fix: align ps/cron :report --global keys with plugin convention

The `ps` and `cron` plugins emitted `:report --format json` keys that
skipped the `<plugin>-` prefix or `-global-` infix used by every other
plugin, forcing external consumers to special-case those names. Rename
the affected report flags so they match the `<plugin>-global-<property>`
and `<plugin>-computed-<property>` convention introduced in 0.38.0, and
add the previously missing `computed-` siblings to both the per-app and
`--global` reports so the shape lines up with caddy, haproxy, and
traefik.
This commit is contained in:
Jose Diaz-Gonzalez
2026-05-25 13:37:56 -04:00
parent 99b949da4a
commit 3feedd8786
7 changed files with 143 additions and 38 deletions

View File

@@ -19,18 +19,23 @@ func ReportSingleApp(appName string, format string, infoFlag string) error {
var flags map[string]common.ReportFunc
if appName == "--global" {
flags = map[string]common.ReportFunc{
"--cron-mailfrom": reportMailfrom,
"--cron-mailto": reportMailto,
"--cron-global-maintenance": reportGlobalMaintenance,
"--cron-computed-mailfrom": reportComputedMailfrom,
"--cron-computed-mailto": reportComputedMailto,
"--cron-computed-maintenance": reportComputedMaintenance,
"--cron-global-mailfrom": reportGlobalMailfrom,
"--cron-global-mailto": reportGlobalMailto,
"--cron-global-maintenance": reportGlobalMaintenance,
}
} else {
flags = map[string]common.ReportFunc{
"--cron-mailfrom": reportMailfrom,
"--cron-mailto": reportMailto,
"--cron-task-count": reportTasks,
"--cron-global-maintenance": reportGlobalMaintenance,
"--cron-computed-mailfrom": reportComputedMailfrom,
"--cron-computed-mailto": reportComputedMailto,
"--cron-computed-maintenance": reportComputedMaintenance,
"--cron-global-mailfrom": reportGlobalMailfrom,
"--cron-global-mailto": reportGlobalMailto,
"--cron-global-maintenance": reportGlobalMaintenance,
"--cron-maintenance": reportMaintenance,
"--cron-task-count": reportTasks,
}
extraFlags := addCronMaintenanceFlags(appName, infoFlag)
@@ -68,14 +73,22 @@ func addCronMaintenanceFlags(appName string, infoFlag string) map[string]common.
return flags
}
func reportMailfrom(_ string) string {
func reportGlobalMailfrom(_ string) string {
return common.PropertyGet("cron", "--global", "mailfrom")
}
func reportMailto(_ string) string {
func reportGlobalMailto(_ string) string {
return common.PropertyGet("cron", "--global", "mailto")
}
func reportComputedMailfrom(_ string) string {
return common.PropertyGetDefault("cron", "--global", "mailfrom", DefaultProperties["mailfrom"])
}
func reportComputedMailto(_ string) string {
return common.PropertyGetDefault("cron", "--global", "mailto", DefaultProperties["mailto"])
}
func reportTasks(appName string) string {
c, _ := FetchCronTasks(FetchCronTasksInput{AppName: appName})
return strconv.Itoa(len(c))

View File

@@ -19,23 +19,25 @@ func ReportSingleApp(appName string, format string, infoFlag string) error {
var flags map[string]common.ReportFunc
if appName == "--global" {
flags = map[string]common.ReportFunc{
"--ps-global-procfile-path": reportGlobalProcfilePath,
"--global-stop-timeout-seconds": reportGlobalStopTimeoutSeconds,
"--ps-computed-procfile-path": reportComputedProcfilePath,
"--ps-computed-stop-timeout-seconds": reportComputedStopTimeoutSeconds,
"--ps-global-procfile-path": reportGlobalProcfilePath,
"--ps-global-stop-timeout-seconds": reportGlobalStopTimeoutSeconds,
}
} else {
flags = map[string]common.ReportFunc{
"--deployed": reportDeployed,
"--processes": reportProcesses,
"--ps-can-scale": reportCanScale,
"--ps-restart-policy": reportRestartPolicy,
"--ps-computed-procfile-path": reportComputedProcfilePath,
"--ps-global-procfile-path": reportGlobalProcfilePath,
"--ps-procfile-path": reportProcfilePath,
"--restore": reportRestore,
"--running": reportRunningState,
"--global-stop-timeout-seconds": reportGlobalStopTimeoutSeconds,
"--computed-stop-timeout-seconds": reportComputedStopTimeoutSeconds,
"--stop-timeout-seconds": reportStopTimeoutSeconds,
"--deployed": reportDeployed,
"--processes": reportProcesses,
"--ps-can-scale": reportCanScale,
"--ps-restart-policy": reportRestartPolicy,
"--ps-computed-procfile-path": reportComputedProcfilePath,
"--ps-global-procfile-path": reportGlobalProcfilePath,
"--ps-procfile-path": reportProcfilePath,
"--restore": reportRestore,
"--running": reportRunningState,
"--ps-global-stop-timeout-seconds": reportGlobalStopTimeoutSeconds,
"--ps-computed-stop-timeout-seconds": reportComputedStopTimeoutSeconds,
"--ps-stop-timeout-seconds": reportStopTimeoutSeconds,
}
extraFlags := addStatusFlags(appName, infoFlag)