Merge pull request #8059 from dokku/8050-release-expansion

Expand variables for release tasks
This commit is contained in:
Jose Diaz-Gonzalez
2025-10-27 01:55:25 -04:00
committed by GitHub
3 changed files with 38 additions and 5 deletions

View File

@@ -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)

View File

@@ -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
}

View File

@@ -98,16 +98,28 @@ teardown() {
cat <<EOF >"$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" {