qvalentin / helm-ls-vscode

Extension for https://github.com/mrjosh/helm-ls
MIT License
5 stars 1 forks source link

How do I change the Kubernetes schema in use? #4

Open Makeshift opened 3 days ago

Makeshift commented 3 days ago

It seems that by default, helm-ls is using the schema for Kubernetes 1.22.4, specifically https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.22.4-standalone-strict/_definitions.json.

I've tried a few ways in my vscode settings.json to modify this, but none seem to work:

    "helm-ls.yamlls": {
        "enabled": true,
        "enabledForFilesGlob": "*.{yaml,yml}",
        "diagnosticsLimit": 50,
        "showDiagnosticsDirectly": false,
        "path": "yaml-language-server",
        "config": {
            "schemas": {
                "https://raw.githubusercontent.com/yannh/kubernetes-json-schema/refs/heads/master/v1.31.1-standalone-strict/_definitions.json": "templates/**"
            },
            "schemaStore": {
                "enable": true
            },
            "validate": true,
            "completion": true,
            "hover": true,
            "format": {
                "enable": true,
                "bracketSpacing": true,
                "proseWrap": "Preserve"
            },
            "keyOrdering": true
        }
    },

I also tried adding it to yaml-language-servers config directly:

    "yaml.schemas": {
        "https://raw.githubusercontent.com/yannh/kubernetes-json-schema/refs/heads/master/v1.31.1-standalone-strict/_definitions.json": "templates/**"
    },

Tried restarting vscode, reinstalling the extension, etc to see if I could get it to apply, but I feel like I have an incorrect config.

Makeshift commented 3 days ago

In the Helm Language Server logs, I can see the schema map I put in, but I think it's being overwritten by the default internal 'kubernetes' one:

{"level":"info","msg":"Workspace configuration: {{true *.{yaml,yml} \u003cbtree:[\u003csuper\u003e\u003c-\u003ctext:`.`\u003e-\u003e\u003cany_of:[\u003ctext:`yaml`\u003e,\u003ctext:`yml`\u003e]\u003e]\u003e yaml-language-server 50 false map[completion:true format:map[bracketSpacing:true enable:true proseWrap:Preserve] hover:true keyOrdering:true schemaStore:map[enable:false] schemas:map[https://raw.githubusercontent.com/yannh/kubernetes-json-schema/refs/heads/master/v1.31.1-standalone-strict/_definitions.json:templates/** kubernetes:templates/**] validate:true]} {values.yaml values.lint.yaml values*.yaml} info}",
qvalentin commented 2 days ago

Hi, thanks for reporting.

It seems that the additional "kubernetes" was caused by the default extension settings. I removed it.

Unfortunately I'm not sure if it will work since yaml-language-server has some problems with overwriting the k8s schema. See https://github.com/redhat-developer/yaml-language-server/issues/211. Maybe you can use one of the patches suggested in the issue?

qvalentin commented 2 days ago

I just reverted my change in this extension since it would break the default config.

I also can confirm that yaml-ls will not let you use custom schemas.

Makeshift commented 2 days ago

Ah, that's a shame. Thank you for looking into it, I'll see if I can use one of the workarounds. Feel free to close this if you don't think it needs to remain open.