mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-05-17 18:25:26 +00:00
fix: Allow patches with empty files with multiple newlines or comments (#5771)
* fix: Add test, when an empty patch file is given, it should not fail * fix: Add code so there's no error given if an empty file is given as a patch * chore: Generate plugin with pluginator * chore: fix tests Signed-off-by: Julio Chana <julio.chana@lokalise.com> * Add t.helper() at start of test function Signed-off-by: Julio Chana <julio.chana@lokalise.com> --------- Signed-off-by: Julio Chana <julio.chana@lokalise.com>
This commit is contained in:
@@ -56,8 +56,9 @@ func (p *PatchTransformerPlugin) Config(h *resmap.PluginHelpers, c []byte) error
|
||||
patchesSM, errSM := h.ResmapFactory().RF().SliceFromBytes([]byte(p.patchText))
|
||||
patchesJson, errJson := jsonPatchFromBytes([]byte(p.patchText))
|
||||
|
||||
if (errSM == nil && errJson == nil) ||
|
||||
(patchesSM != nil && patchesJson != nil) {
|
||||
if ((errSM == nil && errJson == nil) ||
|
||||
(patchesSM != nil && patchesJson != nil)) &&
|
||||
(len(patchesSM) > 0 && len(patchesJson) > 0) {
|
||||
return fmt.Errorf(
|
||||
"illegally qualifies as both an SM and JSON patch: %s",
|
||||
p.patchSource)
|
||||
|
||||
Reference in New Issue
Block a user