feat: allow all network properties to be globally set

Global settings are cool if managed in a standard way (ugh env vars) so we'll add them back for golang plugins as necessary.
This commit is contained in:
Jose Diaz-Gonzalez
2021-03-22 17:13:54 -04:00
parent 84907be0cd
commit 8d26d06f5e
5 changed files with 210 additions and 41 deletions

View File

@@ -13,13 +13,22 @@ func ReportSingleApp(appName string, format string, infoFlag string) error {
}
flags := map[string]common.ReportFunc{
"--network-bind-all-interfaces": reportBindAllInterfaces,
"--network-attach-post-create": reportAttachPostCreate,
"--network-attach-post-deploy": reportAttachPostDeploy,
"--network-computed-initial-network": reportComputedInitialNetwork,
"--network-global-initial-network": reportGlobalInitialNetwork,
"--network-initial-network": reportInitialNetwork,
"--network-web-listeners": reportWebListeners,
"--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,
"--network-tld": reportTld,
"--network-web-listeners": reportWebListeners,
}
flagKeys := []string{}
@@ -33,10 +42,6 @@ func ReportSingleApp(appName string, format string, infoFlag string) error {
return common.ReportSingleApp("network", appName, infoFlag, infoFlags, flagKeys, format, 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")
}
@@ -45,6 +50,37 @@ func reportAttachPostDeploy(appName string) string {
return common.PropertyGet("network", appName, "attach-post-deploy")
}
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
}
func reportComputedInitialNetwork(appName string) string {
value := reportInitialNetwork(appName)
if value == "" {
@@ -54,14 +90,43 @@ func reportComputedInitialNetwork(appName string) string {
return value
}
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")
}
func reportGlobalInitialNetwork(appName string) string {
return common.PropertyGet("network", "--global", "initial-network")
}
func reportGlobalTld(appName string) string {
return common.PropertyGet("network", "--global", "tld")
}
func reportInitialNetwork(appName string) string {
return common.PropertyGet("network", appName, "initial-network")
}
func reportTld(appName string) string {
return common.PropertyGet("network", appName, "tld")
}
func reportWebListeners(appName string) string {
return strings.Join(GetListeners(appName, "web"), " ")
}