question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support multi-resources with different schemas YAML files

See original GitHub issue

When 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:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:20

github_iconTop GitHub Comments

1reaction
andxucommented, Aug 21, 2018

@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.

0reactions
victornoelcommented, Aug 28, 2018

👍

thanks!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found