mirror of
https://github.com/docker/cli.git
synced 2026-01-23 15:21:32 +03:00
Merge pull request #26304 from OctopusDeploy/26178-env-vars-with-equals
Allow windows environment variables to contain `=` Upstream-commit: 778acfdf099894332f6944e7643ee20d8f14387d Component: engine
This commit is contained in:
@@ -10,7 +10,7 @@ import (
|
||||
func setupEnvironmentVariables(a []string) map[string]string {
|
||||
r := make(map[string]string)
|
||||
for _, s := range a {
|
||||
arr := strings.Split(s, "=")
|
||||
arr := strings.SplitN(s, "=", 2)
|
||||
if len(arr) == 2 {
|
||||
r[arr[0]] = arr[1]
|
||||
}
|
||||
|
||||
13
components/engine/libcontainerd/utils_windows_test.go
Normal file
13
components/engine/libcontainerd/utils_windows_test.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package libcontainerd
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestEnvironmentParsing(t *testing.T) {
|
||||
env := []string{"foo=bar", "car=hat", "a=b=c"}
|
||||
result := setupEnvironmentVariables(env)
|
||||
if len(result) != 3 || result["foo"] != "bar" || result["car"] != "hat" || result["a"] != "b=c" {
|
||||
t.Fatalf("Expected map[foo:bar car:hat a:b=c], got %v", result)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user