mirror of
https://github.com/rancher/os.git
synced 2025-09-15 22:49:08 +00:00
HTTP proxy settings can be set in cloud config
This commit is contained in:
@@ -27,11 +27,30 @@ func appendEnv(array []string, key, value string) []string {
|
||||
return append(array, fmt.Sprintf("%s=%s", key, value))
|
||||
}
|
||||
|
||||
func environmentFromCloudConfig(cfg *config.CloudConfig) map[string]string {
|
||||
environment := cfg.Rancher.Environment
|
||||
if cfg.Rancher.Network.HttpProxy != "" {
|
||||
environment["http_proxy"] = cfg.Rancher.Network.HttpProxy
|
||||
environment["HTTP_PROXY"] = cfg.Rancher.Network.HttpProxy
|
||||
}
|
||||
if cfg.Rancher.Network.HttpsProxy != "" {
|
||||
environment["https_proxy"] = cfg.Rancher.Network.HttpsProxy
|
||||
environment["HTTPS_PROXY"] = cfg.Rancher.Network.HttpsProxy
|
||||
}
|
||||
if cfg.Rancher.Network.NoProxy != "" {
|
||||
environment["no_proxy"] = cfg.Rancher.Network.NoProxy
|
||||
environment["NO_PROXY"] = cfg.Rancher.Network.NoProxy
|
||||
}
|
||||
return environment
|
||||
}
|
||||
|
||||
func lookupKeys(cfg *config.CloudConfig, keys ...string) []string {
|
||||
environment := environmentFromCloudConfig(cfg)
|
||||
|
||||
for _, key := range keys {
|
||||
if strings.HasSuffix(key, "*") {
|
||||
result := []string{}
|
||||
for envKey, envValue := range cfg.Rancher.Environment {
|
||||
for envKey, envValue := range environment {
|
||||
keyPrefix := key[:len(key)-1]
|
||||
if strings.HasPrefix(envKey, keyPrefix) {
|
||||
result = appendEnv(result, envKey, envValue)
|
||||
@@ -41,7 +60,7 @@ func lookupKeys(cfg *config.CloudConfig, keys ...string) []string {
|
||||
if len(result) > 0 {
|
||||
return result
|
||||
}
|
||||
} else if value, ok := cfg.Rancher.Environment[key]; ok {
|
||||
} else if value, ok := environment[key]; ok {
|
||||
return appendEnv([]string{}, key, value)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user