yaml-language-server icon indicating copy to clipboard operation
yaml-language-server copied to clipboard

Set specific Kubernetes Schema Version

Open joshrosso opened this issue 5 years ago • 5 comments

It appears the Kubernetes schema is hardcoded at https://github.com/redhat-developer/yaml-language-server/blob/master/src/server.ts#L32.

Is it possible to set a specific version? For example, if I wanted to use https://raw.githubusercontent.com/instrumenta/kubernetes-json-schema/master/v1.16.0-standalone-strict/all.json?

I tried

yaml.schemas: {
        "https://raw.githubusercontent.com/instrumenta/kubernetes-json-schema/master/v1.16.0-standalone-strict/all.json": "/*.yaml"
}

but no luck.

For now, editing server.ts on my local machine works well. I wonder if an [optional] environment variable could be helpful?

joshrosso avatar Jan 03 '20 03:01 joshrosso

It appears the Kubernetes schema is hardcoded at https://github.com/redhat-developer/yaml-language-server/blob/master/src/server.ts#L32.

it has been moved to https://github.com/redhat-developer/yaml-language-server/blob/7346049ac3c6dca6d3b27852c491f6851e3e41ab/src/languageservice/utils/schemaUrls.ts#L1

Using the yaml.schemas should be something working. I think it is a matter of priorities in schema resolution. hope it would be handled with https://github.com/redhat-developer/yaml-language-server/issues/250

Another solution would be to be able to specify the yaml schema in the yaml data file directly https://github.com/redhat-developer/yaml-language-server/issues/204

I wonder if an [optional] environment variable could be helpful?

I'm not a big fan of environment variable as it can have collateral effect but it seems a quick win to add this possibility. (and given the number of +1 on this issue ti can allow to please a lot of people)

@JPinkney From technical point of view, is it a matter of modifying only https://github.com/redhat-developer/yaml-language-server/blob/7346049ac3c6dca6d3b27852c491f6851e3e41ab/src/server.ts#L115-L116 ?

apupier avatar Jul 21 '20 12:07 apupier

Yes I believe so. But TBH I question if we should even have the kubernetes schema embedded in this extension anymore and should just tell people to add it if they want

JPinkney avatar Jul 21 '20 12:07 JPinkney

@JPinkney I think that's the right move.

It feels weird that Kubernetes is just kind of embedded and "works" (assuming the version is good :p) when you turn it on.

joshrosso avatar Jul 21 '20 14:07 joshrosso

@joshrosso Yeah, this language server originally started (3~ years ago) as a kubernetes language server and once we found out that the support for kubernetes worked well we expanded it to all of yaml but kept that schema embedded. That's why its been there for so long

JPinkney avatar Jul 21 '20 14:07 JPinkney

@JPinkney 100% makes sense!

joshrosso avatar Aug 12 '20 17:08 joshrosso