Skip to content

Commit 520d934

Browse files
authored
Upgrade Command: Source the proxy address from env var (#2507)
* source the proxy address from environment variables * update * test
1 parent 1196a01 commit 520d934

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

cmd/version/upgrade.go

+9-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ var upgradeCmd = &cobra.Command{
3333
return fmt.Errorf("failed to download upgrade script: %w", err)
3434
}
3535

36-
c := exec.Command("sudo", "bash", f.Name())
36+
c := exec.Command("sudo", "-E", "bash", f.Name())
3737
// pass the environment variables to the upgrade script
3838
// so that GITHUB_TOKEN is available
3939
c.Env = os.Environ()
@@ -51,8 +51,15 @@ var upgradeCmd = &cobra.Command{
5151

5252
// downloadFile will download a file from a URL and write its content to a file.
5353
func downloadFile(url string, file *os.File) error {
54+
// Create an HTTP client with specific transport
55+
client := &http.Client{
56+
Transport: &http.Transport{
57+
Proxy: http.ProxyFromEnvironment,
58+
},
59+
}
60+
5461
// Get the data
55-
resp, err := http.Get(url)
62+
resp, err := client.Get(url)
5663
if err != nil {
5764
return err
5865
}

0 commit comments

Comments
 (0)