You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by as...@apache.org on 2022/01/12 13:53:51 UTC

[camel-k] 05/31: chore(maven): Convert NO_PROXY to http.nonProxyHosts JVM system property format

This is an automated email from the ASF dual-hosted git repository.

astefanutti pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit 59a87cf90fbbebb2b004d5ccdea5749bc7c6bd8e
Author: Antonin Stefanutti <an...@stefanutti.fr>
AuthorDate: Fri Jan 7 10:21:27 2022 +0100

    chore(maven): Convert NO_PROXY to http.nonProxyHosts JVM system property format
---
 pkg/util/maven/maven_proxies.go | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/pkg/util/maven/maven_proxies.go b/pkg/util/maven/maven_proxies.go
index 94091a8..aa57d4d 100644
--- a/pkg/util/maven/maven_proxies.go
+++ b/pkg/util/maven/maven_proxies.go
@@ -77,10 +77,14 @@ func parseProxyFromEnvVar(proxyEnvVar string) (Proxy, error) {
 		}
 	}
 	if noProxy := os.Getenv("NO_PROXY"); noProxy != "" {
-		nonProxyHosts := strings.ReplaceAll(noProxy, " ", "")
-		nonProxyHosts = strings.ReplaceAll(nonProxyHosts, ",", "|")
-		nonProxyHosts = strings.ReplaceAll(nonProxyHosts, "|.", "|*.")
-		proxy.NonProxyHosts = nonProxyHosts
+		// Convert to the format expected by the JVM http.nonProxyHosts system property
+		hosts := strings.Split(strings.ReplaceAll(noProxy, " ", ""), ",")
+		for i, host := range hosts {
+			if strings.HasPrefix(host, ".") {
+				hosts[i] = strings.Replace(host, ".", "*.", 1)
+			}
+		}
+		proxy.NonProxyHosts = strings.Join(hosts, "|")
 	}
 
 	return proxy, nil