Merge pull request #4929 from koba1t/refactor/cleanup_Unmarshal_kustomization

Error on duplicate fields in Kustomization
This commit is contained in:
Kubernetes Prow Robot
2023-01-06 10:37:59 -08:00
committed by GitHub
22 changed files with 39 additions and 117 deletions

View File

@@ -104,7 +104,7 @@ func (lc *localizer) load() (*types.Kustomization, string, error) {
var kust types.Kustomization
err = (&kust).Unmarshal(content)
if err != nil {
return nil, "", errors.WrapPrefixf(err, "invalid kustomization")
return nil, "", errors.Wrap(err)
}
// Localize intentionally does not replace legacy fields to return a localized kustomization

View File

@@ -212,7 +212,8 @@ suffix: invalid`,
})
err := Run("/a", "", "", fSysTest)
require.EqualError(t, err, `unable to localize target "/a": invalid kustomization: json: unknown field "suffix"`)
require.EqualError(t, err,
`unable to localize target "/a": invalid Kustomization: error unmarshaling JSON: while decoding JSON: json: unknown field "suffix"`)
checkFSys(t, fSysExpected, fSysTest)
}