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

Function MergeProxyConfigs

pkg/config/proxy/openshift.go:64–95  ·  view source on GitHub ↗

MergeProxyConfigs merges proxy configurations from the operator and the cluster and merges them, with the operator configuration taking precedence. Accepts nil arguments. If both arguments are nil, returns nil.

(operatorConfig, clusterConfig *controller.Proxy)

Source from the content-addressed store, hash-verified

62// MergeProxyConfigs merges proxy configurations from the operator and the cluster and merges them, with the
63// operator configuration taking precedence. Accepts nil arguments. If both arguments are nil, returns nil.
64func MergeProxyConfigs(operatorConfig, clusterConfig *controller.Proxy) *controller.Proxy {
65 if clusterConfig == nil {
66 return removeEmptyStrings(operatorConfig)
67 }
68 if operatorConfig == nil {
69 return removeEmptyStrings(clusterConfig)
70 }
71
72 mergedProxy := &controller.Proxy{
73 HttpProxy: operatorConfig.HttpProxy,
74 HttpsProxy: operatorConfig.HttpsProxy,
75 NoProxy: operatorConfig.NoProxy,
76 }
77
78 if mergedProxy.HttpProxy == nil {
79 mergedProxy.HttpProxy = clusterConfig.HttpProxy
80 }
81 if mergedProxy.HttpsProxy == nil {
82 mergedProxy.HttpsProxy = clusterConfig.HttpsProxy
83 }
84 if mergedProxy.NoProxy == nil {
85 mergedProxy.NoProxy = clusterConfig.NoProxy
86 } else if *mergedProxy.NoProxy != "" {
87 // Merge noProxy fields, joining with a comma
88 if clusterConfig.NoProxy != nil {
89 noProxy := fmt.Sprintf("%s,%s", *clusterConfig.NoProxy, *operatorConfig.NoProxy)
90 mergedProxy.NoProxy = &noProxy
91 }
92 }
93
94 return removeEmptyStrings(mergedProxy)
95}
96
97// removeEmptyStrings is a utility function for removing empty fields from a proxy configuration. This is required
98// to allow overriding

Callers 3

SetupControllerConfigFunction · 0.92
mergeConfigFunction · 0.92
TestMergeProxyConfigsFunction · 0.85

Calls 1

removeEmptyStringsFunction · 0.85

Tested by 1

TestMergeProxyConfigsFunction · 0.68