Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit 6018027

Browse files
committed
Fixes issue #454 Environment.ToMap() doesn't support variables with equals signs
Signed-off-by: John Ritsema <[email protected]>
1 parent 8e4221d commit 6018027

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

yaml/types_yaml.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,9 @@ func toStrings(s []interface{}) ([]string, error) {
249249
func toMap(s []string, sep string) map[string]string {
250250
m := map[string]string{}
251251
for _, v := range s {
252+
// Return everything past first sep
252253
values := strings.Split(v, sep)
253-
m[values[0]] = values[1]
254+
m[values[0]] = strings.SplitN(v, sep, 2)[1]
254255
}
255256
return m
256257
}

yaml/types_yaml_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,3 +202,13 @@ func TestSliceWithEmptyValue(t *testing.T) {
202202
assert.True(t, contains(s2.Foo, "empty="))
203203
assert.True(t, contains(s2.Foo, "lookup"))
204204
}
205+
206+
func TestEqualSliceToMapEqualSign(t *testing.T) {
207+
slice := MaporEqualSlice{"foo=bar=baz"}
208+
result := slice.ToMap()
209+
assert.Equal(t, "bar=baz", result["foo"])
210+
211+
slice = MaporEqualSlice{"foo=bar=baz=buz"}
212+
result = slice.ToMap()
213+
assert.Equal(t, "bar=baz=buz", result["foo"])
214+
}

0 commit comments

Comments
 (0)