From d1cfb2ccd085d84f546a9c53ec34fa0741b2807f Mon Sep 17 00:00:00 2001 From: hmsayem Date: Mon, 1 Jan 2024 17:01:43 +0600 Subject: [PATCH] Use consts for http proxy Signed-off-by: hmsayem --- pkg/constants.go | 2 ++ pkg/download.go | 4 ++-- pkg/key.go | 4 ++-- pkg/unlock.go | 4 ++-- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/pkg/constants.go b/pkg/constants.go index 5066ecd6..0b684aa2 100644 --- a/pkg/constants.go +++ b/pkg/constants.go @@ -33,6 +33,8 @@ const ( ResticRegistry = "restic" ResticImage = "restic" ResticTag = "0.16.0" + EnvHttpProxy = "HTTP_PROXY" + EnvHttpsProxy = "HTTPS_PROXY" ) // Constants for debugging diff --git a/pkg/download.go b/pkg/download.go index a8a017e1..396f3efc 100644 --- a/pkg/download.go +++ b/pkg/download.go @@ -295,8 +295,8 @@ func (opt *downloadOptions) runRestoreViaDocker(destination string, args []strin "-u", currentUser.Uid, "-v", ScratchDir + ":" + ScratchDir, "-v", opt.destinationDir + ":" + DestinationDir, - "--env", "HTTP_PROXY=" + os.Getenv("HTTP_PROXY"), - "--env", "HTTPS_PROXY=" + os.Getenv("HTTPS_PROXY"), + "--env", fmt.Sprintf("%s=", EnvHttpProxy) + os.Getenv(EnvHttpProxy), + "--env", fmt.Sprintf("%s=", EnvHttpsProxy) + os.Getenv(EnvHttpsProxy), "--env-file", filepath.Join(ConfigDir, ResticEnvs), imgRestic.ToContainerImage(), } diff --git a/pkg/key.go b/pkg/key.go index 2fab65c2..8ae299e1 100644 --- a/pkg/key.go +++ b/pkg/key.go @@ -139,8 +139,8 @@ func (opt *keyOptions) runCmdViaDocker(args []string) error { "--rm", "-u", currentUser.Uid, "-v", ScratchDir + ":" + ScratchDir, - "--env", "HTTP_PROXY=" + os.Getenv("HTTP_PROXY"), - "--env", "HTTPS_PROXY=" + os.Getenv("HTTPS_PROXY"), + "--env", fmt.Sprintf("%s=", EnvHttpProxy) + os.Getenv(EnvHttpProxy), + "--env", fmt.Sprintf("%s=", EnvHttpsProxy) + os.Getenv(EnvHttpsProxy), "--env-file", filepath.Join(ConfigDir, ResticEnvs), } diff --git a/pkg/unlock.go b/pkg/unlock.go index 8f0b4ebf..a00818a3 100644 --- a/pkg/unlock.go +++ b/pkg/unlock.go @@ -208,8 +208,8 @@ func (opt *unlockOptions) runCmdViaDocker(args []string) error { "--rm", "-u", currentUser.Uid, "-v", ScratchDir + ":" + ScratchDir, - "--env", "HTTP_PROXY=" + os.Getenv("HTTP_PROXY"), - "--env", "HTTPS_PROXY=" + os.Getenv("HTTPS_PROXY"), + "--env", fmt.Sprintf("%s=", EnvHttpProxy) + os.Getenv(EnvHttpProxy), + "--env", fmt.Sprintf("%s=", EnvHttpsProxy) + os.Getenv(EnvHttpsProxy), "--env-file", filepath.Join(ConfigDir, ResticEnvs), imgRestic.ToContainerImage(), }