@@ -6,6 +6,7 @@ Pass [options](https://docs.docker.com/engine/reference/run/) to Docker during D
|
|||||||
|
|
||||||
```
|
```
|
||||||
docker-options:add <app> <phase(s)> OPTION # Add Docker option to app for phase (comma-separated phase list)
|
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
|
||||||
docker-options:remove <app> <phase(s)> OPTION # Remove Docker option from app for 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
|
docker-options:report [<app>] [<flag>] # Displays a docker options report for one or more apps
|
||||||
```
|
```
|
||||||
@@ -44,6 +45,37 @@ dokku docker-options:add node-js-app run "-v /var/log/node-js-app:/app/logs"
|
|||||||
dokku docker-options:remove node-js-app run "-v /var/log/node-js-app:/app/logs"
|
dokku docker-options:remove node-js-app run "-v /var/log/node-js-app:/app/logs"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Clear all Docker options for an app
|
||||||
|
|
||||||
|
Docker options can be removed for a specific app using the `docker-options:clear` command.
|
||||||
|
|
||||||
|
```shell
|
||||||
|
dokku docker-options:clear node-js-app
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
-----> Clearing docker-options for node-js-app on all phases
|
||||||
|
```
|
||||||
|
|
||||||
|
One or more valid phases can also be specified. Phases are comma delimited, and specifying an invalid phase will result in an error.
|
||||||
|
|
||||||
|
```shell
|
||||||
|
dokku docker-options:clear node-js-app run
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
-----> Clearing docker-options for node-js-app on phase run
|
||||||
|
```
|
||||||
|
|
||||||
|
```shell
|
||||||
|
dokku docker-options:clear node-js-app build,run
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
-----> Clearing docker-options for node-js-app on phase build
|
||||||
|
-----> Clearing docker-options for node-js-app on phase run
|
||||||
|
```
|
||||||
|
|
||||||
### Displaying docker-options reports for an app
|
### Displaying docker-options reports for an app
|
||||||
|
|
||||||
> New as of 0.8.1
|
> New as of 0.8.1
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ docker_options_help_content_func() {
|
|||||||
cat <<help_content
|
cat <<help_content
|
||||||
docker-options <app> [phase(s)], [DEPRECATED] Alternative for docker-options:report
|
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: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: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
|
docker-options:report [<app>] [<flag>], Displays a docker options report for one or more apps
|
||||||
help_content
|
help_content
|
||||||
|
|||||||
29
plugins/docker-options/subcommands/clear
Executable file
29
plugins/docker-options/subcommands/clear
Executable 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 "$@"
|
||||||
@@ -23,6 +23,51 @@ teardown() {
|
|||||||
assert_success
|
assert_success
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@test "(docker-options) docker-options:clear" {
|
||||||
|
run /bin/bash -c "dokku docker-options:add $TEST_APP build,deploy,run \"-v /tmp\""
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
run /bin/bash -c "dokku docker-options:clear $TEST_APP"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
run /bin/bash -c "dokku docker-options $TEST_APP | egrep '\-v /tmp' | wc -l | grep -q 0"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku docker-options:add $TEST_APP build,deploy,run \"-v /tmp\""
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
run /bin/bash -c "dokku docker-options:clear $TEST_APP build"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
run /bin/bash -c "dokku docker-options $TEST_APP | egrep '\-v /tmp' | wc -l | grep -q 2"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
run /bin/bash -c "dokku docker-options:clear $TEST_APP deploy"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
run /bin/bash -c "dokku docker-options $TEST_APP | egrep '\-v /tmp' | wc -l | grep -q 1"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
run /bin/bash -c "dokku docker-options:clear $TEST_APP run"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
run /bin/bash -c "dokku docker-options $TEST_APP | egrep '\-v /tmp' | wc -l | grep -q 0"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
}
|
||||||
|
|
||||||
@test "(docker-options) docker-options:add (build phase)" {
|
@test "(docker-options) docker-options:add (build phase)" {
|
||||||
run /bin/bash -c "dokku docker-options:add $TEST_APP build \"-v /tmp\""
|
run /bin/bash -c "dokku docker-options:add $TEST_APP build \"-v /tmp\""
|
||||||
echo "output: $output"
|
echo "output: $output"
|
||||||
|
|||||||
Reference in New Issue
Block a user