feat: implement docker-options:clear

Closes #3776
This commit is contained in:
Jose Diaz-Gonzalez
2020-02-01 17:06:27 -08:00
parent dcb79f8c0b
commit fc8a8d6138
4 changed files with 107 additions and 0 deletions

View File

@@ -8,6 +8,7 @@ docker_options_help_content_func() {
cat <<help_content
docker-options <app> [phase(s)], [DEPRECATED] Alternative for docker-options:report
docker-options:add <app> <phase(s)> OPTION, Add Docker option to app for phase (comma separated phase list)
docker-options:clear <app> [phase(s)], Clear a docker options from application with an optional phase (comma separated phase list)
docker-options:remove <app> <phase(s)> OPTION, Remove Docker option from app for phase (comma separated phase list)
docker-options:report [<app>] [<flag>], Displays a docker options report for one or more apps
help_content

View File

@@ -0,0 +1,29 @@
#!/usr/bin/env bash
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/docker-options/functions"
cmd-docker-options-clear() {
declare desc="clear a docker options from application"
declare cmd="docker-options:clear" argv=("$@")
[[ ${argv[0]} == "$cmd" ]] && shift 1
declare APP="$1" PHASES="$2"
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
verify_app_name "$APP"
if [[ -z "$PHASES" ]]; then
dokku_log_info1 "Clearing docker-options for $APP on all phases"
rm -f "$(fn-get-phase-file-path "$APP" "build")" "$(fn-get-phase-file-path "$APP" "deploy")" "$(fn-get-phase-file-path "$APP" "run")"
return
fi
read -ra passed_phases <<<"$(get_phases "$PHASES")"
for phase in "${passed_phases[@]}"; do
dokku_log_info1 "Clearing docker-options for $APP on phase $phase"
rm -f "$(fn-get-phase-file-path "$APP" "$phase")"
done
}
cmd-docker-options-clear "$@"