tim-koehler / Helm-Intellisense

Extension for Visual Studio Code - Intellisense in helm-templates from the values.yaml
https://marketplace.visualstudio.com/items?itemName=Tim-Koehler.helm-intellisense&ssr=false#overview
MIT License
1.67k stars 25 forks source link

`define`s Not Found When They're In Other Files #46

Closed ProfMoo closed 2 years ago

ProfMoo commented 2 years ago

Hi! Very nice plugin!

One issue I'm running into is the plugin being able to find define blocks from other YAML files. For example, let's say I have two files:

  1. A file called _ports.yaml where I define port constants that are used across the chart, like {{- define "my.port" -}}.
  2. A file called stateful-set.yaml, which uses {{ include "my.port" }} to get the port value from _ports.yaml.

The practice is a bit unusual, but it works perfectly well in Helm and passes Helm linting checks. As such, I believe it should work this plugin.

Looking forward to further thoughts on this use-case.

marcfrederick commented 2 years ago

So if I understand correctly, you are defining named templates containing your ports and including those around your chart. The problem seems to be, that named templates are defined in .tpl files by convention, so the code only scans those for define blocks (see here).

The quick and simple fix for your case would be to rename your _ports.yaml to _ports.tpl if possible.

The extension is definitely making an incorrect assumption here though, which we should fix. @tim-koehler were there any reasons for limiting the scanning of define blocks to .tpl files?

ProfMoo commented 2 years ago

@marcfrederick Thanks for the info. I tried changing the file from _ports.yaml to _ports.tpl and the plugin worked as expected :).

So yes, I agree that the extension is making an incorrect assumption, but I also think that the workaround is totally permissible. Happy to either keep open or close the issue.

tim-koehler commented 2 years ago

@ProfMoo Just merged and released a new patch which also allows templates to also be found in non .tpl files (like .yaml). This should finally resolve your issue 😊

@marcfrederick Thanks for your PR

ProfMoo commented 2 years ago

Awesome, thanks for the quick response everyone!