kustomize icon indicating copy to clipboard operation
kustomize copied to clipboard

fix: Allow patches with empty files with multiple newlines or comments

Open jchanam opened this issue 4 months ago • 5 comments

Fixes https://github.com/kubernetes-sigs/kustomize/issues/5487

Right now, when a file is empty, the patches given by the resmap (sm patches) or the jsonpatch is nil. When the file has only comments in it (virtually empty if we think about changes to be made) or multiple newlines, the result given by said functions is an empty slice.

I've changed the check for when we can't allow to have a patch that is valid for both SM and JSON, so it allows empty changes (both nil or empty slices).

Extra comments:

  • I think that it'd be better to change the functions and return a nil object, instead of an empty slice, but I'm unsure on where to do those changes.
  • Also, I can't make the tests to run locally as they complain for the content file to be empty, and that should not be the case as it's perfectly ok for the built binary to use empty patches.

I'll be more than happy to work on these two with some help or guidance.

jchanam avatar Sep 27 '24 09:09 jchanam