Fix Kubernetes schema priority after resource-specific schema resolution - #1309
Conversation
datho7561
left a comment
There was a problem hiding this comment.
Works really well and addresses the issue. I think the changes to CodeLens especially are super important. Thanks, Morgan!
One thing that might be interesting, to align with the other changes to CodeLens in this PR, is to have it say "Kubernetes v1.36.1" instead of "all.json" when it's validating against Kubernetes but not any specific resource kind. Do you think that's interesting, and if so, do you want to implement that here or in a different PR?
|
@datho7561 Yes that makes sense! I'll implement it in this PR as well. |
|
The PR title says "Fix ... for multi-document YAML", but the problem I reported is also reproduced with a single-document file (e.g. one containing just MutatingAdmissionPolicy). |
Signed-off-by: Morgan Chang <shin19991207@gmail.com>
863a5d7 to
ce776ea
Compare
datho7561
left a comment
There was a problem hiding this comment.
It works really well and it's really helpful. If you think #1309 (comment) is worth addressing now, that might be worth it. Otherwise, I think this PR is good to merge, so feel free to go ahead and do that.
Signed-off-by: Morgan Chang <shin19991207@gmail.com>
|
@datho7561 Thanks for catching this edge case! I fixed the issue so the CodeLens is now placed on the line after a trailing |
datho7561
left a comment
There was a problem hiding this comment.
Looks good! Thanks, Morgan!

What does this PR do?
Kubernetes auto-detection replaces the configured
all.jsonURI with a document-specific_definitions.jsonor CRD URI. However, schema priorities are registered against the originalall.jsonURI. Looking up priority using the document-specific URI caused it to receive the lowest priority, allowing other schema sources such as SchemaStore to incorrectly win.This PR fixes the issue above and includes several related enhancements to Kubernetes support:
coregroup. For example,apiVersion: v1is parsed as{ group: "core", version: "v1" }, allowing aPodto match theio.k8s.api.core.v1.Poddefinition. Unknown core resources fall back toall.jsoninstead of being searched for in the CRD catalogPod (Kubernetes v1.36.1)andMutatingAdmissionPolicy (Kubernetes v1.36.1), instead of displaying the generalall.json/_definitions.json.json. For example, a schema URI ending inschemais displayed asschema, notschema.json, because schema resources may be JSON, YAML, or extensionlessWhat issues does this PR fix or reference?
Fixes #1298
Is it tested? How?
Automated tests
Tested the case reported in Confusing interaction of schemastore and kubernetes manifests #1298. Verified that:
Tested that an unknown core kind falls back to
all.jsoninstead of being resolved through the CRD catalog. For example, expected the following YAML reports a diagnostic onPo:Value is not accepted. Valid values: "MutatingAdmissionPolicy", "MutatingAdmissionPolicyBinding", "MutatingWebhookConfiguration"..., rather than attempting CRD validation: