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:
@@ -206,21 +206,3 @@ func ClearNetworkConfig(appName string) bool {
|
||||
}
|
||||
return success
|
||||
}
|
||||
|
||||
// ReportSingleApp is an internal function that displays the app report for one or more apps
|
||||
func ReportSingleApp(appName, infoFlag string) error {
|
||||
if err := common.VerifyAppName(appName); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
infoFlags := map[string]string{
|
||||
"--network-bind-all-interfaces": common.PropertyGet("network", appName, "bind-all-interfaces"),
|
||||
"--network-attach-post-create": common.PropertyGet("network", appName, "attach-post-create"),
|
||||
"--network-attach-post-deploy": common.PropertyGet("network", appName, "attach-post-deploy"),
|
||||
"--network-web-listeners": strings.Join(GetListeners(appName, "web"), " "),
|
||||
}
|
||||
|
||||
trimPrefix := false
|
||||
uppercaseFirstCharacter := true
|
||||
return common.ReportSingleApp("network", appName, infoFlag, infoFlags, trimPrefix, uppercaseFirstCharacter)
|
||||
}
|
||||
|
||||
42
plugins/network/report.go
Normal file
42
plugins/network/report.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package network
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/dokku/dokku/plugins/common"
|
||||
)
|
||||
|
||||
// ReportSingleApp is an internal function that displays the app report for one or more apps
|
||||
func ReportSingleApp(appName, infoFlag string) error {
|
||||
if err := common.VerifyAppName(appName); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
flags := map[string]common.ReportFunc{
|
||||
"--network-bind-all-interfaces": reportBindAllInterfaces,
|
||||
"--network-attach-post-create": reportAttachPostCreate,
|
||||
"--network-attach-post-deploy": reportAttachPostDeploy,
|
||||
"--network-web-listeners": reportWebListeners,
|
||||
}
|
||||
|
||||
trimPrefix := false
|
||||
uppercaseFirstCharacter := true
|
||||
infoFlags := common.CollectReport(appName, flags)
|
||||
return common.ReportSingleApp("network", appName, infoFlag, infoFlags, trimPrefix, uppercaseFirstCharacter)
|
||||
}
|
||||
|
||||
func reportBindAllInterfaces(appName string) string {
|
||||
return common.PropertyGet("network", appName, "bind-all-interfaces")
|
||||
}
|
||||
|
||||
func reportAttachPostCreate(appName string) string {
|
||||
return common.PropertyGet("network", appName, "attach-post-create")
|
||||
}
|
||||
|
||||
func reportAttachPostDeploy(appName string) string {
|
||||
return common.PropertyGet("network", appName, "attach-post-deploy")
|
||||
}
|
||||
|
||||
func reportWebListeners(appName string) string {
|
||||
return strings.Join(GetListeners(appName, "web"), " ")
|
||||
}
|
||||
Reference in New Issue
Block a user