-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Kustomize edit panics when Kustomization file begins with document separator #4123
Comments
I have just realized I had a blank line at the beginning of the file. Removing that blank line into the |
/assign @KnVerey |
/assign @m-Bilal |
@KnVerey: GitHub didn't allow me to assign the following users: m-Bilal. Note that only kubernetes-sigs members, repo collaborators and people who have commented on this issue/PR can be assigned. Additionally, issues/PRs can only have 10 assignees at the same time. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/assign |
@KnVerey the panic happens because in this line
len(mf.originalFields) returns 0.The reason for this is when the file begins with a blank line (or a comment) and a document separator immediately follows it, len(comments) is > 0 but len(mf.originalFields) is still 0, and since document separator does not match any field, it goes into the following else if condition
So, the kustomization files
and
result in exactly same errors. I was able to fix this by changing
else if len(comments) > 0 && len(mf.originalFields) > 0 . Then kustomize edit set namespace mynamespace simply ignores the document separator and results are as follows:
becomes:
(the blank line is still there), and
becomes
I'll raise a PR with this fix, if there's anything I missed or if it should be a different fix, please let me know. |
Describe the bug
I get a panic when running
kustomize edit set namespace mynamespace
.Files that can reproduce the issue
kustomization.yaml
Expected output
No panic message and the
namespace
field updated tomynamespace
.Actual output
Kustomize version
Platform
Linux
Additional context
Installed by:
The text was updated successfully, but these errors were encountered: