diff options
author | James Cassell <code@james.cassell.me> | 2019-04-17 14:16:37 +0000 |
---|---|---|
committer | James Cassell <code@james.cassell.me> | 2019-04-30 17:29:29 -0400 |
commit | 354d80626ac4790f261a29a6d53d6cd3fa837bb9 (patch) | |
tree | 37f8f7740e9e615a561422410ff91a0ce13bead0 /pkg/spec | |
parent | 39c937ee450a4de7ab97c013d65157a3b39718b1 (diff) | |
download | podman-354d80626ac4790f261a29a6d53d6cd3fa837bb9.tar.gz podman-354d80626ac4790f261a29a6d53d6cd3fa837bb9.tar.bz2 podman-354d80626ac4790f261a29a6d53d6cd3fa837bb9.zip |
auto pass http_proxy into container
Signed-off-by: James Cassell <code@james.cassell.me>
Diffstat (limited to 'pkg/spec')
-rw-r--r-- | pkg/spec/createconfig.go | 1 | ||||
-rw-r--r-- | pkg/spec/spec.go | 18 |
2 files changed, 19 insertions, 0 deletions
diff --git a/pkg/spec/createconfig.go b/pkg/spec/createconfig.go index 064dedd45..9c674d9f1 100644 --- a/pkg/spec/createconfig.go +++ b/pkg/spec/createconfig.go @@ -87,6 +87,7 @@ type CreateConfig struct { NoHosts bool HostAdd []string //add-host Hostname string //hostname + HTTPProxy bool Image string ImageID string BuiltinImgVolumes map[string]struct{} // volumes defined in the image config diff --git a/pkg/spec/spec.go b/pkg/spec/spec.go index 4cbed0ea4..383eeadf3 100644 --- a/pkg/spec/spec.go +++ b/pkg/spec/spec.go @@ -192,6 +192,24 @@ func CreateConfigToOCISpec(config *CreateConfig) (*spec.Spec, error) { //nolint } g.SetRootReadonly(config.ReadOnlyRootfs) + if config.HTTPProxy { + for _, envSpec := range []string{ + "http_proxy", + "HTTP_PROXY", + "https_proxy", + "HTTPS_PROXY", + "ftp_proxy", + "FTP_PROXY", + "no_proxy", + "NO_PROXY", + } { + envVal := os.Getenv(envSpec) + if envVal != "" { + g.AddProcessEnv(envSpec, envVal) + } + } + } + hostname := config.Hostname if hostname == "" && (config.NetMode.IsHost() || config.UtsMode.IsHost()) { hostname, err = os.Hostname() |