MCPcopy Create free account
hub / github.com/devfile/devworkspace-operator / getProxyFunc

Function getProxyFunc

controllers/workspace/http.go:178–204  ·  view source on GitHub ↗

getProxyFunc returns a proxy function based on the global operator configuration. Returns nil if no proxy is configured; a nil proxy func causes the HTTP transport to use the default proxy settings from environment variables.

()

Source from the content-addressed store, hash-verified

176// Returns nil if no proxy is configured; a nil proxy func causes the HTTP transport to
177// use the default proxy settings from environment variables.
178func getProxyFunc() func(*http.Request) (*url.URL, error) {
179 globalConfig := config.GetGlobalConfig()
180
181 if globalConfig.Routing != nil && globalConfig.Routing.ProxyConfig != nil {
182 proxyConf := httpproxy.Config{}
183 if globalConfig.Routing.ProxyConfig.HttpProxy != nil {
184 proxyConf.HTTPProxy = *globalConfig.Routing.ProxyConfig.HttpProxy
185 }
186 if globalConfig.Routing.ProxyConfig.HttpsProxy != nil {
187 proxyConf.HTTPSProxy = *globalConfig.Routing.ProxyConfig.HttpsProxy
188 }
189 if globalConfig.Routing.ProxyConfig.NoProxy != nil {
190 proxyConf.NoProxy = *globalConfig.Routing.ProxyConfig.NoProxy
191 }
192
193 if proxyConf.HTTPProxy == "" && proxyConf.HTTPSProxy == "" {
194 return nil
195 }
196
197 proxyFn := proxyConf.ProxyFunc()
198 return func(req *http.Request) (*url.URL, error) {
199 return proxyFn(req.URL)
200 }
201 }
202
203 return nil
204}
205
206// getCaCertPool returns a CA cert pool that includes system certs and any additional certs from the ConfigMap.
207// A nil pool causes the HTTP client to use the system default root CAs.

Callers 1

SetupHttpClientsFactoryFunction · 0.85

Calls 1

GetGlobalConfigFunction · 0.92

Tested by

no test coverage detected