mirror of
https://github.com/dokku/dokku.git
synced 2026-05-18 05:05:46 +02:00
feat: accept --global on :report subcommands
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.
This commit is contained in:
@@ -3,14 +3,21 @@ package storage
|
||||
import "github.com/dokku/dokku/plugins/common"
|
||||
|
||||
func ReportSingleApp(appName string, format string, infoFlag string) error {
|
||||
if err := common.VerifyAppName(appName); err != nil {
|
||||
return err
|
||||
if appName != "--global" {
|
||||
if err := common.VerifyAppName(appName); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
flags := map[string]common.ReportFunc{
|
||||
"--storage-build-mounts": reportBuildMounts,
|
||||
"--storage-deploy-mounts": reportDeployMounts,
|
||||
"--storage-run-mounts": reportRunMounts,
|
||||
var flags map[string]common.ReportFunc
|
||||
if appName == "--global" {
|
||||
flags = map[string]common.ReportFunc{}
|
||||
} else {
|
||||
flags = map[string]common.ReportFunc{
|
||||
"--storage-build-mounts": reportBuildMounts,
|
||||
"--storage-deploy-mounts": reportDeployMounts,
|
||||
"--storage-run-mounts": reportRunMounts,
|
||||
}
|
||||
}
|
||||
|
||||
flagKeys := []string{}
|
||||
|
||||
@@ -40,11 +40,14 @@ func main() {
|
||||
case "report":
|
||||
args := flag.NewFlagSet("storage:report", flag.ExitOnError)
|
||||
format := args.String("format", "stdout", "format: [ stdout | json ]")
|
||||
osArgs, infoFlag, flagErr := common.ParseReportArgs("storage", os.Args[2:])
|
||||
reportArgs, flagErr := common.ParseReportArgs("storage", os.Args[2:])
|
||||
if flagErr == nil {
|
||||
args.Parse(osArgs)
|
||||
args.Parse(reportArgs.OSArgs)
|
||||
appName := args.Arg(0)
|
||||
err = storage.CommandReport(appName, *format, infoFlag)
|
||||
if reportArgs.IsGlobal {
|
||||
appName = "--global"
|
||||
}
|
||||
err = storage.CommandReport(appName, *format, reportArgs.InfoFlag)
|
||||
}
|
||||
case "unmount":
|
||||
args := flag.NewFlagSet("storage:unmount", flag.ExitOnError)
|
||||
|
||||
Reference in New Issue
Block a user