werf / nelm

Nelm is a Helm 3 alternative and werf deployment engine
Apache License 2.0
262 stars 1 forks source link

Subcharts using oci dependencies do not restore them during bundle publish #130

Open kayanme opened 1 month ago

kayanme commented 1 month ago

Before proceeding

Version

2.10.5

How to reproduce

  1. Create library chart with some template function there ("test-template-function").
  2. Push this chart to the OCI repo.
  3. Create a new chart ("parent").
  4. Create a subchart there ("child").
  5. Declare a dependency to the library chart from step 2 in this subchart.
  6. Include the library function in this subchart somehow ("{{ include "test-template-function") .}}") .
  7. Publish the parent chart via bundle publish.
  8. Use bundle render to view a chart content.

Instead of 7 and 8 you can just render chart or just converge it, the result will be the same (no function found).

Result

Error: error constructing chart tree: error rendering resources for chart "parent": template: parent/charts/child/templates/function-call.yaml:1:4: executing "parent/charts/child/templates/function-call.yaml" at <include "test-template-function" . >: error calling include: template: no template "test-template-function" associated with template "gotpl"

Expected result

The function from the subchart dependency should be seen.

Additional information

You can add the subchart dependency to the parent chart, then the function will be available to use in the subchart, but only in one. Other subcharts with this dependency will not be rendered at all.

ilya-lesikov commented 1 month ago

Сhart dependency resolution in Helm is very primitive. As far as I remember it only downloads direct dependencies of the root chart, but unable to resolve and download subchart dependencies. So you either vendor your whole charts tree in .helm/charts or define a complete list of charts needed to be downloaded in .helm/Chart.yaml.

You can add the subchart dependency to the parent chart, then the function will be available to use in the subchart, but only in one. Other subcharts with this dependency will not be rendered at all.

That's not how it should work. This is a bug or, most likely, misconfiguration. Helm templates (define/include templates in .tpl files) are globally scoped. Once a chart with such .tpl templates included once, all of these templates become available to all the other charts, be it parent or child or sibling charts. Make sure you do everything correctly and if the issue stays please provide a reproducible example.