Every Go-implemented plugin's `:report --format json` now emits keys without the redundant `<plugin>-` head segment, matching the shape bash plugins have always emitted. The CLI flag names and `:set` semantics are unchanged. For backwards compatibility during the 0.38.x patch series, the legacy `<plugin>-<property>` keys are emitted side-by-side with the new keys, and a future major release will drop the legacy keys. `common.ReportSingleApp` is refactored to accept a `ReportSingleAppInput` struct with a `Validate()` method so the input is checked before any work runs, which also catches the latent `"docker options"` reportType bug at the API boundary.
53 lines
1.4 KiB
Go
53 lines
1.4 KiB
Go
package storage
|
|
|
|
import "github.com/dokku/dokku/plugins/common"
|
|
|
|
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{
|
|
"--storage-build-mounts": reportBuildMounts,
|
|
"--storage-deploy-mounts": reportDeployMounts,
|
|
"--storage-run-mounts": reportRunMounts,
|
|
}
|
|
}
|
|
|
|
flagKeys := []string{}
|
|
for flagKey := range flags {
|
|
flagKeys = append(flagKeys, flagKey)
|
|
}
|
|
|
|
infoFlags := common.CollectReport(appName, infoFlag, flags)
|
|
return common.ReportSingleApp(common.ReportSingleAppInput{
|
|
ReportType: "storage",
|
|
AppName: appName,
|
|
InfoFlag: infoFlag,
|
|
InfoFlags: infoFlags,
|
|
InfoFlagKeys: flagKeys,
|
|
Format: format,
|
|
TrimPrefix: true,
|
|
UppercaseFirstCharacter: true,
|
|
EmitLegacyPrefix: true,
|
|
})
|
|
}
|
|
|
|
func reportBuildMounts(appName string) string {
|
|
return GetBindMountsForDisplay(appName, "build")
|
|
}
|
|
|
|
func reportDeployMounts(appName string) string {
|
|
return GetBindMountsForDisplay(appName, "deploy")
|
|
}
|
|
|
|
func reportRunMounts(appName string) string {
|
|
return GetBindMountsForDisplay(appName, "run")
|
|
}
|