From 824079038189c06989f5928abda51b69054b3683 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 19 Dec 2020 20:01:15 -0500 Subject: [PATCH] fix: correct argument handling when setting the `--app` flag MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When setting the `--app` flag, there was a special case for the config plugin. This plugin used to take the `--no-restart` flag as the first argument - and still did until this change - resulting in an invalid call to the plugin subcommands. What is worse is that this functionality carried over to all other plugins as they were rewritten in golang, and thus the issue spread without us knowing. The fix is to support GNU flag parsing rules, which Golang does not do by default (Because Of Reasons™). Switching to `github.com/spf13/pflag` fixes this issue, and also allows positional arguments to be placed wherever, even in the middle of flags. Closes #4255 --- dokku | 7 +--- plugins/apps/go.mod | 1 + plugins/apps/go.sum | 2 + plugins/apps/src/subcommands/subcommands.go | 3 +- plugins/buildpacks/go.mod | 1 + plugins/buildpacks/go.sum | 2 + .../buildpacks/src/subcommands/subcommands.go | 3 +- plugins/config/go.mod | 1 + plugins/config/go.sum | 2 + plugins/config/src/subcommands/subcommands.go | 3 +- plugins/logs/go.mod | 1 + plugins/logs/go.sum | 2 + plugins/logs/src/subcommands/subcommands.go | 3 +- plugins/network/go.mod | 1 + plugins/network/go.sum | 2 + .../network/src/subcommands/subcommands.go | 3 +- plugins/proxy/go.mod | 1 + plugins/proxy/go.sum | 2 + plugins/proxy/src/subcommands/subcommands.go | 3 +- plugins/ps/go.mod | 1 + plugins/ps/go.sum | 2 + plugins/ps/src/subcommands/subcommands.go | 3 +- plugins/repo/go.mod | 1 + plugins/repo/go.sum | 2 + plugins/repo/src/subcommands/subcommands.go | 3 +- plugins/resource/go.mod | 3 +- plugins/resource/go.sum | 2 + .../resource/src/subcommands/subcommands.go | 3 +- tests/unit/client.bats | 40 +++++++++++++++++++ 29 files changed, 87 insertions(+), 16 deletions(-) diff --git a/dokku b/dokku index 51d2fced2..5e10bbb97 100755 --- a/dokku +++ b/dokku @@ -144,12 +144,7 @@ execute_dokku_cmd() { if [[ "$(readlink -f "$PLUGIN_ENABLED_PATH/${PLUGIN_NAME%%:*}")" == *core-plugins* ]]; then [[ ${argv[0]} == "$PLUGIN_CMD" ]] && shift 1 if [[ -n $DOKKU_APP_NAME ]]; then - if [[ "$PLUGIN_CMD" == config* ]] && [[ ${argv[1]} == "--no-restart" ]]; then - shift 1 - set -- "--no-restart" "$DOKKU_APP_NAME" "$@" - else - set -- "$DOKKU_APP_NAME" "$@" - fi + set -- "$DOKKU_APP_NAME" "$@" fi set -- "$PLUGIN_CMD" "$@" fi diff --git a/plugins/apps/go.mod b/plugins/apps/go.mod index c43805370..45d84a255 100644 --- a/plugins/apps/go.mod +++ b/plugins/apps/go.mod @@ -6,6 +6,7 @@ require ( github.com/codeskyblue/go-sh v0.0.0-20190412065543-76bd3d59ff27 // indirect github.com/dokku/dokku/plugins/common v0.0.0-00010101000000-000000000000 github.com/ryanuber/columnize v1.1.2-0.20190319233515-9e6335e58db3 // indirect + github.com/spf13/pflag v1.0.5 // indirect ) replace github.com/dokku/dokku/plugins/common => ../common diff --git a/plugins/apps/go.sum b/plugins/apps/go.sum index f05068f8d..8d94a86e4 100644 --- a/plugins/apps/go.sum +++ b/plugins/apps/go.sum @@ -4,3 +4,5 @@ github.com/codeskyblue/go-sh v0.0.0-20190412065543-76bd3d59ff27 h1:HHUr4P/aKh4qu github.com/codeskyblue/go-sh v0.0.0-20190412065543-76bd3d59ff27/go.mod h1:VQx0hjo2oUeQkQUET7wRwradO6f+fN5jzXgB/zROxxE= github.com/ryanuber/columnize v1.1.2-0.20190319233515-9e6335e58db3 h1:utdYOikI1XjNtTFGCwSM6OmFJblU4ld4gACoJsbadJg= github.com/ryanuber/columnize v1.1.2-0.20190319233515-9e6335e58db3/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= +github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= diff --git a/plugins/apps/src/subcommands/subcommands.go b/plugins/apps/src/subcommands/subcommands.go index 218031a12..208d9eed2 100644 --- a/plugins/apps/src/subcommands/subcommands.go +++ b/plugins/apps/src/subcommands/subcommands.go @@ -1,13 +1,14 @@ package main import ( - "flag" "fmt" "os" "strings" "github.com/dokku/dokku/plugins/apps" "github.com/dokku/dokku/plugins/common" + + flag "github.com/spf13/pflag" ) // main entrypoint to all subcommands diff --git a/plugins/buildpacks/go.mod b/plugins/buildpacks/go.mod index b77ee8b6f..d37f10d5c 100644 --- a/plugins/buildpacks/go.mod +++ b/plugins/buildpacks/go.mod @@ -6,6 +6,7 @@ require ( github.com/codeskyblue/go-sh v0.0.0-20190412065543-76bd3d59ff27 // indirect github.com/dokku/dokku/plugins/common v0.0.0-00010101000000-000000000000 github.com/ryanuber/columnize v1.1.2-0.20190319233515-9e6335e58db3 + github.com/spf13/pflag v1.0.5 // indirect ) replace github.com/dokku/dokku/plugins/common => ../common diff --git a/plugins/buildpacks/go.sum b/plugins/buildpacks/go.sum index f05068f8d..8d94a86e4 100644 --- a/plugins/buildpacks/go.sum +++ b/plugins/buildpacks/go.sum @@ -4,3 +4,5 @@ github.com/codeskyblue/go-sh v0.0.0-20190412065543-76bd3d59ff27 h1:HHUr4P/aKh4qu github.com/codeskyblue/go-sh v0.0.0-20190412065543-76bd3d59ff27/go.mod h1:VQx0hjo2oUeQkQUET7wRwradO6f+fN5jzXgB/zROxxE= github.com/ryanuber/columnize v1.1.2-0.20190319233515-9e6335e58db3 h1:utdYOikI1XjNtTFGCwSM6OmFJblU4ld4gACoJsbadJg= github.com/ryanuber/columnize v1.1.2-0.20190319233515-9e6335e58db3/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= +github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= diff --git a/plugins/buildpacks/src/subcommands/subcommands.go b/plugins/buildpacks/src/subcommands/subcommands.go index fe5e46179..dc9743d0c 100644 --- a/plugins/buildpacks/src/subcommands/subcommands.go +++ b/plugins/buildpacks/src/subcommands/subcommands.go @@ -1,13 +1,14 @@ package main import ( - "flag" "fmt" "os" "strings" "github.com/dokku/dokku/plugins/buildpacks" "github.com/dokku/dokku/plugins/common" + + flag "github.com/spf13/pflag" ) // main entrypoint to all subcommands diff --git a/plugins/config/go.mod b/plugins/config/go.mod index 2e777c4f2..1b9ee9e55 100644 --- a/plugins/config/go.mod +++ b/plugins/config/go.mod @@ -7,6 +7,7 @@ require ( github.com/dokku/dokku/plugins/common v0.0.0-00010101000000-000000000000 github.com/joho/godotenv v1.2.0 github.com/ryanuber/columnize v1.1.2-0.20190319233515-9e6335e58db3 + github.com/spf13/pflag v1.0.5 // indirect ) replace github.com/dokku/dokku/plugins/common => ../common diff --git a/plugins/config/go.sum b/plugins/config/go.sum index 8966db493..bb951f71d 100644 --- a/plugins/config/go.sum +++ b/plugins/config/go.sum @@ -6,3 +6,5 @@ github.com/joho/godotenv v1.2.0 h1:vGTvz69FzUFp+X4/bAkb0j5BoLC+9bpqTWY8mjhA9pc= github.com/joho/godotenv v1.2.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= github.com/ryanuber/columnize v1.1.2-0.20190319233515-9e6335e58db3 h1:utdYOikI1XjNtTFGCwSM6OmFJblU4ld4gACoJsbadJg= github.com/ryanuber/columnize v1.1.2-0.20190319233515-9e6335e58db3/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= +github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= diff --git a/plugins/config/src/subcommands/subcommands.go b/plugins/config/src/subcommands/subcommands.go index 2d7cdb04a..0ad64a674 100644 --- a/plugins/config/src/subcommands/subcommands.go +++ b/plugins/config/src/subcommands/subcommands.go @@ -1,13 +1,14 @@ package main import ( - "flag" "fmt" "os" "strings" "github.com/dokku/dokku/plugins/common" "github.com/dokku/dokku/plugins/config" + + flag "github.com/spf13/pflag" ) func getKeys(args []string, global bool) []string { diff --git a/plugins/logs/go.mod b/plugins/logs/go.mod index 9c7166d02..7d6a5255d 100644 --- a/plugins/logs/go.mod +++ b/plugins/logs/go.mod @@ -6,6 +6,7 @@ require ( github.com/codeskyblue/go-sh v0.0.0-20190412065543-76bd3d59ff27 github.com/dokku/dokku/plugins/common v0.0.0-00010101000000-000000000000 github.com/ryanuber/columnize v1.1.2-0.20190319233515-9e6335e58db3 // indirect + github.com/spf13/pflag v1.0.5 // indirect ) replace github.com/dokku/dokku/plugins/common => ../common diff --git a/plugins/logs/go.sum b/plugins/logs/go.sum index f05068f8d..8d94a86e4 100644 --- a/plugins/logs/go.sum +++ b/plugins/logs/go.sum @@ -4,3 +4,5 @@ github.com/codeskyblue/go-sh v0.0.0-20190412065543-76bd3d59ff27 h1:HHUr4P/aKh4qu github.com/codeskyblue/go-sh v0.0.0-20190412065543-76bd3d59ff27/go.mod h1:VQx0hjo2oUeQkQUET7wRwradO6f+fN5jzXgB/zROxxE= github.com/ryanuber/columnize v1.1.2-0.20190319233515-9e6335e58db3 h1:utdYOikI1XjNtTFGCwSM6OmFJblU4ld4gACoJsbadJg= github.com/ryanuber/columnize v1.1.2-0.20190319233515-9e6335e58db3/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= +github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= diff --git a/plugins/logs/src/subcommands/subcommands.go b/plugins/logs/src/subcommands/subcommands.go index 1e438bda5..9d09b974a 100644 --- a/plugins/logs/src/subcommands/subcommands.go +++ b/plugins/logs/src/subcommands/subcommands.go @@ -1,13 +1,14 @@ package main import ( - "flag" "fmt" "os" "strings" "github.com/dokku/dokku/plugins/common" "github.com/dokku/dokku/plugins/logs" + + flag "github.com/spf13/pflag" ) // main entrypoint to all subcommands diff --git a/plugins/network/go.mod b/plugins/network/go.mod index c683b16ff..9208e00ad 100644 --- a/plugins/network/go.mod +++ b/plugins/network/go.mod @@ -7,6 +7,7 @@ require ( github.com/codeskyblue/go-sh v0.0.0-20190412065543-76bd3d59ff27 github.com/dokku/dokku/plugins/common v0.0.0-00010101000000-000000000000 github.com/dokku/dokku/plugins/config v0.0.0-00010101000000-000000000000 + github.com/spf13/pflag v1.0.5 // indirect ) replace github.com/dokku/dokku/plugins/common => ../common diff --git a/plugins/network/go.sum b/plugins/network/go.sum index 8966db493..bb951f71d 100644 --- a/plugins/network/go.sum +++ b/plugins/network/go.sum @@ -6,3 +6,5 @@ github.com/joho/godotenv v1.2.0 h1:vGTvz69FzUFp+X4/bAkb0j5BoLC+9bpqTWY8mjhA9pc= github.com/joho/godotenv v1.2.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= github.com/ryanuber/columnize v1.1.2-0.20190319233515-9e6335e58db3 h1:utdYOikI1XjNtTFGCwSM6OmFJblU4ld4gACoJsbadJg= github.com/ryanuber/columnize v1.1.2-0.20190319233515-9e6335e58db3/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= +github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= diff --git a/plugins/network/src/subcommands/subcommands.go b/plugins/network/src/subcommands/subcommands.go index cb9ac377e..88f3040ab 100644 --- a/plugins/network/src/subcommands/subcommands.go +++ b/plugins/network/src/subcommands/subcommands.go @@ -1,13 +1,14 @@ package main import ( - "flag" "fmt" "os" "strings" "github.com/dokku/dokku/plugins/common" "github.com/dokku/dokku/plugins/network" + + flag "github.com/spf13/pflag" ) // main entrypoint to all subcommands diff --git a/plugins/proxy/go.mod b/plugins/proxy/go.mod index 165889ac8..55a0e008b 100644 --- a/plugins/proxy/go.mod +++ b/plugins/proxy/go.mod @@ -7,6 +7,7 @@ require ( github.com/dokku/dokku/plugins/common v0.0.0-00010101000000-000000000000 github.com/dokku/dokku/plugins/config v0.0.0-00010101000000-000000000000 github.com/ryanuber/columnize v1.1.2-0.20190319233515-9e6335e58db3 + github.com/spf13/pflag v1.0.5 // indirect ) replace github.com/dokku/dokku/plugins/common => ../common diff --git a/plugins/proxy/go.sum b/plugins/proxy/go.sum index 8966db493..bb951f71d 100644 --- a/plugins/proxy/go.sum +++ b/plugins/proxy/go.sum @@ -6,3 +6,5 @@ github.com/joho/godotenv v1.2.0 h1:vGTvz69FzUFp+X4/bAkb0j5BoLC+9bpqTWY8mjhA9pc= github.com/joho/godotenv v1.2.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= github.com/ryanuber/columnize v1.1.2-0.20190319233515-9e6335e58db3 h1:utdYOikI1XjNtTFGCwSM6OmFJblU4ld4gACoJsbadJg= github.com/ryanuber/columnize v1.1.2-0.20190319233515-9e6335e58db3/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= +github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= diff --git a/plugins/proxy/src/subcommands/subcommands.go b/plugins/proxy/src/subcommands/subcommands.go index fa320b175..77a0dfb70 100644 --- a/plugins/proxy/src/subcommands/subcommands.go +++ b/plugins/proxy/src/subcommands/subcommands.go @@ -1,13 +1,14 @@ package main import ( - "flag" "fmt" "os" "strings" "github.com/dokku/dokku/plugins/common" "github.com/dokku/dokku/plugins/proxy" + + flag "github.com/spf13/pflag" ) // main entrypoint to all subcommands diff --git a/plugins/ps/go.mod b/plugins/ps/go.mod index 466666a27..7db5a8ce9 100644 --- a/plugins/ps/go.mod +++ b/plugins/ps/go.mod @@ -9,6 +9,7 @@ require ( github.com/dokku/dokku/plugins/docker-options v0.0.0-00010101000000-000000000000 github.com/gofrs/flock v0.8.0 github.com/ryanuber/columnize v1.1.2-0.20190319233515-9e6335e58db3 + github.com/spf13/pflag v1.0.5 // indirect ) replace github.com/dokku/dokku/plugins/common => ../common diff --git a/plugins/ps/go.sum b/plugins/ps/go.sum index b44b50726..e991213a1 100644 --- a/plugins/ps/go.sum +++ b/plugins/ps/go.sum @@ -10,3 +10,5 @@ github.com/joho/godotenv v1.2.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqx github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8= github.com/ryanuber/columnize v1.1.2-0.20190319233515-9e6335e58db3 h1:utdYOikI1XjNtTFGCwSM6OmFJblU4ld4gACoJsbadJg= github.com/ryanuber/columnize v1.1.2-0.20190319233515-9e6335e58db3/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= +github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= diff --git a/plugins/ps/src/subcommands/subcommands.go b/plugins/ps/src/subcommands/subcommands.go index 6eec6e0ae..887843d8d 100644 --- a/plugins/ps/src/subcommands/subcommands.go +++ b/plugins/ps/src/subcommands/subcommands.go @@ -1,13 +1,14 @@ package main import ( - "flag" "fmt" "os" "strings" "github.com/dokku/dokku/plugins/common" "github.com/dokku/dokku/plugins/ps" + + flag "github.com/spf13/pflag" ) // main entrypoint to all subcommands diff --git a/plugins/repo/go.mod b/plugins/repo/go.mod index 3588d0833..bffe0f1c5 100644 --- a/plugins/repo/go.mod +++ b/plugins/repo/go.mod @@ -6,6 +6,7 @@ require ( github.com/codeskyblue/go-sh v0.0.0-20190412065543-76bd3d59ff27 // indirect github.com/dokku/dokku/plugins/common v0.0.0-00010101000000-000000000000 github.com/dokku/dokku/plugins/config v0.0.0-00010101000000-000000000000 + github.com/spf13/pflag v1.0.5 // indirect ) replace github.com/dokku/dokku/plugins/common => ../common diff --git a/plugins/repo/go.sum b/plugins/repo/go.sum index 8966db493..bb951f71d 100644 --- a/plugins/repo/go.sum +++ b/plugins/repo/go.sum @@ -6,3 +6,5 @@ github.com/joho/godotenv v1.2.0 h1:vGTvz69FzUFp+X4/bAkb0j5BoLC+9bpqTWY8mjhA9pc= github.com/joho/godotenv v1.2.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= github.com/ryanuber/columnize v1.1.2-0.20190319233515-9e6335e58db3 h1:utdYOikI1XjNtTFGCwSM6OmFJblU4ld4gACoJsbadJg= github.com/ryanuber/columnize v1.1.2-0.20190319233515-9e6335e58db3/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= +github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= diff --git a/plugins/repo/src/subcommands/subcommands.go b/plugins/repo/src/subcommands/subcommands.go index 3ef36c88c..9e46455d7 100644 --- a/plugins/repo/src/subcommands/subcommands.go +++ b/plugins/repo/src/subcommands/subcommands.go @@ -1,13 +1,14 @@ package main import ( - "flag" "fmt" "os" "strings" "github.com/dokku/dokku/plugins/common" "github.com/dokku/dokku/plugins/repo" + + flag "github.com/spf13/pflag" ) // main entrypoint to all subcommands diff --git a/plugins/resource/go.mod b/plugins/resource/go.mod index ec4d3930c..8b8594909 100644 --- a/plugins/resource/go.mod +++ b/plugins/resource/go.mod @@ -4,8 +4,9 @@ go 1.14 require ( github.com/codeskyblue/go-sh v0.0.0-20190412065543-76bd3d59ff27 // indirect - github.com/dokku/dokku/plugins/common v0.0.0-00010101000000-000000000000 + github.com/dokku/dokku/plugins/common v0.0.0-00010101000000-000000000000 github.com/ryanuber/columnize v1.1.2-0.20190319233515-9e6335e58db3 + github.com/spf13/pflag v1.0.5 // indirect ) replace github.com/dokku/dokku/plugins/common => ../common diff --git a/plugins/resource/go.sum b/plugins/resource/go.sum index f05068f8d..8d94a86e4 100644 --- a/plugins/resource/go.sum +++ b/plugins/resource/go.sum @@ -4,3 +4,5 @@ github.com/codeskyblue/go-sh v0.0.0-20190412065543-76bd3d59ff27 h1:HHUr4P/aKh4qu github.com/codeskyblue/go-sh v0.0.0-20190412065543-76bd3d59ff27/go.mod h1:VQx0hjo2oUeQkQUET7wRwradO6f+fN5jzXgB/zROxxE= github.com/ryanuber/columnize v1.1.2-0.20190319233515-9e6335e58db3 h1:utdYOikI1XjNtTFGCwSM6OmFJblU4ld4gACoJsbadJg= github.com/ryanuber/columnize v1.1.2-0.20190319233515-9e6335e58db3/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= +github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= diff --git a/plugins/resource/src/subcommands/subcommands.go b/plugins/resource/src/subcommands/subcommands.go index b6fbf99ea..7a060cc23 100644 --- a/plugins/resource/src/subcommands/subcommands.go +++ b/plugins/resource/src/subcommands/subcommands.go @@ -1,13 +1,14 @@ package main import ( - "flag" "fmt" "os" "strings" "github.com/dokku/dokku/plugins/common" "github.com/dokku/dokku/plugins/resource" + + flag "github.com/spf13/pflag" ) // main entrypoint to all subcommands diff --git a/tests/unit/client.bats b/tests/unit/client.bats index f5906f201..6af86a629 100644 --- a/tests/unit/client.bats +++ b/tests/unit/client.bats @@ -29,6 +29,46 @@ teardown() { assert_success } +@test "(client) arg parsing" { + run /bin/bash -c "dokku config:set --global GLOBAL_KEY=VALUE" + echo "output: $output" + echo "status: $status" + + run /bin/bash -c "dokku config:set $TEST_APP GLOBAL_KEY=VALUE" + echo "output: $output" + echo "status: $status" + + run /bin/bash -c "${BATS_TEST_DIRNAME}/../../contrib/dokku_client.sh config:export --merged --format shell" + echo "output: $output" + echo "status: $status" + assert_success + + common_output="$output" + run /bin/bash -c "dokku config:export $TEST_APP --merged --format shell" + echo "output: $output" + echo "status: $status" + assert_success + assert_output "$common_output" + + run /bin/bash -c "dokku config:export --merged $TEST_APP --format shell" + echo "output: $output" + echo "status: $status" + assert_success + assert_output "$common_output" + + run /bin/bash -c "dokku config:export --merged --format shell $TEST_APP" + echo "output: $output" + echo "status: $status" + assert_success + assert_output "$common_output" + + run /bin/bash -c "dokku --app $TEST_APP config:export --merged --format shell" + echo "output: $output" + echo "status: $status" + assert_success + assert_output "$common_output" +} + @test "(client) apps:create AND apps:destroy with random name" { setup_client_repo run /bin/bash -c "${BATS_TEST_DIRNAME}/../../contrib/dokku_client.sh apps:create"