diff --git a/plugins/scheduler-docker-local/README.md b/plugins/scheduler-docker-local/README.md new file mode 100644 index 000000000..e69de29bb diff --git a/plugins/tags/functions b/plugins/scheduler-docker-local/scheduler-tags-create old mode 100755 new mode 100644 similarity index 62% rename from plugins/tags/functions rename to plugins/scheduler-docker-local/scheduler-tags-create index 2dc060c21..2e46c6ae1 --- a/plugins/tags/functions +++ b/plugins/scheduler-docker-local/scheduler-tags-create @@ -2,6 +2,21 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" +scheduler-docker-local-scheduler-tags-create() { + declare desc="scheduler-docker-local scheduler-stop plugin trigger" + declare trigger="scheduler-docker-local scheduler-stop" + declare DOKKU_SCHEDULER="$1" APP="$2" SOURCE_IMAGE="$3" TARGET_IMAGE="$4" + + if [[ "$DOKKU_SCHEDULER" != "docker-local" ]]; then + return + fi + + local TAG_OPTS="" + [[ $(is_tag_force_available) ]] && TAG_OPTS="-f" + # shellcheck disable=SC2086 + docker tag $TAG_OPTS "$SOURCE_IMAGE" "$TARGET_IMAGE" +} + is_tag_force_available() { CLIENT_VERSION_STRING="$(get_docker_version)" MAJOR_VERSION=$(echo "$CLIENT_VERSION_STRING" | awk '{split($0,a,"."); print a[1]}') @@ -18,9 +33,4 @@ is_tag_force_available() { fi } -tag_image() { - declare desc="convenience method for docker tag interface" - [[ $(is_tag_force_available) ]] && TAG_OPTS="-f" - # shellcheck disable=SC2086 - docker tag $TAG_OPTS "$1" "$2" -} +scheduler-docker-local-scheduler-tags-create "$@" diff --git a/plugins/scheduler-docker-local/scheduler-tags-destroy b/plugins/scheduler-docker-local/scheduler-tags-destroy new file mode 100644 index 000000000..779ebc4f4 --- /dev/null +++ b/plugins/scheduler-docker-local/scheduler-tags-destroy @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x +source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" + +scheduler-docker-local-scheduler-tags-destroy() { + declare desc="scheduler-docker-local scheduler-stop plugin trigger" + declare trigger="scheduler-docker-local scheduler-stop" + declare DOKKU_SCHEDULER="$1" APP="$2" IMAGE_REPO="$3" IMAGE_TAG="$4" + + if [[ "$DOKKU_SCHEDULER" != "docker-local" ]]; then + return + fi + + docker rmi "$IMAGE_REPO:$IMAGE_TAG" +} + +scheduler-docker-local-scheduler-tags-destroy "$@" diff --git a/plugins/tags/subcommands/create b/plugins/tags/subcommands/create index 00adbea58..2a90f8c8c 100755 --- a/plugins/tags/subcommands/create +++ b/plugins/tags/subcommands/create @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" -source "$PLUGIN_AVAILABLE_PATH/tags/functions" +source "$PLUGIN_AVAILABLE_PATH/config/functions" tags_create_cmd() { declare desc="creates an images tag for app via command line" @@ -10,7 +10,9 @@ tags_create_cmd() { local APP="$2"; local IMAGE_TAG="$3"; local IMAGE_REPO=$(get_app_image_repo "$APP") verify_app_name "$APP" - tag_image "$IMAGE_REPO:latest" "$IMAGE_REPO:$IMAGE_TAG" + local DOKKU_SCHEDULER=$(config_get "$APP" DOKKU_SCHEDULER || echo "docker-local") + plugn trigger scheduler-tags-create "$DOKKU_SCHEDULER" "$APP" "$IMAGE_REPO:latest" "$IMAGE_REPO:$IMAGE_TAG" + dokku_log_info2_quiet "Added $IMAGE_TAG tag to $IMAGE_REPO" plugn trigger tags-create "$APP" "$IMAGE_TAG" } diff --git a/plugins/tags/subcommands/default b/plugins/tags/subcommands/default index de16fb926..1b9da0050 100755 --- a/plugins/tags/subcommands/default +++ b/plugins/tags/subcommands/default @@ -1,7 +1,6 @@ #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" -source "$PLUGIN_AVAILABLE_PATH/tags/functions" tags_main_cmd() { declare desc="shows docker images tags for app via command line" diff --git a/plugins/tags/subcommands/deploy b/plugins/tags/subcommands/deploy index 35c573595..f924bea67 100755 --- a/plugins/tags/subcommands/deploy +++ b/plugins/tags/subcommands/deploy @@ -1,7 +1,6 @@ #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" -source "$PLUGIN_AVAILABLE_PATH/tags/functions" tags_deploy_cmd() { declare desc="deploys an app with a given tagged image via command line" diff --git a/plugins/tags/subcommands/destroy b/plugins/tags/subcommands/destroy index 4fec517ab..5a8293c4a 100755 --- a/plugins/tags/subcommands/destroy +++ b/plugins/tags/subcommands/destroy @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" -source "$PLUGIN_AVAILABLE_PATH/tags/functions" +source "$PLUGIN_AVAILABLE_PATH/config/functions" tags_destroy_cmd() { declare desc="destroys an app image tag via command line" @@ -16,7 +16,8 @@ tags_destroy_cmd() { ;; *) - docker rmi "$IMAGE_REPO:$IMAGE_TAG" + local DOKKU_SCHEDULER=$(config_get "$APP" DOKKU_SCHEDULER || echo "docker-local") + plugn trigger scheduler-tags-destroy "$DOKKU_SCHEDULER" "$APP" "$IMAGE_REPO" "$IMAGE_TAG" ;; esac plugn trigger tags-destroy "$APP" "$IMAGE_TAG"