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:
@@ -43,33 +43,6 @@ func IsAppProxyEnabled(appName string) bool {
|
||||
return proxyEnabled
|
||||
}
|
||||
|
||||
// ReportSingleApp is an internal function that displays the app report for one or more apps
|
||||
func ReportSingleApp(appName string, infoFlag string) error {
|
||||
if err := common.VerifyAppName(appName); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
proxyEnabled := "false"
|
||||
if IsAppProxyEnabled(appName) {
|
||||
proxyEnabled = "true"
|
||||
}
|
||||
|
||||
var proxyPortMap []string
|
||||
for _, portMap := range getProxyPortMap(appName) {
|
||||
proxyPortMap = append(proxyPortMap, portMap.String())
|
||||
}
|
||||
|
||||
infoFlags := map[string]string{
|
||||
"--proxy-enabled": proxyEnabled,
|
||||
"--proxy-type": getAppProxyType(appName),
|
||||
"--proxy-port-map": strings.Join(proxyPortMap, " "),
|
||||
}
|
||||
|
||||
trimPrefix := false
|
||||
uppercaseFirstCharacter := true
|
||||
return common.ReportSingleApp("proxy", appName, infoFlag, infoFlags, trimPrefix, uppercaseFirstCharacter)
|
||||
}
|
||||
|
||||
func addProxyPorts(appName string, proxyPortMap []PortMap) error {
|
||||
allPortMaps := getProxyPortMap(appName)
|
||||
allPortMaps = append(allPortMaps, proxyPortMap...)
|
||||
|
||||
47
plugins/proxy/report.go
Normal file
47
plugins/proxy/report.go
Normal file
@@ -0,0 +1,47 @@
|
||||
package proxy
|
||||
|
||||
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 string, infoFlag string) error {
|
||||
if err := common.VerifyAppName(appName); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
flags := map[string]common.ReportFunc{
|
||||
"--proxy-enabled": reportEnabled,
|
||||
"--proxy-type": reportType,
|
||||
"--proxy-port-map": reportPortMap,
|
||||
}
|
||||
|
||||
trimPrefix := false
|
||||
uppercaseFirstCharacter := true
|
||||
infoFlags := common.CollectReport(appName, flags)
|
||||
return common.ReportSingleApp("proxy", appName, infoFlag, infoFlags, trimPrefix, uppercaseFirstCharacter)
|
||||
}
|
||||
|
||||
func reportEnabled(appName string) string {
|
||||
proxyEnabled := "false"
|
||||
if IsAppProxyEnabled(appName) {
|
||||
proxyEnabled = "true"
|
||||
}
|
||||
|
||||
return proxyEnabled
|
||||
}
|
||||
|
||||
func reportType(appName string) string {
|
||||
return getAppProxyType(appName)
|
||||
}
|
||||
|
||||
func reportPortMap(appName string) string {
|
||||
var proxyPortMap []string
|
||||
for _, portMap := range getProxyPortMap(appName) {
|
||||
proxyPortMap = append(proxyPortMap, portMap.String())
|
||||
}
|
||||
|
||||
return strings.Join(proxyPortMap, " ")
|
||||
}
|
||||
Reference in New Issue
Block a user