mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-07-16 17:33:14 +00:00
Uniform unmarshal function
This commit is contained in:
@@ -153,7 +153,7 @@ func (mf *kustomizationFile) Read() (*types.Kustomization, error) {
|
||||
return nil, err
|
||||
}
|
||||
var k types.Kustomization
|
||||
err = yaml.Unmarshal(data, &k)
|
||||
err = k.Unmarshal(data)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -340,3 +340,21 @@ kind: Kustomization
|
||||
string(expected), string(bytes))
|
||||
}
|
||||
}
|
||||
|
||||
func TestUnknownFieldInKustomization(t *testing.T) {
|
||||
kContent := []byte(`
|
||||
foo:
|
||||
bar
|
||||
`)
|
||||
fSys := filesys.MakeFsInMemory()
|
||||
testutils_test.WriteTestKustomizationWith(fSys, kContent)
|
||||
mf, err := NewKustomizationFile(fSys)
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected Error: %v", err)
|
||||
}
|
||||
|
||||
_, err = mf.Read()
|
||||
if err == nil || err.Error() != "json: unknown field \"foo\"" {
|
||||
t.Fatalf("Expect an unknown field error but got: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user