Use HTTPProxy settings from containers.conf

This PR takes the settings from containers.conf and uses
them.  This works on the podman local but does not fix the
issue for podman remote or for APIv2.  We need a way
to specify optionalbooleans when creating containers.

Fixes: https://github.com/containers/podman/issues/8843

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
Daniel J Walsh
2021-01-08 09:42:43 -05:00
parent 63d8f535ec
commit 1c1e670d40
16 changed files with 118 additions and 25 deletions

View File

@ -746,13 +746,20 @@ func (c *Config) FindConmon() (string, error) {
}
// GetDefaultEnv returns the environment variables for the container.
// It will checn the HTTPProxy and HostEnv booleans and add the appropriate
// It will check the HTTPProxy and HostEnv booleans and add the appropriate
// environment variables to the container.
func (c *Config) GetDefaultEnv() []string {
return c.GetDefaultEnvEx(c.Containers.EnvHost, c.Containers.HTTPProxy)
}
// GetDefaultEnvEx returns the environment variables for the container.
// It will check the HTTPProxy and HostEnv boolean parameters and return the appropriate
// environment variables for the container.
func (c *Config) GetDefaultEnvEx(envHost, httpProxy bool) []string {
var env []string
if c.Containers.EnvHost {
if envHost {
env = append(env, os.Environ()...)
} else if c.Containers.HTTPProxy {
} else if httpProxy {
proxy := []string{"http_proxy", "https_proxy", "ftp_proxy", "no_proxy", "HTTP_PROXY", "HTTPS_PROXY", "FTP_PROXY", "NO_PROXY"}
for _, p := range proxy {
if val, ok := os.LookupEnv(p); ok {