mirror of
https://github.com/dokku/dokku.git
synced 2026-09-03 04:32:26 +02:00
Every `:report` subcommand now recognizes `--global` as a scope selector that limits the report to globally-configured properties, including in JSON form via `--global --format json`. Previously this combination was rejected because `--global` was treated as an info flag, conflicting with `--format`. The shared `common.ParseReportArgs` helper now returns a `ReportArgs` struct exposing the parsed scope; each Go and bash report selects a global-only flag map when scope is global, and skips per-app verification.
74 lines
2.1 KiB
Go
74 lines
2.1 KiB
Go
package dockeroptions
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
|
|
"github.com/dokku/dokku/plugins/common"
|
|
)
|
|
|
|
// ReportSingleApp displays the docker options report for a single app.
|
|
// Default-scope options are reported under fixed keys for each phase.
|
|
// Process-scoped options surface as dynamic per-process keys, one per
|
|
// configured process+phase combination.
|
|
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{}
|
|
} else {
|
|
flags = map[string]common.ReportFunc{
|
|
"--docker-options-build": reportBuildOptions,
|
|
"--docker-options-deploy": reportDeployOptions,
|
|
"--docker-options-run": reportRunOptions,
|
|
}
|
|
}
|
|
|
|
processTypes, err := ListProcessTypesWithOptions(appName)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
for _, processType := range processTypes {
|
|
processType := processType
|
|
flagName := fmt.Sprintf("--docker-options-deploy.%s", processType)
|
|
flags[flagName] = func(app string) string {
|
|
return joinProcessPhaseOptions(app, processType, "deploy")
|
|
}
|
|
}
|
|
|
|
flagKeys := []string{}
|
|
for flagKey := range flags {
|
|
flagKeys = append(flagKeys, flagKey)
|
|
}
|
|
|
|
trimPrefix := false
|
|
uppercaseFirstCharacter := true
|
|
infoFlags := common.CollectReport(appName, infoFlag, flags)
|
|
return common.ReportSingleApp("docker options", appName, infoFlag, infoFlags, flagKeys, format, trimPrefix, uppercaseFirstCharacter)
|
|
}
|
|
|
|
func reportBuildOptions(appName string) string {
|
|
return joinProcessPhaseOptions(appName, DefaultProcessType, "build")
|
|
}
|
|
|
|
func reportDeployOptions(appName string) string {
|
|
return joinProcessPhaseOptions(appName, DefaultProcessType, "deploy")
|
|
}
|
|
|
|
func reportRunOptions(appName string) string {
|
|
return joinProcessPhaseOptions(appName, DefaultProcessType, "run")
|
|
}
|
|
|
|
func joinProcessPhaseOptions(appName, processType, phase string) string {
|
|
options, err := GetDockerOptionsForProcessPhase(appName, processType, phase)
|
|
if err != nil || len(options) == 0 {
|
|
return ""
|
|
}
|
|
return strings.Join(options, " ")
|
|
}
|