refactor: only add status flags as necessary
This commit is contained in:
1 parent
0e320d2832
commit
0176e888af
1 file changed
+23
-6
+23
-6
@@ -23,8 +23,29 @@ func ReportSingleApp(appName, infoFlag string) error {
|
|||||||
"--running": reportRunningState,
|
"--running": reportRunningState,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extraFlags := addStatusFlags(appName, infoFlag)
|
||||||
|
for flag, fn := range extraFlags {
|
||||||
|
flags[flag] = fn
|
||||||
|
}
|
||||||
|
|
||||||
|
trimPrefix := false
|
||||||
|
uppercaseFirstCharacter := true
|
||||||
|
infoFlags := common.CollectReport(appName, infoFlag, flags)
|
||||||
|
return common.ReportSingleApp("ps", appName, infoFlag, infoFlags, trimPrefix, uppercaseFirstCharacter)
|
||||||
|
}
|
||||||
|
|
||||||
|
func addStatusFlags(appName string, infoFlag string) map[string]common.ReportFunc {
|
||||||
|
flags := map[string]common.ReportFunc{}
|
||||||
|
|
||||||
|
if infoFlag != "" && !strings.HasPrefix(infoFlag, "--status-") {
|
||||||
|
return flags
|
||||||
|
}
|
||||||
|
|
||||||
scheduler := common.GetAppScheduler(appName)
|
scheduler := common.GetAppScheduler(appName)
|
||||||
if scheduler == "docker-local" {
|
if scheduler != "docker-local" {
|
||||||
|
return flags
|
||||||
|
}
|
||||||
|
|
||||||
containerFiles := common.ListFilesWithPrefix(common.AppRoot(appName), "CONTAINER.")
|
containerFiles := common.ListFilesWithPrefix(common.AppRoot(appName), "CONTAINER.")
|
||||||
for _, filename := range containerFiles {
|
for _, filename := range containerFiles {
|
||||||
// See https://github.com/golang/go/wiki/CommonMistakes#using-goroutines-on-loop-iterator-variables
|
// See https://github.com/golang/go/wiki/CommonMistakes#using-goroutines-on-loop-iterator-variables
|
||||||
@@ -42,12 +63,8 @@ func ReportSingleApp(appName, infoFlag string) error {
|
|||||||
return fmt.Sprintf("%s (CID: %s)", containerStatus, containerID[0:11])
|
return fmt.Sprintf("%s (CID: %s)", containerStatus, containerID[0:11])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
trimPrefix := false
|
return flags
|
||||||
uppercaseFirstCharacter := true
|
|
||||||
infoFlags := common.CollectReport(appName, infoFlag, flags)
|
|
||||||
return common.ReportSingleApp("ps", appName, infoFlag, infoFlags, trimPrefix, uppercaseFirstCharacter)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func reportCanScale(appName string) string {
|
func reportCanScale(appName string) string {
|
||||||
|
|||||||
Reference in new issue
Block a user