-
Notifications
You must be signed in to change notification settings - Fork 270
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
Content-aware schema detection #605
Comments
Please note that if the CRD is deployed on your Kubernetes cluster, that you are connected to it and using VS Code Kubernetes and VS Code yaml, the schema is already resolved. Having a way to define them via preferences as you mentioned or via API would be nice too. For kubernetes files, it is effectively not very convenient to provide schema using modelines in comment as the version is already defined in a specific attribute. A way to workaround the lack of schema support in yaml specification. |
Wasn't aware of this capability of the extension as I don't use VS Code. It's better than nothing of course, I'll try that out, but I definitely agree that offline support would be nice. If it's configurable offline and purely via a language server, then it makes this capability more accessible to the majority of present and future editors. And I imagine Kubernetes access from laptops/workstations where you edit files isn't always an option. Also I'd just like to point out that the Kubernetes ecosystem is just an example. This could be useful for plenty of other use-cases, like internal configs, application-specific configs, etc. |
Any updates on this issue? My 2cents on why this is really needed. While it is a kubernetes specific example, IntelliJs Kubernetes extension is able to recognize contents of a yaml file to determine if it's a kubernetes manifest. I'm sure VSCode's ability to autocomplete by connecting to the cluster itself is useful, but not having the option to do it offline or without VSCode is really inconvenient. Sure, inline comments for schemas exist but they have to be put on every single document. It's prone to human error, nothing is stopping someone making the mistake of putting the With GitOps becoming more prevalent we don't even give some roles cluster credentials, they just edit manifests in a git repo. In some scenarios, we don't even have a cluster yet, merging new manifests to the main branch of GitOps repo is what creates the cluster, without ever needing to touch TL;DR
|
I have created the following PR that addresses this issue, by automatically detetecting the Kubernetes schema used and downloading it from the CRD Catalog: #962 I'm using this in my neovim setup locally and it works great! |
Is your enhancement related to a problem? Please describe.
The current way of mappings schemas to files is way too static for some use-cases. When working e.g. with Kubernetes manifests, it's not very common nor practical to follow a file-naming convention that would include the apiVersion/kind (= the schema determinant), which makes it hard to use YAML LS in practice.
Describe the solution you would like
Instead of just a file glob, I'd like to be able to involve the contents of files in the process of determining a schema. A mapping could be defined using a basic expression, e.g.:
(The syntax doesn't really matter as long as it's possible to determine a schema based on YAML content)
I wonder what maintainers think. Does this sound as a feature that would be accepted or is it too much complexity? Are there any other ways of achieving this ?
Describe alternatives you have considered
Adding comments with schema links to each file. This is quite impractical to maintain in repos with a lot of similar files. Adding the comments could potentially be automated based on a mapping like above for a "quick fix" solution.
Additional context
The text was updated successfully, but these errors were encountered: