From 679dbee73cbe281f957e66be10d2a08dfe13c4d9 Mon Sep 17 00:00:00 2001 From: Thibault Gagnaux Date: Thu, 23 Mar 2023 13:10:57 +0100 Subject: [PATCH] feat: support multiple custom kubernetes urls --- package.json | 5 +++++ src/extension.ts | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/package.json b/package.json index 6e024b9d..1c7496ef 100644 --- a/package.json +++ b/package.json @@ -166,6 +166,11 @@ "default": [], "description": "Custom tags for the parser to use" }, + "yaml.kubernetesSchemaURLs": { + "type": "array", + "default": [], + "description": "URLs to Kubernetes schemas" + }, "yaml.schemaStore.enable": { "type": "boolean", "default": true, diff --git a/src/extension.ts b/src/extension.ts index df025f7c..f6a1dea0 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -74,6 +74,12 @@ namespace DynamicCustomSchemaRequestRegistration { export const type: NotificationType<{}> = new NotificationType('yaml/registerCustomSchemaRequest'); } +// eslint-disable-next-line @typescript-eslint/no-namespace +export namespace KubernetesSchemaURLsNotification { + // eslint-disable-next-line @typescript-eslint/ban-types + export const type: NotificationType = new NotificationType('yaml/kubernetesSchemaURLs'); +} + // eslint-disable-next-line @typescript-eslint/no-namespace namespace ResultLimitReachedNotification { // eslint-disable-next-line @typescript-eslint/ban-types @@ -161,6 +167,7 @@ export function startClient( client.sendNotification(SchemaAssociationNotification.type, getSchemaAssociations()); findConflicts(); }); + client.sendNotification(KubernetesSchemaURLsNotification.type, getKubernetesSchemaURLs()); // Tell the server that the client is ready to provide custom schema content client.sendNotification(DynamicCustomSchemaRequestRegistration.type); // Tell the server that the client supports schema requests sent directly to it @@ -229,6 +236,10 @@ function findConflicts(): void { } } +function getKubernetesSchemaURLs(): string[] { + return workspace.getConfiguration('yaml').get('kubernetesSchemaURLs') || []; +} + function getSchemaAssociations(): ISchemaAssociation[] { const associations: ISchemaAssociation[] = []; extensions.all.forEach((extension) => {