From 5be7641f875e264cb0a453523373f7127c3f6f17 Mon Sep 17 00:00:00 2001 From: Michael Hobbs Date: Wed, 10 Jun 2015 18:10:48 -0700 Subject: [PATCH] call tag-add and tag-remove pluginhooks --- docs/development/pluginhooks.md | 36 +++++++++++++++++++++++++++++++++ plugins/tag/commands | 2 ++ 2 files changed, 38 insertions(+) diff --git a/docs/development/pluginhooks.md b/docs/development/pluginhooks.md index 202328e28..8236b0563 100644 --- a/docs/development/pluginhooks.md +++ b/docs/development/pluginhooks.md @@ -629,3 +629,39 @@ if [[ ! -d "$DOKKU_ROOT/$APP" ]]; then fi pluginhook receive-app $APP $newrev ``` + +### `tag-add` + +- Description: Allows you to run commands once a tag for an application image has been added +- Invoked by: `dokku tag:add` +- Arguments: `$APP $TAG` +- Example: + +```shell +#!/usr/bin/env bash +# Upload an application image to docker hub + +set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x +APP="$1"; TAG="$2"; IMAGE="dokku/${APP}:${TAG}" + +IMAGE_ID=$(docker inspect --format '{{ .Id }}' $IMAGE) +docker tag -f $IMAGE_ID $DOCKER_HUB_USER/$APP:$TAG +docker push $DOCKER_HUB_USER/$APP:$TAG +``` + +### `tag-remove` + +- Description: Allows you to run commands once a tag for an application image has been removed +- Invoked by: `dokku tag:remove` +- Arguments: `$APP $TAG` +- Example: + +```shell +#!/usr/bin/env bash +# Remove an image tag from docker hub + +set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x +APP="$1"; TAG="$2" + +some code to remove a docker hub tag because it's not implemented in the CLI.... +``` diff --git a/plugins/tag/commands b/plugins/tag/commands index f035cbca4..8bc308dd4 100755 --- a/plugins/tag/commands +++ b/plugins/tag/commands @@ -12,6 +12,7 @@ case "$1" in tag_image "$IMAGE:latest" "$IMAGE:$TAG" dokku_log_info2_quiet "Added $TAG tag to $IMAGE" + pluginhook tag-add $APP $TAG ;; tag:deploy) @@ -45,6 +46,7 @@ case "$1" in docker rmi "$IMAGE:$TAG" ;; esac + pluginhook tag-remove $APP $TAG ;; help | tag:help)