mirror of
https://github.com/dokku/dokku.git
synced 2025-12-29 00:25:08 +01:00
refactor: move docker-related commands from tags plugin into scheduler-docker-local plugin
This commit is contained in:
0
plugins/scheduler-docker-local/README.md
Normal file
0
plugins/scheduler-docker-local/README.md
Normal file
22
plugins/tags/functions → plugins/scheduler-docker-local/scheduler-tags-create
Executable file → Normal file
22
plugins/tags/functions → plugins/scheduler-docker-local/scheduler-tags-create
Executable file → Normal file
@@ -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 "$@"
|
||||
17
plugins/scheduler-docker-local/scheduler-tags-destroy
Normal file
17
plugins/scheduler-docker-local/scheduler-tags-destroy
Normal file
@@ -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
|
||||
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"
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user