diff --git a/plugins/ps/functions.go b/plugins/ps/functions.go index b6af4f6dc67..068f8ab9e3c 100644 --- a/plugins/ps/functions.go +++ b/plugins/ps/functions.go @@ -18,14 +18,35 @@ func canScaleApp(appName string) bool { return common.ToBool(canScale) } -func getProcfileCommand(procfilePath string, processType string, port int) (string, error) { +func getProcfileCommand(appName string, procfilePath string, processType string, port int) (string, error) { if !common.FileExists(procfilePath) { return "", errors.New("No procfile found") } + configResult, err := common.CallPlugnTrigger(common.PlugnTriggerInput{ + Trigger: "config-export", + Args: []string{appName, "false", "true", "envfile"}, + }) + if err != nil { + return "", err + } + + // write the envfile to a temporary file + tempFile, err := os.CreateTemp("", "envfile-*.env") + if err != nil { + return "", err + } + defer os.Remove(tempFile.Name()) + if _, err := tempFile.Write(configResult.StdoutBytes()); err != nil { + return "", err + } + if err := tempFile.Close(); err != nil { + return "", err + } + result, err := common.CallExecCommand(common.ExecCommandInput{ Command: "procfile-util", - Args: []string{"show", "--procfile", procfilePath, "--process-type", processType, "--default-port", strconv.Itoa(port)}, + Args: []string{"show", "--procfile", procfilePath, "--process-type", processType, "--default-port", strconv.Itoa(port), "--env-file", tempFile.Name()}, }) if err != nil { return "", fmt.Errorf("Error running procfile-util: %s", err) diff --git a/plugins/ps/triggers.go b/plugins/ps/triggers.go index ad69a9f61f9..0e355933c79 100644 --- a/plugins/ps/triggers.go +++ b/plugins/ps/triggers.go @@ -274,7 +274,7 @@ func TriggerProcfileGetCommand(appName string, processType string, port int) err return nil } - command, err := getProcfileCommand(getProcessSpecificProcfilePath(appName), processType, port) + command, err := getProcfileCommand(appName, getProcessSpecificProcfilePath(appName), processType, port) if err != nil { return err } diff --git a/tests/unit/ps-general-1.bats b/tests/unit/ps-general-1.bats index 38bf0319398..a6fb02da129 100644 --- a/tests/unit/ps-general-1.bats +++ b/tests/unit/ps-general-1.bats @@ -98,16 +98,28 @@ teardown() { cat <"$DOKKU_LIB_ROOT/data/ps/$TEST_APP/Procfile" web: node web.js --port \$PORT worker: node worker.js +release: interpolated \$ENV_VAR EOF - PLUGIN_PATH=/var/lib/dokku/plugins PLUGIN_CORE_AVAILABLE_PATH=/var/lib/dokku/core-plugins/available DOKKU_LIB_ROOT=/var/lib/dokku run plugn trigger procfile-get-command "$TEST_APP" web 5001 + + run /bin/bash -c "dokku config:set '$TEST_APP' ENV_VAR=value" + echo "output: $output" + echo "status: $status" + assert_success + + run /bin/bash -c "dokku plugin:trigger procfile-get-command '$TEST_APP' web 5001" echo "output: $output" echo "status: $status" assert_output "node web.js --port 5001" - PLUGIN_PATH=/var/lib/dokku/plugins PLUGIN_CORE_AVAILABLE_PATH=/var/lib/dokku/core-plugins/available DOKKU_LIB_ROOT=/var/lib/dokku run plugn trigger procfile-get-command "$TEST_APP" worker + run /bin/bash -c "dokku plugin:trigger procfile-get-command '$TEST_APP' worker" echo "output: $output" echo "status: $status" assert_output "node worker.js" + + run /bin/bash -c "dokku plugin:trigger procfile-get-command '$TEST_APP' release 5001" + echo "output: $output" + echo "status: $status" + assert_output "interpolated value" } @test "(ps:scale) update formations from Procfile" {