<p>If you running Linux-based agents/runners, then you may be able to integrate the following command into your CI pipeline:</p>
<pre><code>find path/to/helmchart/directory/ -type f -exec sed -i '' '/^#/d' {} \;
</code></pre>
<p>In the above command we use the <code>find</code> command to list out all the files in the helm chart directory and then we use the <code>exec</code> switch to run a <code>sed</code> to delete the lines which begin with a <code>#</code> using the regex pattern <code>^#</code>.</p>
<p>The above command can be modified to include other regex patterns as defined by the use case.</p>
<p>Also note that only the comments which begin with a <code>#</code> would be removed from the files in the helm directory. Helm chart templates have comments in the form of <code>{{/* ... */}}</code>. These will not be stripped. But supplying another regex will be able to do this job too. I hope this helps.</p>

CC BY-SA 4.0
2023-02-04T02:07:59.847Z
2023-02-04T02:07:59.847Z
Shivinder
<p>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.</p>
<p>I am hoping to be able to do this during my CI pipeline. I have a step in my pipeline which performs the <code>helm package</code> command. I am hoping to have this package completely stripped of comments (in the templates, values, etc)</p>
<p>I have not found a way to do this directly with helm.</p>
<p>Is there a simple solution to my problem?</p>
<p>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 <code>yq</code> 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.</p>

CC BY-SA 4.0
2023-01-31T15:12:42.897Z
YAML comments or template comments - https://helm.sh/docs/chart_best_practices/templates/?
Kyslik
<kubernetes><continuous-integration><helm><kubernetes-helm>
strip all comments from helm package
Inbar Rose
# strip all comments from helm package

(Asked by: username_0 on 2023-01-30)

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.

**Tags:** kubernetes, continuous-integration, helm, kubernetes-helm

> **Comments:**
> **username_1**: YAML comments or template comments - https://helm.sh/docs/chart_best_practices/templates/?  

---

## 1 answers

### Answer by username_2 on 2023-02-04. Score: 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.


---

