Skip to content

Commit 72446bf

Browse files
alexecsarabala1979
authored andcommitted
fix: do not delete expr tag tmpl values. Fixes argoproj#6909 (argoproj#6921)
Signed-off-by: Alex Collins <[email protected]>
1 parent 2922a2a commit 72446bf

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

util/expand/expand.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func removeConflicts(m map[string]interface{}) map[string]interface{} {
2626
for i := 0; i < len(keys)-1; i++ {
2727
k := keys[i]
2828
// remove any parent that has a child
29-
if strings.HasPrefix(keys[i+1]+".", k) {
29+
if strings.HasPrefix(keys[i+1], k+".") {
3030
delete(n, k)
3131
}
3232
}

util/expand/expand_test.go

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,26 @@ import (
88
)
99

1010
func TestExpand(t *testing.T) {
11-
for i := 0; i < 100; i++ { // loop 100 times, because map ordering is not determisitic
11+
for i := 0; i < 1; i++ { // loop 100 times, because map ordering is not determisitic
1212
t.Run(fmt.Sprint(i), func(t *testing.T) {
1313
before := map[string]interface{}{
14-
"a.b": 1,
15-
"a": 2,
16-
"ab": 3,
14+
"a.b": 1,
15+
"a.c.d": 2,
16+
"a": 3, // should be deleted
17+
"ab": 4,
18+
"abb": 5, // should be kept
1719
}
1820
after := Expand(before)
19-
assert.Len(t, before, 3, "original map unchanged")
21+
assert.Len(t, before, 5, "original map unchanged")
2022
assert.Equal(t, map[string]interface{}{
2123
"a": map[string]interface{}{
2224
"b": 1,
25+
"c": map[string]interface{}{
26+
"d": 2,
27+
},
2328
},
24-
"ab": 3,
29+
"ab": 4,
30+
"abb": 5,
2531
}, after)
2632
})
2733
}

0 commit comments

Comments
 (0)