squakez commented on a change in pull request #2858:
URL: https://github.com/apache/camel-k/pull/2858#discussion_r782961649
##########
File path: pkg/trait/jvm.go
##########
@@ -169,6 +171,59 @@ func (t *jvmTrait) Apply(e *Environment) error {
args = append(args, t.Options...)
}
+ // Translate HTTP proxy environment variables, that are set by the
environment trait,
+ // into corresponding JVM system properties.
+ if HTTPProxy := envvar.Get(container.Env, "HTTP_PROXY"); HTTPProxy !=
nil {
+ u, err := url.Parse(HTTPProxy.Value)
+ if err != nil {
+ return err
+ }
+ if !util.StringSliceContainsAnyOf(t.Options, "http.proxyHost") {
+ args = append(args, fmt.Sprintf("-Dhttp.proxyHost=%q",
u.Hostname()))
+ }
+ if port := u.Port(); !util.StringSliceContainsAnyOf(t.Options,
"http.proxyPort") && port != "" {
+ args = append(args, fmt.Sprintf("-Dhttp.proxyPort=%q",
u.Port()))
+ }
+ if user := u.User; !util.StringSliceContainsAnyOf(t.Options,
"http.proxyUser") && user != nil {
+ args = append(args, fmt.Sprintf("-Dhttp.proxyUser=%q",
user.Username()))
+ if password, ok := user.Password();
!util.StringSliceContainsAnyOf(t.Options, "http.proxyUser") && ok {
+ args = append(args,
fmt.Sprintf("-Dhttp.proxyPassword=%q", password))
+ }
+ }
+ }
+
+ if HTTPSProxy := envvar.Get(container.Env, "HTTPS_PROXY"); HTTPSProxy
!= nil {
Review comment:
Nit: considering that it's the same behavior for HTTP, we may try to
create a function, so, any maintenance would be simpler
##########
File path: resources/traits.yaml
##########
@@ -810,22 +815,28 @@ traits:
- Knative
- OpenShift
description: 'The Mount trait can be used to configure volumes mounted on
the Integration
- Pod. nolint: tagliatelle'
+ Pods. nolint: tagliatelle'
Review comment:
Fixed in #2851 - if you rebase, you should have it fixed when
regenerating the documentation
##########
File path: pkg/util/maven/maven_proxies.go
##########
@@ -0,0 +1,89 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package maven
+
+import (
+ "net/url"
+ "os"
+ "strings"
+)
+
+var ProxyFromEnvironment = proxyFromEnvironment{}
+
+type proxyFromEnvironment struct{}
+
+func (proxyFromEnvironment) apply(settings *Settings) error {
+ if httpProxy := os.Getenv("HTTP_PROXY"); httpProxy != "" {
+ proxy, err := parseProxyFromEnvVar(httpProxy)
+ if err != nil {
+ return err
+ }
+ proxy.ID = "http-proxy"
+ settings.Proxies = append(settings.Proxies, proxy)
+ }
+
+ if httpsProxy := os.Getenv("HTTPS_PROXY"); httpsProxy != "" {
Review comment:
Nit: duplicated code could benefit a refactoring into a function
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]