Skip to content

Commit

Permalink
Merge pull request #11 from ibuildthecloud/master
Browse files Browse the repository at this point in the history
Port over http_proxy changes from k3s
  • Loading branch information
ibuildthecloud authored May 9, 2019
2 parents 0d5ec6e + 4a853cb commit 669d56e
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion pkg/helm/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"crypto/sha256"
"encoding/hex"
"fmt"
"os"
"sort"

helmv1 "github.com/rancher/helm-controller/pkg/apis/k3s.cattle.io/v1"
Expand Down Expand Up @@ -197,7 +198,7 @@ func job(chart *helmv1.HelmChart) (*batch.Job, *core.ConfigMap) {
},
},
}

setProxyEnv(job)
configMap := configMap(chart)
if configMap == nil {
return job, nil
Expand Down Expand Up @@ -328,3 +329,29 @@ func keys(val map[string]intstr.IntOrString) []string {
sort.Strings(keys)
return keys
}

func setProxyEnv(job *batch.Job) {
proxySysEnv := []string{
"all_proxy",
"ALL_PROXY",
"http_proxy",
"HTTP_PROXY",
"https_proxy",
"HTTPS_PROXY",
"no_proxy",
"NO_PROXY",
}
for _, proxyEnv := range proxySysEnv {
proxyEnvValue := os.Getenv(proxyEnv)
if len(proxyEnvValue) == 0 {
continue
}
envar := core.EnvVar{
Name: proxyEnv,
Value: proxyEnvValue,
}
job.Spec.Template.Spec.Containers[0].Env = append(
job.Spec.Template.Spec.Containers[0].Env,
envar)
}
}

0 comments on commit 669d56e

Please sign in to comment.