Files
dokku/plugins/proxy/subcommands.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

104 lines
2.4 KiB
Go

package proxy
import (
"errors"
"strings"
"github.com/dokku/dokku/plugins/common"
)
// CommandBuildConfig rebuilds config for a given app
func CommandBuildConfig(appName string, allApps bool, parallelCount int) error {
if allApps {
return common.RunCommandAgainstAllApps(BuildConfig, "build-config", parallelCount)
}
if err := common.VerifyAppName(appName); err != nil {
return err
}
return BuildConfig(appName)
}
// CommandClearConfig clears config for a given app
func CommandClearConfig(appName string, allApps bool) error {
if allApps {
return ClearConfig("--all")
}
if err := common.VerifyAppName(appName); err != nil {
return err
}
return ClearConfig(appName)
}
// CommandDisable disables the proxy for app via command line
func CommandDisable(appName string, allApps bool, parallelCount int) error {
if allApps {
return common.RunCommandAgainstAllApps(Disable, "disable", parallelCount)
}
if err := common.VerifyAppName(appName); err != nil {
return err
}
return Disable(appName)
}
// CommandEnable enables the proxy for app via command line
func CommandEnable(appName string, allApps bool, parallelCount int) error {
if allApps {
return common.RunCommandAgainstAllApps(Enable, "enable", parallelCount)
}
if err := common.VerifyAppName(appName); err != nil {
return err
}
return Enable(appName)
}
// CommandReport displays a proxy report for one or more apps
func CommandReport(appName string, format string, infoFlag string) error {
if len(appName) == 0 {
apps, err := common.DokkuApps()
if err != nil {
if errors.Is(err, common.NoAppsExist) {
common.LogWarn(err.Error())
return nil
}
return err
}
for _, appName := range apps {
if err := ReportSingleApp(appName, format, infoFlag); err != nil {
return err
}
}
return nil
}
return ReportSingleApp(appName, format, infoFlag)
}
// CommandSet sets a proxy for an app
func CommandSet(appName string, proxyType string) error {
if appName != "--global" {
if err := common.VerifyAppName(appName); err != nil {
return err
}
}
if len(proxyType) < 2 {
return errors.New("Please specify a proxy type")
}
if strings.Contains(proxyType, ":") {
common.LogWarn("Detected potential port mapping instead of proxy type")
return errors.New("Consider using ports:set command or specifying a valid proxy")
}
common.CommandPropertySet("proxy", appName, "type", proxyType, DefaultProperties, GlobalProperties)
return nil
}