Browse Source

Merge pull request #17991 from nak3/proxy-env

docker info suppports case-insensitive proxy env settings
David Calavera 9 years ago
parent
commit
57b42250ce
1 changed files with 14 additions and 3 deletions
  1. 14 3
      daemon/info.go

+ 14 - 3
daemon/info.go

@@ -3,6 +3,7 @@ package daemon
 import (
 import (
 	"os"
 	"os"
 	"runtime"
 	"runtime"
+	"strings"
 	"time"
 	"time"
 
 
 	"github.com/Sirupsen/logrus"
 	"github.com/Sirupsen/logrus"
@@ -91,9 +92,9 @@ func (daemon *Daemon) SystemInfo() (*types.Info, error) {
 		ServerVersion:      dockerversion.Version,
 		ServerVersion:      dockerversion.Version,
 		ClusterStore:       daemon.config().ClusterStore,
 		ClusterStore:       daemon.config().ClusterStore,
 		ClusterAdvertise:   daemon.config().ClusterAdvertise,
 		ClusterAdvertise:   daemon.config().ClusterAdvertise,
-		HTTPProxy:          os.Getenv("http_proxy"),
-		HTTPSProxy:         os.Getenv("https_proxy"),
-		NoProxy:            os.Getenv("no_proxy"),
+		HTTPProxy:          getProxyEnv("http_proxy"),
+		HTTPSProxy:         getProxyEnv("https_proxy"),
+		NoProxy:            getProxyEnv("no_proxy"),
 	}
 	}
 
 
 	// TODO Windows. Refactor this more once sysinfo is refactored into
 	// TODO Windows. Refactor this more once sysinfo is refactored into
@@ -129,3 +130,13 @@ func (daemon *Daemon) showPluginsInfo() types.PluginsInfo {
 
 
 	return pluginsInfo
 	return pluginsInfo
 }
 }
+
+// The uppercase and the lowercase are available for the proxy settings.
+// See the Go specification for details on these variables. https://golang.org/pkg/net/http/
+func getProxyEnv(key string) string {
+	proxyValue := os.Getenv(strings.ToUpper(key))
+	if proxyValue == "" {
+		return os.Getenv(strings.ToLower(key))
+	}
+	return proxyValue
+}