refactor: move docker-related commands from tags plugin into scheduler-docker-local plugin
This commit is contained in:
1 parent
8474c72a10
commit
06a5ac9fc7
7 files changed
+40
-12
No files matched your search
Whitespace-only changes.
Executable → Regular
+16
-6
@@ -2,6 +2,21 @@
|
|||||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
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() {
|
is_tag_force_available() {
|
||||||
CLIENT_VERSION_STRING="$(get_docker_version)"
|
CLIENT_VERSION_STRING="$(get_docker_version)"
|
||||||
MAJOR_VERSION=$(echo "$CLIENT_VERSION_STRING" | awk '{split($0,a,"."); print a[1]}')
|
MAJOR_VERSION=$(echo "$CLIENT_VERSION_STRING" | awk '{split($0,a,"."); print a[1]}')
|
||||||
@@ -18,9 +33,4 @@ is_tag_force_available() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
tag_image() {
|
scheduler-docker-local-scheduler-tags-create "$@"
|
||||||
declare desc="convenience method for docker tag interface"
|
|
||||||
[[ $(is_tag_force_available) ]] && TAG_OPTS="-f"
|
|
||||||
# shellcheck disable=SC2086
|
|
||||||
docker tag $TAG_OPTS "$1" "$2"
|
|
||||||
}
|
|
||||||
@@ -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 "$@"
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||||
source "$PLUGIN_AVAILABLE_PATH/tags/functions"
|
source "$PLUGIN_AVAILABLE_PATH/config/functions"
|
||||||
|
|
||||||
tags_create_cmd() {
|
tags_create_cmd() {
|
||||||
declare desc="creates an images tag for app via command line"
|
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")
|
local APP="$2"; local IMAGE_TAG="$3"; local IMAGE_REPO=$(get_app_image_repo "$APP")
|
||||||
verify_app_name "$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"
|
dokku_log_info2_quiet "Added $IMAGE_TAG tag to $IMAGE_REPO"
|
||||||
plugn trigger tags-create "$APP" "$IMAGE_TAG"
|
plugn trigger tags-create "$APP" "$IMAGE_TAG"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||||
source "$PLUGIN_AVAILABLE_PATH/tags/functions"
|
|
||||||
|
|
||||||
tags_main_cmd() {
|
tags_main_cmd() {
|
||||||
declare desc="shows docker images tags for app via command line"
|
declare desc="shows docker images tags for app via command line"
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||||
source "$PLUGIN_AVAILABLE_PATH/tags/functions"
|
|
||||||
|
|
||||||
tags_deploy_cmd() {
|
tags_deploy_cmd() {
|
||||||
declare desc="deploys an app with a given tagged image via command line"
|
declare desc="deploys an app with a given tagged image via command line"
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||||
source "$PLUGIN_AVAILABLE_PATH/tags/functions"
|
source "$PLUGIN_AVAILABLE_PATH/config/functions"
|
||||||
|
|
||||||
tags_destroy_cmd() {
|
tags_destroy_cmd() {
|
||||||
declare desc="destroys an app image tag via command line"
|
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
|
esac
|
||||||
plugn trigger tags-destroy "$APP" "$IMAGE_TAG"
|
plugn trigger tags-destroy "$APP" "$IMAGE_TAG"
|
||||||
|
|||||||
Reference in new issue
Block a user