redhat-developer / yaml-language-server

Language Server for YAML Files
MIT License
1.09k stars 264 forks source link

Set specific Kubernetes Schema Version #211

Open joshrosso opened 4 years ago

joshrosso commented 4 years ago

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?

apupier commented 4 years ago

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 ?

JPinkney commented 4 years ago

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

joshrosso commented 4 years ago

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

JPinkney commented 4 years ago

@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

joshrosso commented 4 years ago

@JPinkney 100% makes sense!