yaml-language-server
yaml-language-server copied to clipboard
Schema association with fallbacks (wildcards)
Summary
I would like to associate certain files with a specific schema and use a fallback for all other files.
The concrete usecase would be to provide schema association for Kubernetes CRDs and use the default Kubernetes schema for all other files.
Relevant information
This is the config I tried, but it seems that this will enable the Kubernetes schema even for the servicemonitor
and cause validation errors:
yaml.schemas: {
"https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/monitoring.coreos.com/servicemonitor_v1.json": "**servicemonitor.yaml",
"kubernetes": "templates/**.yaml"
}
The Readme contains a similar example, which is quite confusing:
yaml.schemas: {
"https://json.schemastore.org/composer": "/*",
"kubernetes": "/myYamlFile.yaml"
}
From my understanding this will enable the composer schema (some php stuff I guess) for all files in the root directory but will also enable the Kubernetes schema for the file myYamlFile.yaml. Would you not get validation errors in the Kubernetes file from the composer schema?
I'd like to achieve the same thing, but I'm getting the same result. The moment I add "kubernetes": "/*.yaml"
, everything is treated as a Kubernetes manifest. The order doesn't matter.