GetClusterProxyConfig reads a proxy configuration from the "cluster" proxies.config.openshift.io on OpenShift. If running in a non-OpenShift cluster, returns (nil, nil). If the cluster proxy is empty, returns (nil, nil)
(nonCachedClient crclient.Client)
| 33 | // OpenShift. If running in a non-OpenShift cluster, returns (nil, nil). If the cluster proxy is empty, returns |
| 34 | // (nil, nil) |
| 35 | func GetClusterProxyConfig(nonCachedClient crclient.Client) (*controller.Proxy, error) { |
| 36 | if !infrastructure.IsOpenShift() { |
| 37 | return nil, nil |
| 38 | } |
| 39 | proxy := &configv1.Proxy{} |
| 40 | err := nonCachedClient.Get(context.Background(), types.NamespacedName{Name: openshiftClusterProxyName}, proxy) |
| 41 | if err != nil { |
| 42 | if k8sErrors.IsNotFound(err) { |
| 43 | // Should never happen as OpenShift cluster proxy is always present |
| 44 | return nil, nil |
| 45 | } |
| 46 | return nil, err |
| 47 | } |
| 48 | |
| 49 | if proxy.Status.HTTPProxy == "" && proxy.Status.HTTPSProxy == "" && proxy.Status.NoProxy == "" { |
| 50 | return nil, nil |
| 51 | } |
| 52 | |
| 53 | proxyConfig := &controller.Proxy{ |
| 54 | HttpProxy: &proxy.Status.HTTPProxy, |
| 55 | HttpsProxy: &proxy.Status.HTTPSProxy, |
| 56 | NoProxy: &proxy.Status.NoProxy, |
| 57 | } |
| 58 | |
| 59 | return proxyConfig, nil |
| 60 | } |
| 61 | |
| 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. |
no test coverage detected