diff --git a/plugins/proxy/proxy.go b/plugins/proxy/proxy.go index 477e4be9d..8e08d8255 100644 --- a/plugins/proxy/proxy.go +++ b/plugins/proxy/proxy.go @@ -100,7 +100,8 @@ func getAppProxyType(appName string) string { func getProxyPortMap(appName string) []PortMap { value := config.GetWithDefault(appName, "DOKKU_PROXY_PORT_MAP", "") - return parseProxyPortMapString(value) + warn := false + return parseProxyPortMapString(value, warn) } func listAppProxyPorts(appName string) error { @@ -165,24 +166,30 @@ func removeProxyPorts(appName string, proxyPortMap []PortMap) error { return setProxyPorts(appName, toSet) } -func parseProxyPortMapString(stringPortMap string) []PortMap { +func parseProxyPortMapString(stringPortMap string, warn bool) []PortMap { var proxyPortMap []PortMap for _, v := range strings.Split(strings.TrimSpace(stringPortMap), " ") { parts := strings.SplitN(v, ":", 3) if len(parts) != 3 { - common.LogWarn(fmt.Sprintf("Invalid port map %s", v)) + if warn { + common.LogWarn(fmt.Sprintf("Invalid port map %s", v)) + } continue } hostPort, err := strconv.Atoi(parts[1]) if err != nil { - common.LogWarn(fmt.Sprintf("Invalid port map %s", v)) + if warn { + common.LogWarn(fmt.Sprintf("Invalid port map %s", v)) + } } containerPort, err := strconv.Atoi(parts[2]) if err != nil { - common.LogWarn(fmt.Sprintf("Invalid port map %s", v)) + if warn { + common.LogWarn(fmt.Sprintf("Invalid port map %s", v)) + } } proxyPortMap = append(proxyPortMap, PortMap{ diff --git a/plugins/proxy/subcommands.go b/plugins/proxy/subcommands.go index bcddd4e41..86f106dc3 100644 --- a/plugins/proxy/subcommands.go +++ b/plugins/proxy/subcommands.go @@ -85,7 +85,8 @@ func CommandPortsAdd(args []string) error { } stringPortMap := strings.Join(args[1:], " ") - proxyPortMap := parseProxyPortMapString(stringPortMap) + warn := true + proxyPortMap := parseProxyPortMapString(stringPortMap, warn) if err := addProxyPorts(appName, proxyPortMap); err != nil { return err } @@ -121,7 +122,8 @@ func CommandPortsRemove(args []string) error { } stringPortMap := strings.Join(args[1:], " ") - proxyPortMap := parseProxyPortMapString(stringPortMap) + warn := true + proxyPortMap := parseProxyPortMapString(stringPortMap, warn) if err := removeProxyPorts(appName, proxyPortMap); err != nil { return err } @@ -141,7 +143,8 @@ func CommandPortsSet(args []string) error { } stringPortMap := strings.Join(args[1:], " ") - proxyPortMap := parseProxyPortMapString(stringPortMap) + warn := true + proxyPortMap := parseProxyPortMapString(stringPortMap, warn) if err := setProxyPorts(appName, proxyPortMap); err != nil { return err }