diff options
author | John Howard <jhoward@microsoft.com> | 2016-11-21 10:06:17 -0800 |
---|---|---|
committer | John Howard <jhoward@microsoft.com> | 2016-11-23 12:57:33 -0800 |
commit | b2049a84dee35308ca8c4837ccb9359f57808f45 (patch) | |
tree | d67a8317158d2fd223a96c94b75dc96924d7e42b /runconfig/opts | |
parent | 06e92cc2c1e840095f2f11f576fe6097b0fc44af (diff) | |
download | docker-b2049a84dee35308ca8c4837ccb9359f57808f45.tar.gz |
Windows: Case insensitive env vars
Signed-off-by: John Howard <jhoward@microsoft.com>
Diffstat (limited to 'runconfig/opts')
-rw-r--r-- | runconfig/opts/opts.go | 7 | ||||
-rw-r--r-- | runconfig/opts/opts_test.go | 5 |
2 files changed, 12 insertions, 0 deletions
diff --git a/runconfig/opts/opts.go b/runconfig/opts/opts.go index f6c7cd7ed7..2abce5744b 100644 --- a/runconfig/opts/opts.go +++ b/runconfig/opts/opts.go @@ -4,6 +4,7 @@ import ( "fmt" "net" "os" + "runtime" "strings" fopts "github.com/docker/docker/opts" @@ -45,6 +46,12 @@ func ValidateEnv(val string) (string, error) { func doesEnvExist(name string) bool { for _, entry := range os.Environ() { parts := strings.SplitN(entry, "=", 2) + if runtime.GOOS == "windows" { + // Environment variable are case-insensitive on Windows. PaTh, path and PATH are equivalent. + if strings.EqualFold(parts[0], name) { + return true + } + } if parts[0] == name { return true } diff --git a/runconfig/opts/opts_test.go b/runconfig/opts/opts_test.go index 7d22107b9e..7bf9d2672a 100644 --- a/runconfig/opts/opts_test.go +++ b/runconfig/opts/opts_test.go @@ -3,6 +3,7 @@ package opts import ( "fmt" "os" + "runtime" "strings" "testing" ) @@ -50,6 +51,10 @@ func TestValidateEnv(t *testing.T) { " some space before": " some space before", "some space after ": "some space after ", } + // Environment variables are case in-sensitive on Windows + if runtime.GOOS == "windows" { + valids["PaTh"] = fmt.Sprintf("PaTh=%v", os.Getenv("PATH")) + } for value, expected := range valids { actual, err := ValidateEnv(value) if err != nil { |