raw-configuration: fix invalid resources issued from comment-only YAML fragments#46
Open
LeonoreMangold wants to merge 3 commits into
Open
Conversation
LeonoreMangold
commented
Jul 20, 2026
| {{/* Match "---" line separator without leading indentation and with potential trailing whitespaces or comment before the end of line */}} | ||
| {{- range regexSplit "(?m)^---\\s*(#.*)?$" $kubeResources -1 }} | ||
| {{- if . | trim }} | ||
| {{ $document := . | trim | fromYaml }} |
Contributor
Author
There was a problem hiding this comment.
Note: converting to a yaml document removes the comments and only outputs the "real" manifest content. This should be the most reliable base to test for emptiness.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Example of the error:
Here the previous version of the chart would generate two Kubernetes manifests, the first one resulting from the comment part ("# Create my priority class") before the first object separator "---".
The first document only contained the labels appended by the chart, something like that:
But this is an invalid Kubernetes manifest since it does not contain mandatory fields like
apiVersionorkind, so applying the Helm release will result in an error.This kind of use case with a comment being placed before the first separator "---" can occur when using a
rangeloop that needs to be documented. Like that: