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

Expand variables for release tasks
This commit is contained in:
Jose Diaz-Gonzalez authored and GitHub committed 2025-10-27 01:55:25 -04:00
commit 528746cf6c
3 files changed
+38 -5

No files matched your search

+23 -2
View File
@@ -18,14 +18,35 @@ func canScaleApp(appName string) bool {
return common.ToBool(canScale) 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) { if !common.FileExists(procfilePath) {
return "", errors.New("No procfile found") 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{ result, err := common.CallExecCommand(common.ExecCommandInput{
Command: "procfile-util", 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 { if err != nil {
return "", fmt.Errorf("Error running procfile-util: %s", err) return "", fmt.Errorf("Error running procfile-util: %s", err)
+1 -1
View File
@@ -274,7 +274,7 @@ func TriggerProcfileGetCommand(appName string, processType string, port int) err
return nil return nil
} }
command, err := getProcfileCommand(getProcessSpecificProcfilePath(appName), processType, port) command, err := getProcfileCommand(appName, getProcessSpecificProcfilePath(appName), processType, port)
if err != nil { if err != nil {
return err return err
} }
+14 -2
View File
@@ -98,16 +98,28 @@ teardown() {
cat <<EOF >"$DOKKU_LIB_ROOT/data/ps/$TEST_APP/Procfile" cat <<EOF >"$DOKKU_LIB_ROOT/data/ps/$TEST_APP/Procfile"
web: node web.js --port \$PORT web: node web.js --port \$PORT
worker: node worker.js worker: node worker.js
release: interpolated \$ENV_VAR
EOF 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 "output: $output"
echo "status: $status" echo "status: $status"
assert_output "node web.js --port 5001" 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 "output: $output"
echo "status: $status" echo "status: $status"
assert_output "node worker.js" 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" { @test "(ps:scale) update formations from Procfile" {