Skip to content

Commit

Permalink
fix: do not delete expr tag tmpl values. Fixes #6909
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Collins <alex_collins@intuit.com>
  • Loading branch information
alexec committed Oct 12, 2021
1 parent 2fd4b8a commit f01dd11
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion util/expand/expand.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func removeConflicts(m map[string]interface{}) map[string]interface{} {
for i := 0; i < len(keys)-1; i++ {
k := keys[i]
// remove any parent that has a child
if strings.HasPrefix(keys[i+1]+".", k) {
if strings.HasPrefix(keys[i+1], k+".") {
delete(n, k)
}
}
Expand Down
18 changes: 12 additions & 6 deletions util/expand/expand_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,26 @@ import (
)

func TestExpand(t *testing.T) {
for i := 0; i < 100; i++ { // loop 100 times, because map ordering is not determisitic
for i := 0; i < 1; i++ { // loop 100 times, because map ordering is not determisitic
t.Run(fmt.Sprint(i), func(t *testing.T) {
before := map[string]interface{}{
"a.b": 1,
"a": 2,
"ab": 3,
"a.b": 1,
"a.c.d": 2,
"a": 3, // should be deleted
"ab": 4,
"abb": 5, // should be kept
}
after := Expand(before)
assert.Len(t, before, 3, "original map unchanged")
assert.Len(t, before, 5, "original map unchanged")
assert.Equal(t, map[string]interface{}{
"a": map[string]interface{}{
"b": 1,
"c": map[string]interface{}{
"d": 2,
},
},
"ab": 3,
"ab": 4,
"abb": 5,
}, after)
})
}
Expand Down

0 comments on commit f01dd11

Please sign in to comment.