-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Open
Labels
kind/bugCategorizes issue or PR as related to a bug.Categorizes issue or PR as related to a bug.triage/acceptedIndicates an issue or PR is ready to be actively worked on.Indicates an issue or PR is ready to be actively worked on.
Description
What happened?
Even though #5487 was closed by #5771, kustomize (v5.7.0 and 5.7.1) still fails with an error if a patch file contains only comments or is empty:
$ cat comments-only-patch.yaml
# This is a comment
$ cat empty-patch.yaml
$ cat kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
patches:
- path: comments-only-patch.yaml
- path: empty-patch.yaml
$ kustomize build
Error: must specify a target for JSON patch [path: "comments-only-patch.yaml"]
$ kustomize version
v5.7.1
Commenting out the patch with the comments results in the same error:
$ cat empty-patch.yaml
$ cat kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
patches:
# - path: comments-only-patch.yaml
- path: empty-patch.yaml
$ kustomize build
Error: must specify a target for JSON patch [path: "empty-patch.yaml"]
NOTE: adding a resource
does not make a difference.
NOTE2: the error has indeed changed from previous versions, before the merge of #5771 the error was something like this:
Error: trouble configuring builtin PatchTransformer with config: `
path: comments-only-patch.yaml
`: illegally qualifies as both an SM and JSON patch: [path: "comments-only-patch.yaml"]
cc @jchanam that worked on the PR just for visibility :) If I'm "holding it wrong" please tell me
What did you expect to happen?
According to #5771 I was expecting that the empty patches would be ignored and not produce an error.
How can we reproduce it (as minimally and precisely as possible)?
# kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- resource.yaml
patches:
- empty.yaml
# empty.yaml
# This is a comment on an "empty" file
# resource.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: dummy
data:
dummy: value
Expected output
apiVersion: v1
kind: ConfigMap
metadata:
name: dummy
data:
dummy: value
Actual output
Error: must specify a target for JSON patch [path: "empty.yaml"]
Kustomize version
5.7.1
Operating system
MacOS
Metadata
Metadata
Assignees
Labels
kind/bugCategorizes issue or PR as related to a bug.Categorizes issue or PR as related to a bug.triage/acceptedIndicates an issue or PR is ready to be actively worked on.Indicates an issue or PR is ready to be actively worked on.