Files
dokku/plugins/proxy/proxy.go
Jose Diaz-Gonzalez 1308e21947 feat: migrate environment variables to plugin properties
Standardize how environment variables are migrated to properties during
install triggers and migrate all remaining DOKKU_* config vars to their
appropriate plugin properties.

Adds a reusable MigrateConfigToProperties() function in the common
package with Transform callback and ListProperty support, plus a
migrate-config-to-property subcommand for the prop binary so shell
plugins can use the same code path.

Migrated variables and their new property owners:
- DOKKU_APP_PROXY_TYPE/DOKKU_PROXY_TYPE → proxy type
- DOKKU_DISABLE_PROXY → proxy disabled
- DOKKU_PROXY_PORT → ports proxy-port
- DOKKU_PROXY_SSL_PORT → ports proxy-ssl-port
- DOKKU_APP_RESTORE → ps restore
- DOKKU_SKIP_DEPLOY → ps skip-deploy
- DOKKU_START_CMD → ps start-cmd
- DOKKU_DOCKERFILE_START_CMD → ps dockerfile-start-cmd
- DOKKU_DISABLE_APP_AUTOCREATION → apps disable-autocreation
- DOKKU_APP_SHELL → scheduler shell
- DOKKU_SKIP_CLEANUP → builder skip-cleanup
- DOKKU_CHECKS_DISABLED → checks disabled
- DOKKU_CHECKS_SKIPPED → checks skipped
- DOKKU_CHECKS_WAIT → checks wait
- DOKKU_CHECKS_TIMEOUT → checks timeout
- DOKKU_CHECKS_ATTEMPTS → checks attempts
- DOKKU_DEFAULT_CHECKS_WAIT → checks default-wait
- DOKKU_SKIP_ALL_CHECKS → checks disabled (legacy)
- DOKKU_SKIP_DEFAULT_CHECKS → checks skipped (legacy)

Also refactors existing bespoke migration loops in scheduler, ports, ps,
builder, and nginx-vhosts plugins to use the standardized utility.

Removes DOKKU_PARALLEL_ARGUMENTS from documentation (unused in core).
Deprecates fn-migrate-config-to-property bash function.

closes #1558
2026-04-25 05:11:07 -04:00

88 lines
2.3 KiB
Go

package proxy
import (
"github.com/dokku/dokku/plugins/common"
)
// RunInSerial is the default value for whether to run a command in parallel or not
// and defaults to -1 (false)
const RunInSerial = 0
var (
// DefaultProperties is a map of all valid proxy properties with corresponding default property values
DefaultProperties = map[string]string{
"disabled": "false",
"type": "",
}
// GlobalProperties is a map of all valid global proxy properties
GlobalProperties = map[string]bool{
"type": true,
}
)
// BuildConfig rebuilds the proxy config for the specified app
func BuildConfig(appName string) error {
_, err := common.CallPlugnTrigger(common.PlugnTriggerInput{
Trigger: "proxy-build-config",
Args: []string{appName},
StreamStdio: true,
})
return err
}
// ClearConfig clears the proxy config for the specified app
func ClearConfig(appName string) error {
_, err := common.CallPlugnTrigger(common.PlugnTriggerInput{
Trigger: "proxy-clear-config",
Args: []string{appName},
StreamStdio: true,
})
return err
}
// Disable disables proxy implementations for the specified app
func Disable(appName string) error {
if !IsAppProxyEnabled(appName) {
common.LogInfo1("Proxy is already disable for app")
return nil
}
common.LogInfo1("Disabling proxy for app")
if err := common.PropertyWrite("proxy", appName, "disabled", "true"); err != nil {
return err
}
_, err := common.CallPlugnTrigger(common.PlugnTriggerInput{
Trigger: "proxy-disable",
Args: []string{appName},
StreamStdio: true,
})
return err
}
// Enable enables proxy implementations for the specified app
func Enable(appName string) error {
if IsAppProxyEnabled(appName) {
common.LogInfo1("Proxy is already enabled for app")
return nil
}
common.LogInfo1("Enabling proxy for app")
if err := common.PropertyDelete("proxy", appName, "disabled"); err != nil {
return err
}
_, err := common.CallPlugnTrigger(common.PlugnTriggerInput{
Trigger: "proxy-enable",
Args: []string{appName},
StreamStdio: true,
})
return err
}
// IsAppProxyEnabled returns true if proxy is enabled; otherwise return false
func IsAppProxyEnabled(appName string) bool {
return common.PropertyGetDefault("proxy", appName, "disabled", "false") != "true"
}