2020-12-29 23:56:10 -05:00
|
|
|
package network
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
|
|
"github.com/dokku/dokku/plugins/common"
|
|
|
|
|
)
|
|
|
|
|
|
2021-01-20 14:49:32 -05:00
|
|
|
// ReportSingleApp is an internal function that displays the network report for one or more apps
|
2021-02-01 22:23:05 -05:00
|
|
|
func ReportSingleApp(appName string, format string, infoFlag string) error {
|
2020-12-29 23:56:10 -05:00
|
|
|
if err := common.VerifyAppName(appName); err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
flags := map[string]common.ReportFunc{
|
2021-03-22 17:13:54 -04:00
|
|
|
"--network-bind-all-interfaces": reportBindAllInterfaces,
|
|
|
|
|
"--network-attach-post-create": reportAttachPostCreate,
|
|
|
|
|
"--network-attach-post-deploy": reportAttachPostDeploy,
|
|
|
|
|
"--network-computed-attach-post-create": reportComputedAttachPostCreate,
|
|
|
|
|
"--network-computed-attach-post-deploy": reportComputedAttachPostDeploy,
|
|
|
|
|
"--network-computed-bind-all-interfaces": reportComputedBindAllInterfaces,
|
|
|
|
|
"--network-computed-initial-network": reportComputedInitialNetwork,
|
|
|
|
|
"--network-computed-tld": reportComputedTld,
|
|
|
|
|
"--network-global-attach-post-create": reportGlobalAttachPostCreate,
|
|
|
|
|
"--network-global-attach-post-deploy": reportGlobalAttachPostDeploy,
|
|
|
|
|
"--network-global-bind-all-interfaces": reportGlobalBindAllInterfaces,
|
|
|
|
|
"--network-global-initial-network": reportGlobalInitialNetwork,
|
|
|
|
|
"--network-global-tld": reportGlobalTld,
|
|
|
|
|
"--network-initial-network": reportInitialNetwork,
|
2021-08-06 01:29:25 -04:00
|
|
|
"--network-static-web-listener": reportStaticWebListener,
|
2021-03-22 17:13:54 -04:00
|
|
|
"--network-tld": reportTld,
|
|
|
|
|
"--network-web-listeners": reportWebListeners,
|
2020-12-29 23:56:10 -05:00
|
|
|
}
|
|
|
|
|
|
2021-01-07 01:34:05 -05:00
|
|
|
flagKeys := []string{}
|
|
|
|
|
for flagKey := range flags {
|
|
|
|
|
flagKeys = append(flagKeys, flagKey)
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-29 23:56:10 -05:00
|
|
|
trimPrefix := false
|
|
|
|
|
uppercaseFirstCharacter := true
|
2020-12-30 00:37:43 -05:00
|
|
|
infoFlags := common.CollectReport(appName, infoFlag, flags)
|
2021-02-01 22:23:05 -05:00
|
|
|
return common.ReportSingleApp("network", appName, infoFlag, infoFlags, flagKeys, format, trimPrefix, uppercaseFirstCharacter)
|
2020-12-29 23:56:10 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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")
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-22 17:13:54 -04:00
|
|
|
func reportBindAllInterfaces(appName string) string {
|
|
|
|
|
return common.PropertyGet("network", appName, "bind-all-interfaces")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func reportComputedAttachPostCreate(appName string) string {
|
|
|
|
|
value := reportAttachPostCreate(appName)
|
|
|
|
|
if value == "" {
|
|
|
|
|
value = reportGlobalAttachPostCreate(appName)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return value
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func reportComputedAttachPostDeploy(appName string) string {
|
|
|
|
|
value := reportAttachPostDeploy(appName)
|
|
|
|
|
if value == "" {
|
|
|
|
|
value = reportGlobalAttachPostDeploy(appName)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return value
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func reportComputedBindAllInterfaces(appName string) string {
|
|
|
|
|
value := reportBindAllInterfaces(appName)
|
|
|
|
|
if value == "" {
|
|
|
|
|
value = reportGlobalBindAllInterfaces(appName)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return value
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-22 01:05:35 -04:00
|
|
|
func reportComputedInitialNetwork(appName string) string {
|
|
|
|
|
value := reportInitialNetwork(appName)
|
|
|
|
|
if value == "" {
|
|
|
|
|
value = reportGlobalInitialNetwork(appName)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return value
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-22 17:13:54 -04:00
|
|
|
func reportComputedTld(appName string) string {
|
|
|
|
|
value := reportTld(appName)
|
|
|
|
|
if value == "" {
|
|
|
|
|
value = reportGlobalTld(appName)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return value
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func reportGlobalAttachPostCreate(appName string) string {
|
|
|
|
|
return common.PropertyGet("network", "--global", "attach-post-create")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func reportGlobalAttachPostDeploy(appName string) string {
|
|
|
|
|
return common.PropertyGet("network", "--global", "attach-post-deploy")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func reportGlobalBindAllInterfaces(appName string) string {
|
|
|
|
|
return common.PropertyGetDefault("network", "--global", "bind-all-interfaces", "false")
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-22 01:05:35 -04:00
|
|
|
func reportGlobalInitialNetwork(appName string) string {
|
|
|
|
|
return common.PropertyGet("network", "--global", "initial-network")
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-22 17:13:54 -04:00
|
|
|
func reportGlobalTld(appName string) string {
|
|
|
|
|
return common.PropertyGet("network", "--global", "tld")
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-22 01:05:35 -04:00
|
|
|
func reportInitialNetwork(appName string) string {
|
|
|
|
|
return common.PropertyGet("network", appName, "initial-network")
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-06 01:29:25 -04:00
|
|
|
func reportStaticWebListener(appName string) string {
|
|
|
|
|
return common.PropertyGet("network", appName, "static-web-listener")
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-22 17:13:54 -04:00
|
|
|
func reportTld(appName string) string {
|
|
|
|
|
return common.PropertyGet("network", appName, "tld")
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-29 23:56:10 -05:00
|
|
|
func reportWebListeners(appName string) string {
|
|
|
|
|
return strings.Join(GetListeners(appName, "web"), " ")
|
|
|
|
|
}
|