diff --git a/controllers/settings_components_defaults.go b/controllers/settings_components_defaults.go index 33d9c694..aaa46bf4 100644 --- a/controllers/settings_components_defaults.go +++ b/controllers/settings_components_defaults.go @@ -3,6 +3,7 @@ package controllers import ( cbcontainersv1 "github.com/vmware/cbcontainers-operator/api/v1" coreV1 "k8s.io/api/core/v1" + "strings" ) func (r *CBContainersAgentController) setSettingsComponentsDefaults(settings *cbcontainersv1.CBContainersComponentsSettings) error { @@ -31,6 +32,21 @@ func (r *CBContainersAgentController) setProxySettingsComponentsDefaults(proxy * proxy.Enabled = &falseRef } + httpProxyLen := 0 + if proxy.HttpProxy != nil { + httpProxyLen = len(strings.TrimSpace(*(proxy.HttpProxy))) + } + + httpsProxyLen := 0 + if proxy.HttpProxy != nil { + httpProxyLen = len(strings.TrimSpace(*(proxy.HttpsProxy))) + } + + // Don't set NoProxySuffix default value if we don't have any proxies defined + if httpProxyLen+httpsProxyLen == 0 { + return nil + } + if proxy.NoProxySuffix == nil { noProxySuffix, err := GetDefaultNoProxyValue(r.Namespace) if err != nil {