vscode-kubernetes-tools: schema validation conflicts with other vscode extension on templates yaml

In our monorepo we have a custom folder named “templates” where we store yaml files not related to kubernetes and to which we apply custom schema validation using “redhat.vscode-yaml” extension. The problem is that when Kubernetes extension is enabled it takes over schema validation of any yaml file located in this folder due to pattern collision "**/templates/*.yaml".

Is there any way to tell kubernetes-tools extension to step back and ignore “templates/*.yaml” pattern so that vscode will use our schema for those files?

About this issue

Most upvoted comments

❤️☕️💡 Thank you both! Aha @lstocchi and @yury-kozlov I think I got it now, the moment file is under the template folder the icon instantly changes, (With extension enable)

So, it is surely not the shouldProvideSchemaFor aka consideration-filter issue it is the helmCompletionProvider issue which is part of the extension and gets added way top in the stack. As mentioned the screenshot might add more clarity and as to explain why templates file are behaving that way.

Screenshot 2023-06-12 at 6 03 05 PM Screenshot 2023-06-12 at 6 53 37 PM

Proposed Solution: (something I could try)

  • I like your idea about finding a way to skip the helmCompletionProvider enablement - shall we do it via some new user setting ~> aka something like vs-kubernetes.skip-helm-completion: - if set to true we can test the skipping of filter bit (Which when I tested locally does work and identify the file as right file.
    • Reason I think it will be better is because it will help in fixing with clarity rather than changing some key aspect of code and causing side effects due to changing of file pattern et. al. (I am not sure the pattern used currently is for what reasons)
Screenshot 2023-06-12 at 7 41 45 PM

Thank you so much! WDYT?

@yury-kozlov - could you sanity-check my comment above? Is it definitely the tooltip in your screenshot that indicates that schema validation is happening?

Please let us know if @Tatsinnit’s .vsix helps at all.

Because I can’t reproduce this myself, I’m wondering if this might be down to a combination of extensions being active (the K8s one plus something else, maybe Helm related?). I’m imagining something like the K8s extension identifies the file as being a helm template (because of a file path pattern), but something else does the schema validation.

Proposed Solution: (something I could try)

  • I like your idea about finding a way to skip the helmCompletionProvider enablement - shall we do it via some new user setting ~> aka something like vs-kubernetes.skip-helm-completion: - if set to true we can test the skipping of filter bit (Which when I tested locally does work and identify the file as right file.
Screenshot 2023-06-12 at 7 41 45 PM Thank you so much! WDYT?

Yes I was thinking about having a setting to change the default behavior but i’m not sure it’s actually possible.

@Tatsinnit i guess that the problem is if the file is under a templates folder. You can see that the plugin intervenes in the yaml because the file icon changes. I suppose we should find a way to avoid registering the helmCompletionProvider when required.

@Tatsinnit thank you for a thorough check! One question: what is the path of yaml file you are testing (with exclude comment)? On my machine the issue happened when the file is stored inside “templates” folder.

Thanks @yury-kozlov and @lstocchi . Cool, I can play around with this tomorrow and will loop back once I found any workaround or solution for this. Thanks heaps