refactor: parallelize report commands

This will make reports a bit faster to run, and is safe to do as reports should not change app state.
This commit is contained in:
Jose Diaz-Gonzalez
2020-12-29 23:56:10 -05:00
parent 44461e21df
commit 28c9f42a25
9 changed files with 237 additions and 120 deletions

View File

@@ -12,23 +12,36 @@ func ReportSingleApp(appName, infoFlag string) error {
return err
}
flags := map[string]common.ReportFunc{
"--app-dir": reportDir,
"--app-deploy-source": reportDeploySource,
"--app-locked": reportLocked,
}
trimPrefix := false
uppercaseFirstCharacter := true
infoFlags := common.CollectReport(appName, flags)
return common.ReportSingleApp("app", appName, infoFlag, infoFlags, trimPrefix, uppercaseFirstCharacter)
}
func reportDir(appName string) string {
return common.AppRoot(appName)
}
func reportDeploySource(appName string) string {
deploySource := ""
if b, err := common.PlugnTriggerSetup("deploy-source", []string{appName}...).SetInput("").Output(); err != nil {
deploySource = strings.TrimSpace(string(b[:]))
}
return deploySource
}
func reportLocked(appName string) string {
locked := "false"
if appIsLocked(appName) {
locked = "true"
}
infoFlags := map[string]string{
"--app-dir": common.AppRoot(appName),
"--app-deploy-source": deploySource,
"--app-locked": locked,
}
trimPrefix := false
uppercaseFirstCharacter := true
return common.ReportSingleApp("app", appName, infoFlag, infoFlags, trimPrefix, uppercaseFirstCharacter)
return locked
}