Files
dokku/plugins/proxy/proxy.go
Jose Diaz-Gonzalez 915172c0c5 fix: move proxy-port properties to proxy plugin and fix CI failures
- Move proxy-port and proxy-ssl-port properties from ports plugin to
  proxy plugin where they conceptually belong
- Generalize proxy:set to handle any property (matching ps:set pattern)
  instead of only handling the type property
- Fix apps:set --global flag parsing (pflag treats --global as a flag,
  not an argument — must be defined explicitly like ps:set does)
- Add missing property-functions source to scheduler-docker-local
  shell scripts (scheduler-enter, scheduler-run, scheduler-deploy,
  check-deploy, bin/scheduler-deploy-process-container)
- Update nginx-vhosts property references from ports to proxy plugin
- Update tests to use proxy:set for proxy-port properties
2026-04-25 17:19:42 -04:00

92 lines
2.4 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",
"proxy-port": "",
"proxy-ssl-port": "",
"type": "",
}
// GlobalProperties is a map of all valid global proxy properties
GlobalProperties = map[string]bool{
"proxy-port": true,
"proxy-ssl-port": true,
"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"
}