Provide a way to map schemas to multidocument yaml file
According to specification yaml file may contain multiple documents. In real world it is used to define a custom k8s resources, for example Tekton Samples, each file has more then one document, we have JSON Schema for each of them, but there are no way to map that different schema to yaml document inside such multi document yaml files.
I think if you're using the custom schema contributor API its possible to use schemaSequence. E.g. with this yaml
---
apiVersion: v1
kind: Pod
metadata:
name: myapp
labels:
name: myapp
spec:
containers:
- name: myapp
image: <Image>
resources:
limits:
memory: "128Mi"
cpu: "500m"
ports:
- containerPort: 222
...
apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp
spec:
selector:
matchLabels:
app: myapp
template:
metadata:
labels:
app: myapp
spec:
containers:
- name: myapp
image: <Image>
resources:
limits:
memory: "128Mi"
cpu: "500m"
ports:
- containerPort: 222
when you try to autocomplete you'll get:
[Trace - 9:43:04 a.m.] Received request 'custom/schema/request - (424)'.
Params: "file:///home/joshpinkney/Documents/Work/Schemas/basic.yaml"
[Trace - 9:43:04 a.m.] Sending response 'custom/schema/request - (424)'. Processing request took 0ms
Result: [
"kubernetes://schema/v1@pod+apps/v1@deployment"
]
[Trace - 9:43:04 a.m.] Received request 'custom/schema/content - (425)'.
Params: "kubernetes://schema/v1@pod+apps/v1@deployment"
[Trace - 9:43:04 a.m.] Sending response 'custom/schema/content - (425)'. Processing request took 0ms
Result: "{\"schemaSequence\":[{\"$ref\":\"kubernetes://schema/v1@pod\"},{\"$ref\":\"kubernetes://schema/apps/v1@deployment\"}]}"
so autocompletion, validation, hover, etc will use the pod schema defined by the vscode-kubernetes-tools for the first document and for the second one use the deployment schema. Their implementation of the YamlSchemaContributor is here: https://github.com/Azure/vscode-kubernetes-tools/blob/master/src/yaml-support/yaml-schema.ts#L72