feat: add cron maintenance info to cron:report output
This commit is contained in:
1 file changed
+25
@@ -1,7 +1,9 @@
|
|||||||
package cron
|
package cron
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/dokku/dokku/plugins/common"
|
"github.com/dokku/dokku/plugins/common"
|
||||||
)
|
)
|
||||||
@@ -21,6 +23,11 @@ func ReportSingleApp(appName string, format string, infoFlag string) error {
|
|||||||
"--cron-maintenance": reportMaintenance,
|
"--cron-maintenance": reportMaintenance,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extraFlags := addCronMaintenanceFlags(appName, infoFlag)
|
||||||
|
for flag, fn := range extraFlags {
|
||||||
|
flags[flag] = fn
|
||||||
|
}
|
||||||
|
|
||||||
flagKeys := []string{}
|
flagKeys := []string{}
|
||||||
for flagKey := range flags {
|
for flagKey := range flags {
|
||||||
flagKeys = append(flagKeys, flagKey)
|
flagKeys = append(flagKeys, flagKey)
|
||||||
@@ -32,6 +39,24 @@ func ReportSingleApp(appName string, format string, infoFlag string) error {
|
|||||||
return common.ReportSingleApp("cron", appName, infoFlag, infoFlags, flagKeys, format, trimPrefix, uppercaseFirstCharacter)
|
return common.ReportSingleApp("cron", appName, infoFlag, infoFlags, flagKeys, format, trimPrefix, uppercaseFirstCharacter)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func addCronMaintenanceFlags(appName string, infoFlag string) map[string]common.ReportFunc {
|
||||||
|
flags := map[string]common.ReportFunc{}
|
||||||
|
|
||||||
|
properties, err := common.PropertyGetAllByPrefix("cron", appName, MaintenancePropertyPrefix)
|
||||||
|
if err != nil {
|
||||||
|
return flags
|
||||||
|
}
|
||||||
|
|
||||||
|
for property, value := range properties {
|
||||||
|
key := strings.Replace(property, MaintenancePropertyPrefix, "", 1)
|
||||||
|
flags[fmt.Sprintf("--cron-maintenance-%s", key)] = func(appName string) string {
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return flags
|
||||||
|
}
|
||||||
|
|
||||||
func reportMailfrom(_ string) string {
|
func reportMailfrom(_ string) string {
|
||||||
return common.PropertyGet("cron", "--global", "mailfrom")
|
return common.PropertyGet("cron", "--global", "mailfrom")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user