From 2516c79264cec54d1ef752a608d47371adcc5449 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Thu, 28 Mar 2024 21:16:04 -0400 Subject: [PATCH] fix: add --global flag to ps:set Closes #6755 --- plugins/ps/src/subcommands/subcommands.go | 6 +++ tests/unit/ps-general-1.bats | 48 +++++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/plugins/ps/src/subcommands/subcommands.go b/plugins/ps/src/subcommands/subcommands.go index a970fef3378..24172b49035 100644 --- a/plugins/ps/src/subcommands/subcommands.go +++ b/plugins/ps/src/subcommands/subcommands.go @@ -68,10 +68,16 @@ func main() { err = ps.CommandScale(appName, *skipDeploy, processTuples) case "set": args := flag.NewFlagSet("ps:set", flag.ExitOnError) + global := args.Bool("global", false, "--global: set a global property") args.Parse(os.Args[2:]) appName := args.Arg(0) property := args.Arg(1) value := args.Arg(2) + if *global { + appName = "--global" + property = args.Arg(0) + value = args.Arg(1) + } err = ps.CommandSet(appName, property, value) case "start": args := flag.NewFlagSet("ps:start", flag.ExitOnError) diff --git a/tests/unit/ps-general-1.bats b/tests/unit/ps-general-1.bats index 13f4d6a7a58..d1a0ffcf09f 100644 --- a/tests/unit/ps-general-1.bats +++ b/tests/unit/ps-general-1.bats @@ -45,6 +45,54 @@ teardown() { assert_output_contains "$CID" 6 } +@test "(ps:set) procfile" { + run /bin/bash -c "dokku ps:set --global procfile-path .dokku/Procfile" + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "dokku ps:report $TEST_APP --ps-computed-procfile-path" + echo "output: $output" + echo "status: $status" + assert_output ".dokku/Procfile" + assert_success + + run /bin/bash -c "dokku ps:report $TEST_APP --ps-global-procfile-path" + echo "output: $output" + echo "status: $status" + assert_output ".dokku/Procfile" + assert_success + + run /bin/bash -c "dokku ps:report $TEST_APP --ps-procfile-path" + echo "output: $output" + echo "status: $status" + assert_output "" + assert_success + + run /bin/bash -c "dokku ps:set --global procfile-path" + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "dokku ps:report $TEST_APP --ps-computed-procfile-path" + echo "output: $output" + echo "status: $status" + assert_output "Procfile" + assert_success + + run /bin/bash -c "dokku ps:report $TEST_APP --ps-global-procfile-path" + echo "output: $output" + echo "status: $status" + assert_output "Procfile" + assert_success + + run /bin/bash -c "dokku ps:report $TEST_APP --ps-procfile-path" + echo "output: $output" + echo "status: $status" + assert_output "" + assert_success +} + @test "(ps:scale) procfile commands extraction" { source "$PLUGIN_CORE_AVAILABLE_PATH/ps/functions" cat <"$DOKKU_LIB_ROOT/data/ps/$TEST_APP/Procfile"