From af9100ca7946588243f6bebadba6f1ceea055d07 Mon Sep 17 00:00:00 2001 From: Dmitriy Ivolgin Date: Mon, 16 Sep 2024 06:39:49 -0700 Subject: [PATCH] Read PROXY env in more places when deploying (#4891) --- pkg/kotsadmupstream/upstream.go | 13 +++++++++++++ pkg/online/online.go | 13 +++++++++++++ 2 files changed, 26 insertions(+) diff --git a/pkg/kotsadmupstream/upstream.go b/pkg/kotsadmupstream/upstream.go index 1d59d246d0..5dcb0e0e2c 100644 --- a/pkg/kotsadmupstream/upstream.go +++ b/pkg/kotsadmupstream/upstream.go @@ -234,6 +234,19 @@ func DownloadUpdate(appID string, update types.Update, skipPreflights bool, skip AppSelectedChannelID: a.SelectedChannelID, } + pullOptions.HTTPProxyEnvValue = os.Getenv("HTTP_PROXY") + if pullOptions.HTTPProxyEnvValue == "" { + pullOptions.HTTPProxyEnvValue = os.Getenv("http_proxy") + } + pullOptions.HTTPSProxyEnvValue = os.Getenv("HTTPS_PROXY") + if pullOptions.HTTPSProxyEnvValue == "" { + pullOptions.HTTPSProxyEnvValue = os.Getenv("https_proxy") + } + pullOptions.NoProxyEnvValue = os.Getenv("NO_PROXY") + if pullOptions.NoProxyEnvValue == "" { + pullOptions.NoProxyEnvValue = os.Getenv("no_proxy") + } + _, err = pull.Pull(fmt.Sprintf("replicated://%s", beforeKotsKinds.License.Spec.AppSlug), pullOptions) if err != nil { if errors.Cause(err) != pull.ErrConfigNeeded { diff --git a/pkg/online/online.go b/pkg/online/online.go index 74a8ce6bbf..84848a89cb 100644 --- a/pkg/online/online.go +++ b/pkg/online/online.go @@ -160,6 +160,19 @@ func CreateAppFromOnline(opts CreateOnlineAppOpts) (_ *kotsutil.KotsKinds, final SkipCompatibilityCheck: opts.SkipCompatibilityCheck, } + pullOptions.HTTPProxyEnvValue = os.Getenv("HTTP_PROXY") + if pullOptions.HTTPProxyEnvValue == "" { + pullOptions.HTTPProxyEnvValue = os.Getenv("http_proxy") + } + pullOptions.HTTPSProxyEnvValue = os.Getenv("HTTPS_PROXY") + if pullOptions.HTTPSProxyEnvValue == "" { + pullOptions.HTTPSProxyEnvValue = os.Getenv("https_proxy") + } + pullOptions.NoProxyEnvValue = os.Getenv("NO_PROXY") + if pullOptions.NoProxyEnvValue == "" { + pullOptions.NoProxyEnvValue = os.Getenv("no_proxy") + } + if _, err := pull.Pull(opts.UpstreamURI, pullOptions); err != nil { if errors.Cause(err) != pull.ErrConfigNeeded { return nil, errors.Wrap(err, "failed to pull")