0

I have a lot of comments in my helm chart in my repository. I want to deliver my helm chart to others without these comments.

I am hoping to be able to do this during my CI pipeline. I have a step in my pipeline which performs the helm package command. I am hoping to have this package completely stripped of comments (in the templates, values, etc)

I have not found a way to do this directly with helm.

Is there a simple solution to my problem?

I have already considered some ways to solve it but I feel like I am missing a simple solution here. I know I can parse the values files and re write them using something like yq which will strip all comments. But that won't work for the template files as they are not valid yaml with the helm/go templating in them.

1

1 Answer 1

1

If you running Linux-based agents/runners, then you may be able to integrate the following command into your CI pipeline:

find path/to/helmchart/directory/ -type f -exec sed -i '' '/^#/d' {} \;

In the above command we use the find command to list out all the files in the helm chart directory and then we use the exec switch to run a sed to delete the lines which begin with a # using the regex pattern ^#.

The above command can be modified to include other regex patterns as defined by the use case.

Also note that only the comments which begin with a # would be removed from the files in the helm directory. Helm chart templates have comments in the form of {{/* ... */}}. These will not be stripped. But supplying another regex will be able to do this job too. I hope this helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.