github.com/operator-framework/operator-lifecycle-manager@v0.30.0/pkg/lib/proxy/envvar.go (about) 1 package proxy 2 3 import ( 4 apiconfigv1 "github.com/openshift/api/config/v1" 5 corev1 "k8s.io/api/core/v1" 6 ) 7 8 const ( 9 // HTTP_PROXY is the URL of the proxy for HTTP requests. 10 // Empty means unset and will not result in an env var. 11 envHTTPProxyName = "HTTP_PROXY" 12 13 // HTTPS_PROXY is the URL of the proxy for HTTPS requests. 14 // Empty means unset and will not result in an env var. 15 envHTTPSProxyName = "HTTPS_PROXY" 16 17 // NO_PROXY is the list of domains for which the proxy should not be used. 18 // Empty means unset and will not result in an env var. 19 envNoProxyName = "NO_PROXY" 20 ) 21 22 var ( 23 allProxyEnvVarNames = []string{ 24 envHTTPProxyName, 25 envHTTPSProxyName, 26 envNoProxyName, 27 } 28 ) 29 30 // ToEnvVar accepts a config Proxy object and returns an array of all three 31 // proxy variables with values. 32 // 33 // Please note that the function uses the status of the Proxy object to rea the 34 // proxy env variables. It's because OpenShift validates the proxy variables in 35 // spec and writes them back to status. 36 // As a consumer we should be reading off of proxy.status. 37 func ToEnvVar(proxy *apiconfigv1.Proxy) []corev1.EnvVar { 38 return []corev1.EnvVar{ 39 { 40 Name: envHTTPProxyName, 41 Value: proxy.Status.HTTPProxy, 42 }, 43 { 44 Name: envHTTPSProxyName, 45 Value: proxy.Status.HTTPSProxy, 46 }, 47 { 48 Name: envNoProxyName, 49 Value: proxy.Status.NoProxy, 50 }, 51 } 52 }