The `<plugin>-global-<property>` keys in `:report` output returned the resolved value with the built-in default substituted in, so external tooling could not distinguish a property that had been set globally to the default from one that had never been set. The bare keys for caddy, haproxy, and traefik global-only properties had the same shape. The `global-<property>` keys now hold the raw stored value and are empty when nothing has been set, and a new `computed-<property>` key holds the effective value used at runtime, falling back through the per-app value (where one exists), the global value, and the built-in default. The bare global-only keys for the three proxy plugins are removed in favor of the raw/computed pair. Closes #8631.
61 lines
1.5 KiB
Go
61 lines
1.5 KiB
Go
package proxy
|
|
|
|
import (
|
|
"github.com/dokku/dokku/plugins/common"
|
|
)
|
|
|
|
// ReportSingleApp is an internal function that displays the proxy report for one or more apps
|
|
func ReportSingleApp(appName string, format string, infoFlag string) error {
|
|
if appName != "--global" {
|
|
if err := common.VerifyAppName(appName); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
|
|
var flags map[string]common.ReportFunc
|
|
if appName == "--global" {
|
|
flags = map[string]common.ReportFunc{
|
|
"--proxy-computed-type": reportComputedType,
|
|
"--proxy-global-type": reportGlobalType,
|
|
}
|
|
} else {
|
|
flags = map[string]common.ReportFunc{
|
|
"--proxy-enabled": reportEnabled,
|
|
"--proxy-computed-type": reportComputedType,
|
|
"--proxy-global-type": reportGlobalType,
|
|
"--proxy-type": reportType,
|
|
}
|
|
}
|
|
|
|
flagKeys := []string{}
|
|
for flagKey := range flags {
|
|
flagKeys = append(flagKeys, flagKey)
|
|
}
|
|
|
|
trimPrefix := false
|
|
uppercaseFirstCharacter := true
|
|
infoFlags := common.CollectReport(appName, infoFlag, flags)
|
|
return common.ReportSingleApp("proxy", appName, infoFlag, infoFlags, flagKeys, format, trimPrefix, uppercaseFirstCharacter)
|
|
}
|
|
|
|
func reportEnabled(appName string) string {
|
|
proxyEnabled := "false"
|
|
if IsAppProxyEnabled(appName) {
|
|
proxyEnabled = "true"
|
|
}
|
|
|
|
return proxyEnabled
|
|
}
|
|
|
|
func reportComputedType(appName string) string {
|
|
return getComputedProxyType(appName)
|
|
}
|
|
|
|
func reportGlobalType(appName string) string {
|
|
return getGlobalProxyType()
|
|
}
|
|
|
|
func reportType(appName string) string {
|
|
return getAppProxyType(appName)
|
|
}
|