Support multi-resources with different schemas YAML files
See original GitHub issueWhen opening a k8s YAML file, there can be multiple resources descrtibed in it, separated by ---
.
For example:
apiVersion: apps/v1
kind: Deployment
metadata:
name: app
spec:
selector:
matchLabels:
app: app
replicas: 1
template:
metadata:
labels:
app: app
spec:
containers:
- name: app
image: nginx
volumes:
- name: config-volume
configMap:
name: app-config
---
apiVersion: v1
kind: ConfigMap
metadata:
name: app-config
data:
config: some config
In practice, the editor shows an error saying Matches multiple schemas when only one must validate.
and not validation happens.
I think that we should be able to validate separately the different resources of a yaml file without problems by considering them as if they were different files.
Even though YAML support is implemented with yaml-language-server, according to the discussion in redhat-developer/yaml-language-server#80, the problem should be solved in the present extension and not there.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:20
Top Results From Across the Web
Support multi-resources with different schemas YAML files #341
When opening a k8s YAML file, there can be multiple resources descrtibed in it, separated by ---. For example: apiVersion: apps/v1 kind: ...
Read more >How to configure YAML schema to make editing files easier
Discover the benefits of providing a YAML schema and how to make it consumable for all of your users, making it easier to...
Read more >Define YAML resources for Azure Pipelines - Microsoft Learn
Resources in YAML represent sources of pipelines, builds, repositories, containers, packages, and webhooks. Resources also provide you the ...
Read more >Using schemas - IBM
Schemas provide constraints, suggestions, and validation to system programmers and application developers when they create YAML files for CICS® resource ...
Read more >How to use YAML Schema to validate your YAML files
Moreover, engineer support is often still required to understand the full potential of the configuration files. We have been investigating how ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@victornoel @JPinkney The problems are caused by the differences between json and yaml document: one json file only has one document while one yaml file can have multiple documents, in this case(multiple document), the current behavior for k8s schema provider is to provide anyOf [Deployment, ConfigMap] for the specified yaml, this works well if no validation problems/errors found, but if any errors are founded, for example the second ConfigMap has some validation errors, then the yaml-languange-server will not be able to detect which schema is actually chosen since both [Deployment, ConfigMap] schema is not acceptable, and it will use the first one Deployment to report the errors. The solution to this scenario is to notice the getSchemaForResource may return an Array if multiple documents are detected rather than the tricky anyOf schema to represent multiple documents, I am preparing for the PR.
👍
thanks!