diff --git a/plugins/apps/Makefile b/plugins/apps/Makefile index 7bf928361..ff5fb0725 100644 --- a/plugins/apps/Makefile +++ b/plugins/apps/Makefile @@ -1,4 +1,4 @@ -SUBCOMMANDS = subcommands/clone subcommands/create subcommands/destroy subcommands/exists subcommands/list subcommands/lock subcommands/locked subcommands/rename subcommands/report subcommands/unlock +SUBCOMMANDS = subcommands/clone subcommands/create subcommands/destroy subcommands/exists subcommands/list subcommands/lock subcommands/locked subcommands/rename subcommands/report subcommands/set subcommands/unlock TRIGGERS = triggers/app-create triggers/app-destroy triggers/app-exists triggers/app-maybe-create triggers/deploy-source-set triggers/install triggers/post-app-clone-setup triggers/post-app-rename triggers/post-app-rename-setup triggers/post-create triggers/post-delete triggers/report BUILD = commands subcommands triggers PLUGIN_NAME = apps diff --git a/plugins/apps/src/commands/commands.go b/plugins/apps/src/commands/commands.go index 3f6d37859..8cc38f158 100644 --- a/plugins/apps/src/commands/commands.go +++ b/plugins/apps/src/commands/commands.go @@ -28,6 +28,7 @@ Additional commands:` apps:locked , Checks if an app is locked for deployment apps:rename , Rename an app apps:report [] [], Display report about an app + apps:set |--global , Set or clear an apps property apps:unlock , Unlocks an app for deployment` ) diff --git a/plugins/apps/src/subcommands/subcommands.go b/plugins/apps/src/subcommands/subcommands.go index 0874f7084..a61e46d45 100644 --- a/plugins/apps/src/subcommands/subcommands.go +++ b/plugins/apps/src/subcommands/subcommands.go @@ -72,6 +72,13 @@ func main() { appName := args.Arg(0) err = apps.CommandReport(appName, *format, infoFlag) } + case "set": + args := flag.NewFlagSet("apps:set", flag.ExitOnError) + args.Parse(os.Args[2:]) + appName := args.Arg(0) + property := args.Arg(1) + value := args.Arg(2) + err = apps.CommandSet(appName, property, value) case "unlock": args := flag.NewFlagSet("apps:unlock", flag.ExitOnError) args.Parse(os.Args[2:]) diff --git a/plugins/apps/subcommands.go b/plugins/apps/subcommands.go index 40291c2c8..8c02d33bc 100644 --- a/plugins/apps/subcommands.go +++ b/plugins/apps/subcommands.go @@ -226,6 +226,12 @@ func CommandReport(appName string, format string, infoFlag string) error { return ReportSingleApp(appName, format, infoFlag) } +// CommandSet set or clear an apps property for an app +func CommandSet(appName string, property string, value string) error { + common.CommandPropertySet("apps", appName, property, value, DefaultProperties, GlobalProperties) + return nil +} + // CommandUnlock unlocks an app for deployment func CommandUnlock(appName string) error { if err := common.VerifyAppName(appName); err != nil { diff --git a/plugins/nginx-vhosts/functions b/plugins/nginx-vhosts/functions index 0f81141c4..1b15cde8e 100755 --- a/plugins/nginx-vhosts/functions +++ b/plugins/nginx-vhosts/functions @@ -227,8 +227,8 @@ nginx_build_config() { # setup nginx listen ports plugn trigger ports-configure "$APP" - local PROXY_PORT=$(config_get "$APP" DOKKU_PROXY_PORT) - local PROXY_SSL_PORT=$(config_get "$APP" DOKKU_PROXY_SSL_PORT) + local PROXY_PORT=$(plugn trigger ports-get-property "$APP" "proxy-port") + local PROXY_SSL_PORT=$(plugn trigger ports-get-property "$APP" "proxy-ssl-port") local PORT_MAP PROXY_PORT_MAP proxy_port_map while read -r PORT_MAP; do diff --git a/plugins/nginx-vhosts/pre-disable-vhost b/plugins/nginx-vhosts/pre-disable-vhost index 4aa94cec9..027dedcd6 100755 --- a/plugins/nginx-vhosts/pre-disable-vhost +++ b/plugins/nginx-vhosts/pre-disable-vhost @@ -2,7 +2,7 @@ set -eo pipefail [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" -source "$PLUGIN_AVAILABLE_PATH/config/functions" +source "$PLUGIN_CORE_AVAILABLE_PATH/common/property-functions" trigger-nginx-vhosts-pre-disable-vhost() { declare desc="unset port prior to vhosts being disabled" @@ -14,19 +14,14 @@ trigger-nginx-vhosts-pre-disable-vhost() { fi # only clear ports if they are port 80 or 443 - local PROXY_PORT=$(config_get "$APP" DOKKU_PROXY_PORT) - local PROXY_SSL_PORT=$(config_get "$APP" DOKKU_PROXY_SSL_PORT) + local PROXY_PORT=$(plugn trigger ports-get-property "$APP" "proxy-port") + local PROXY_SSL_PORT=$(plugn trigger ports-get-property "$APP" "proxy-ssl-port") - ports_to_clear=() if [[ "$PROXY_PORT" == "80" ]]; then - ports_to_clear+=("DOKKU_PROXY_PORT") + fn-plugin-property-delete "ports" "$APP" "proxy-port" fi if [[ "$PROXY_SSL_PORT" == "443" ]]; then - ports_to_clear+=("DOKKU_PROXY_SSL_PORT") - fi - - if [[ "${#ports_to_clear[@]}" -gt 0 ]]; then - DOKKU_QUIET_OUTPUT=1 config_unset --no-restart "$APP" "${ports_to_clear[@]}" + fn-plugin-property-delete "ports" "$APP" "proxy-ssl-port" fi # clear ports if there is a mapping starting with http:80 or https:443 diff --git a/plugins/nginx-vhosts/pre-enable-vhost b/plugins/nginx-vhosts/pre-enable-vhost index c8a7f4e56..11615f4be 100755 --- a/plugins/nginx-vhosts/pre-enable-vhost +++ b/plugins/nginx-vhosts/pre-enable-vhost @@ -2,7 +2,7 @@ set -eo pipefail [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" -source "$PLUGIN_AVAILABLE_PATH/config/functions" +source "$PLUGIN_CORE_AVAILABLE_PATH/common/property-functions" trigger-nginx-vhosts-pre-enable-vhost() { declare desc="unset port prior to vhosts being enabled" @@ -14,19 +14,14 @@ trigger-nginx-vhosts-pre-enable-vhost() { fi # only clear ports if they are port 80 or 443 - local PROXY_PORT=$(config_get "$APP" DOKKU_PROXY_PORT) - local PROXY_SSL_PORT=$(config_get "$APP" DOKKU_PROXY_SSL_PORT) + local PROXY_PORT=$(plugn trigger ports-get-property "$APP" "proxy-port") + local PROXY_SSL_PORT=$(plugn trigger ports-get-property "$APP" "proxy-ssl-port") - ports_to_clear=() if [[ "$PROXY_PORT" == "80" ]]; then - ports_to_clear+=("DOKKU_PROXY_PORT") + fn-plugin-property-delete "ports" "$APP" "proxy-port" fi if [[ "$PROXY_SSL_PORT" == "443" ]]; then - ports_to_clear+=("DOKKU_PROXY_SSL_PORT") - fi - - if [[ "${#ports_to_clear[@]}" -gt 0 ]]; then - DOKKU_QUIET_OUTPUT=1 config_unset --no-restart "$APP" "${ports_to_clear[@]}" + fn-plugin-property-delete "ports" "$APP" "proxy-ssl-port" fi # clear ports if there is a mapping starting with http:80 or https:443 diff --git a/tests/unit/apps_2.bats b/tests/unit/apps_2.bats index 49c30f037..0926fe33c 100644 --- a/tests/unit/apps_2.bats +++ b/tests/unit/apps_2.bats @@ -116,7 +116,7 @@ teardown() { echo "output: $output" echo "status: $status" assert_success - run /bin/bash -c "dokku ports:set $TEST_APP proxy-ssl-port 443" + run /bin/bash -c "$PLUGIN_CORE_AVAILABLE_PATH/common/prop set ports $TEST_APP proxy-ssl-port 443" echo "output: $output" echo "status: $status" assert_success diff --git a/tests/unit/nginx-vhosts_5.bats b/tests/unit/nginx-vhosts_5.bats index 1c6ebc88f..9f8963950 100644 --- a/tests/unit/nginx-vhosts_5.bats +++ b/tests/unit/nginx-vhosts_5.bats @@ -62,7 +62,7 @@ teardown() { @test "(nginx-vhosts) proxy:build-config (global proxy-port)" { local GLOBAL_PORT=30999 - run /bin/bash -c "dokku ports:set --global proxy-port ${GLOBAL_PORT}" + run /bin/bash -c "$PLUGIN_CORE_AVAILABLE_PATH/common/prop set ports --global proxy-port ${GLOBAL_PORT}" echo "output: $output" echo "status: $status" assert_success @@ -74,7 +74,7 @@ teardown() { check_urls "http://${TEST_APP}.${DOKKU_DOMAIN}:${GLOBAL_PORT}" assert_http_success "http://${TEST_APP}.${DOKKU_DOMAIN}:${GLOBAL_PORT}" - run /bin/bash -c "dokku ports:set --global proxy-port" + run /bin/bash -c "$PLUGIN_CORE_AVAILABLE_PATH/common/prop del ports --global proxy-port" echo "output: $output" echo "status: $status" assert_success