From 02e24735b850771412a66257f087c7fc3ba77e44 Mon Sep 17 00:00:00 2001 From: Alex Andreev Date: Fri, 7 Apr 2023 10:51:58 +0300 Subject: [PATCH] Fix webhook field scoping Signed-off-by: Alex Andreev --- .../mutating-webhook-configuration.api.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/core/src/common/k8s-api/endpoints/mutating-webhook-configuration.api.ts b/packages/core/src/common/k8s-api/endpoints/mutating-webhook-configuration.api.ts index 6434a31cc0..6d33374ba4 100644 --- a/packages/core/src/common/k8s-api/endpoints/mutating-webhook-configuration.api.ts +++ b/packages/core/src/common/k8s-api/endpoints/mutating-webhook-configuration.api.ts @@ -2,10 +2,11 @@ * Copyright (c) OpenLens Authors. All rights reserved. * Licensed under MIT License. See LICENSE in root directory for more information. */ -import type { LabelSelector, NamespaceScopedMetadata } from "../kube-object"; +import type { LabelSelector, NamespaceScopedMetadata, KubeObjectMetadata, KubeObjectScope } from "../kube-object"; import { KubeObject } from "../kube-object"; import type { DerivedKubeApiOptions, KubeApiDependencies } from "../kube-api"; import { KubeApi } from "../kube-api"; +import type { KubeJsonApiData } from "../kube-json-api"; interface MutatingWebhookConfigurationStatus { // The latest generation observed by the webhook. @@ -203,6 +204,10 @@ interface MutatingWebhookConfigurationSpec { reinvocationPolicy?: string; } +interface MutatingWebhookConfigurationData extends KubeJsonApiData, MutatingWebhookConfigurationStatus, MutatingWebhookConfigurationSpec> { + webhooks?: MutatingWebhook[]; +} + export class MutatingWebhookConfiguration extends KubeObject< NamespaceScopedMetadata, MutatingWebhookConfigurationStatus, @@ -212,8 +217,15 @@ export class MutatingWebhookConfiguration extends KubeObject< static namespaced = true; static apiBase = "/apis/admissionregistration.k8s.io/v1/mutatingwebhookconfigurations"; + webhooks?: MutatingWebhook[]; + + constructor({ webhooks, ...rest }: MutatingWebhookConfigurationData) { + super(rest); + this.webhooks = webhooks; + } + getWebhooks(): MutatingWebhook[] { - return this.spec?.webhooks ?? []; + return this.webhooks ?? []; } getClientConfig(serviceName: string, serviceNamespace: string): WebhookClientConfig | undefined {