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

Support for includes #59

Open
qvalentin opened this issue Feb 4, 2024 · 4 comments
Open

Support for includes #59

qvalentin opened this issue Feb 4, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@qvalentin
Copy link
Collaborator

Opening this issue to track your feature request @Mo0rBy.

1 question I have to see if this would even be possible. So with Helm Library charts, they can be stored and referenced within the local machines filesystem and I imagine that with this method, it would be possible to get the LSP to find definitions for Helm templates, however, would this be possible for library charts hosted in online repositories? For example, Bitnami have a common library which contains a bunch of useful utility templates that are heavily used in their own Helm charts and can easily be used in your own custom Helm charts. Furthermore, would it be possible to setup the LSP to get template definitions from private repositories? (my initial guess would be no without setting up some authentication stuff which I think would be kind of advanced for any LSP to do).

To support this I would suggest to approach it using the following steps:

  1. Support local includes in same chart
    For this you would need to read in all templates files in the current chart and parse them with tree-sitter. On go-to-definition or hover you would query the parsed templates for the corresponding definition. For this you would also need to update the parsed templates when they change (this should already be implemented).

  2. Support local includes from dependency charts
    On startup you could read in all dependency charts that are defined like repository: file:https://../mylibchart and add their templates to the templates that are queried for go-to-definition or hover of includes

  3. Support remote includes from dependency charts
    Would be the same as 2. but you would need to fetch the dependencies over the network.

  4. Support remote includes from dependency charts with authentication
    Would be the same as 3. but using user defined credentials (e.g. via configuration options or environment variables)

@qvalentin qvalentin added the enhancement New feature or request label Feb 4, 2024
@AndersBennedsgaard
Copy link

AndersBennedsgaard commented Apr 26, 2024

Actually, should Helm-ls even support sources other than the current chart and dependencies collected in the charts/ folder collected with helm dependency build or similar?
Supporting remote library charts with advanced networking, authentication, caching, and all the other issues that come with this, seems out of scope for an LS.

Most other language servers just make use of the locally collected dependencies. For example: gopls only support dependencies already collected with go get or similar.
The YAML language server is special in this regard, since it enabled remote lookup of schemas, but in my mind, this is not necessary here

@Mo0rBy
Copy link

Mo0rBy commented Apr 26, 2024

@AndersBennedsgaard I think you're correct, this should only read dependencies that are built and stored within the charts/ directory.
Then all the authentication and stuff is up to the user to sort.

For example, the user will need to make sure they execute:

aws ecr get-login-password | helm registry login --username AWS --password-stdin <my-aws-account-url> && \
helm dependency build

Makes it a whole lot simpler as well as we don't have to worry about different source types etc, it just reads everything it needs from the charts/ directory.

@qvalentin
Copy link
Collaborator Author

You are right, reimplementing the dependency fetch makes no sense. We could either use helm as a library (#77) or maybe call helm env to get the HELM_REPOSITORY_CACHE directory and read the charts from there.
Either way, step 1 from the first post in this issue is about 50% done in #72.

@qvalentin
Copy link
Collaborator Author

qvalentin commented May 17, 2024

Support local includes in same chart is implemented in https://github.com/mrjosh/helm-ls/releases/tag/v0.0.16.

The rest might follow with #80
(Preview below)
Screenshot_20240516-205147_Termux

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants