pull/1487/merge
Tõnis Tiigi 2 years ago committed by GitHub
commit 0eb5bc5909
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -58,6 +58,11 @@ func main() {
os.Exit(1)
}
if err := configureProxy(cmd); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
if plugin.RunningStandalone() {
err = runStandalone(cmd)
} else {

@ -0,0 +1,42 @@
package main
import (
"encoding/json"
"os"
"path/filepath"
"github.com/docker/buildx/util/confutil"
"github.com/docker/cli/cli/command"
"github.com/pkg/errors"
)
func configureProxy(cmd *command.DockerCli) error {
fp := filepath.Join(confutil.ConfigDir(cmd), "proxy.json")
dt, err := os.ReadFile(fp)
if err != nil {
if os.IsNotExist(err) || os.IsPermission(err) {
return nil
}
return err
}
env := map[string]string{}
if err := json.Unmarshal(dt, &env); err != nil {
return errors.Wrapf(err, "failed to parse proxy config %s", fp)
}
permitted := map[string]struct{}{
"HTTP_PROXY": {},
"HTTPS_PROXY": {},
"NO_PROXY": {},
"FTP_PROXY": {},
"ALL_PROXY": {},
}
for k := range permitted {
if _, ok := os.LookupEnv(k); ok {
continue
}
if val, ok := env[k]; ok {
os.Setenv(k, val)
}
}
return nil
}
Loading…
Cancel
Save