mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-07-17 09:49:13 +00:00
return error for duplicate keys rather than panicking
This commit is contained in:
@@ -306,13 +306,16 @@ items:
|
||||
assert.False(t, tc.exp.isErr)
|
||||
assert.Equal(t, len(tc.exp.out), len(rs))
|
||||
for i := range rs {
|
||||
rsMap, err := rs[i].Map()
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(
|
||||
t, fmt.Sprintf("%v", tc.exp.out[i]), fmt.Sprintf("%v", rs[i].Map()))
|
||||
t, fmt.Sprintf("%v", tc.exp.out[i]), fmt.Sprintf("%v", rsMap))
|
||||
if n != "listWithAnchors" {
|
||||
// https://github.com/kubernetes-sigs/kustomize/issues/3271
|
||||
if !reflect.DeepEqual(tc.exp.out[i], rs[i].Map()) {
|
||||
m, _ := rs[i].Map()
|
||||
if !reflect.DeepEqual(tc.exp.out[i], m) {
|
||||
t.Fatalf("%s:\nexpected: %v\n actual: %v",
|
||||
n, tc.exp.out[i], rs[i].Map())
|
||||
n, tc.exp.out[i], m)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -220,7 +220,7 @@ func (wn *WNode) GetString(path string) (string, error) {
|
||||
}
|
||||
|
||||
// Map implements ifc.Kunstructured.
|
||||
func (wn *WNode) Map() map[string]interface{} {
|
||||
func (wn *WNode) Map() (map[string]interface{}, error) {
|
||||
return wn.node.Map()
|
||||
}
|
||||
|
||||
|
||||
@@ -559,7 +559,9 @@ func TestGetSlice(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMapEmpty(t *testing.T) {
|
||||
assert.Equal(t, 0, len(NewWNode().Map()))
|
||||
newNodeMap, err := NewWNode().Map()
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, 0, len(newNodeMap))
|
||||
}
|
||||
|
||||
func TestMap(t *testing.T) {
|
||||
@@ -577,7 +579,8 @@ func TestMap(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
actual := wn.Map()
|
||||
actual, err := wn.Map()
|
||||
assert.NoError(t, err)
|
||||
if diff := cmp.Diff(expected, actual); diff != "" {
|
||||
t.Fatalf("actual map does not deep equal expected map:\n%v", diff)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user