mirror of
https://github.com/dokku/dokku.git
synced 2026-02-23 19:50:34 +01:00
feat: short-circuit report fetching if only retrieving a single value
This speeds up report output when specifying a flag as extra data that isn't used will not be fetched unnecessarily.
This commit is contained in:
@@ -20,7 +20,7 @@ func ReportSingleApp(appName, infoFlag string) error {
|
||||
|
||||
trimPrefix := false
|
||||
uppercaseFirstCharacter := true
|
||||
infoFlags := common.CollectReport(appName, flags)
|
||||
infoFlags := common.CollectReport(appName, infoFlag, flags)
|
||||
return common.ReportSingleApp("app", appName, infoFlag, infoFlags, trimPrefix, uppercaseFirstCharacter)
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ func ReportSingleApp(appName, infoFlag string) error {
|
||||
|
||||
trimPrefix := false
|
||||
uppercaseFirstCharacter := true
|
||||
infoFlags := common.CollectReport(appName, flags)
|
||||
infoFlags := common.CollectReport(appName, infoFlag, flags)
|
||||
return common.ReportSingleApp("buildpacks", appName, infoFlag, infoFlags, trimPrefix, uppercaseFirstCharacter)
|
||||
}
|
||||
|
||||
|
||||
@@ -139,10 +139,14 @@ type ReportFunc func(string) string
|
||||
|
||||
// CollectReport iterates over a set of report functions
|
||||
// to collect the :report output in parallel
|
||||
func CollectReport(appName string, flags map[string]ReportFunc) map[string]string {
|
||||
func CollectReport(appName string, infoFlag string, flags map[string]ReportFunc) map[string]string {
|
||||
var sm sync.Map
|
||||
var wg sync.WaitGroup
|
||||
for flag, fn := range flags {
|
||||
if infoFlag != "" && infoFlag != flag {
|
||||
continue
|
||||
}
|
||||
|
||||
wg.Add(1)
|
||||
go func(flag string, fn ReportFunc) {
|
||||
defer wg.Done()
|
||||
|
||||
@@ -21,7 +21,7 @@ func ReportSingleApp(appName, infoFlag string) error {
|
||||
|
||||
trimPrefix := false
|
||||
uppercaseFirstCharacter := true
|
||||
infoFlags := common.CollectReport(appName, flags)
|
||||
infoFlags := common.CollectReport(appName, infoFlag, flags)
|
||||
return common.ReportSingleApp("network", appName, infoFlag, infoFlags, trimPrefix, uppercaseFirstCharacter)
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ func ReportSingleApp(appName string, infoFlag string) error {
|
||||
|
||||
trimPrefix := false
|
||||
uppercaseFirstCharacter := true
|
||||
infoFlags := common.CollectReport(appName, flags)
|
||||
infoFlags := common.CollectReport(appName, infoFlag, flags)
|
||||
return common.ReportSingleApp("proxy", appName, infoFlag, infoFlags, trimPrefix, uppercaseFirstCharacter)
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ func ReportSingleApp(appName, infoFlag string) error {
|
||||
|
||||
trimPrefix := false
|
||||
uppercaseFirstCharacter := true
|
||||
infoFlags := common.CollectReport(appName, flags)
|
||||
infoFlags := common.CollectReport(appName, infoFlag, flags)
|
||||
return common.ReportSingleApp("ps", appName, infoFlag, infoFlags, trimPrefix, uppercaseFirstCharacter)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user