Skip to content
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

Additional YAML document header when rendering CRDs to stdout #12953

Open
magat opened this issue Apr 16, 2024 · 0 comments · May be fixed by #12960
Open

Additional YAML document header when rendering CRDs to stdout #12953

magat opened this issue Apr 16, 2024 · 0 comments · May be fixed by #12960
Labels
bug Categorizes issue or PR as related to a bug. good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.

Comments

@magat
Copy link

magat commented Apr 16, 2024

Output of helm version:

version.BuildInfo{Version:"v3.14.4", GitCommit:"81c902a123462fd4052bc5e9aa9c513c4c8fc142", GitTreeState:"clean", GoVersion:"go1.22.2"}

Context: the CI for our charts renders all the content including CRDs before piping the result to kyverno to check compliance with internal policies. This step fails because helm produces empty documents.

This bug arises only for CRDs when rendering to stdout, if the yaml file for the CRD in the subchart starts with the document separator ---.

To reproduce, in this repository:

# Add a --- at the beginning of the CRD file
$ echo -e "---\n$(cat ./cmd/helm/testdata/testcharts/subchart/crds/crdA.yaml)" > ./cmd/helm/testdata/testcharts/subchart/crds/crdA.yaml
# render
$ helm template --include-crds cmd/helm/testdata/testcharts/subchart/ | head

The output:

---
# Source: subchart/crds/crdA.yaml
---
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
  name: testcrds.testcrdgroups.example.com
spec:
  group: testcrdgroups.example.com
  version: v1alpha1

After looking at the code, I suspect that the problem lies in this code that directly write the crd file content:

fmt.Fprintf(b, "---\n# Source: %s\n%s\n", crd.Filename, string(crd.File.Data[:]))

@gjenkins8 gjenkins8 added help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. bug Categorizes issue or PR as related to a bug. good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. labels Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Categorizes issue or PR as related to a bug. good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants