mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Adding validatingwebhookconfigs API
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
3c27fc25f0
commit
8f684cff18
@ -43,7 +43,7 @@ interface RuleWithOperations {
|
|||||||
scope?: string;
|
scope?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface MutatingWebhook {
|
export interface Webhook {
|
||||||
// The name of the webhook configuration.
|
// The name of the webhook configuration.
|
||||||
name: string;
|
name: string;
|
||||||
|
|
||||||
@ -88,7 +88,9 @@ interface MutatingWebhook {
|
|||||||
// needs to run. This should be false when the webhook only applies to resources that have
|
// needs to run. This should be false when the webhook only applies to resources that have
|
||||||
// the sideEffects field set to None. Defaults to true.
|
// the sideEffects field set to None. Defaults to true.
|
||||||
sideEffects?: string;
|
sideEffects?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface MutatingWebhook extends Webhook {
|
||||||
// reinvocationPolicy indicates whether this webhook should be called multiple times as part of a
|
// reinvocationPolicy indicates whether this webhook should be called multiple times as part of a
|
||||||
// single admission evaluation. Allowed values are "Never" and "IfNeeded"
|
// single admission evaluation. Allowed values are "Never" and "IfNeeded"
|
||||||
reinvocationPolicy?: "Never" | "IfNeeded";
|
reinvocationPolicy?: "Never" | "IfNeeded";
|
||||||
|
|||||||
@ -0,0 +1,27 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
|
import assert from "assert";
|
||||||
|
import { storesAndApisCanBeCreatedInjectionToken } from "../stores-apis-can-be-created.token";
|
||||||
|
import { kubeApiInjectionToken } from "../kube-api/kube-api-injection-token";
|
||||||
|
import loggerInjectable from "../../logger.injectable";
|
||||||
|
import maybeKubeApiInjectable from "../maybe-kube-api.injectable";
|
||||||
|
import { ValidatingWebhookConfigurationApi } from "./validating-webhook-configuration.api";
|
||||||
|
|
||||||
|
const validatingWebhookConfigurationApiInjectable = getInjectable({
|
||||||
|
id: "validating-webhook-configuration",
|
||||||
|
instantiate: (di) => {
|
||||||
|
assert(di.inject(storesAndApisCanBeCreatedInjectionToken), "validatingWebhookApi is only available in certain environments");
|
||||||
|
|
||||||
|
return new ValidatingWebhookConfigurationApi({
|
||||||
|
logger: di.inject(loggerInjectable),
|
||||||
|
maybeKubeApi: di.inject(maybeKubeApiInjectable),
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
injectionToken: kubeApiInjectionToken,
|
||||||
|
});
|
||||||
|
|
||||||
|
export default validatingWebhookConfigurationApiInjectable;
|
||||||
@ -0,0 +1,48 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
|
import type { 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";
|
||||||
|
import type { Webhook } from "./mutating-webhook-configuration.api";
|
||||||
|
import { MutatingWebhookConfiguration } from "./mutating-webhook-configuration.api";
|
||||||
|
|
||||||
|
interface ValidatingWebhook extends Webhook {
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ValidatingWebhookConfigurationData extends KubeJsonApiData<KubeObjectMetadata<KubeObjectScope.Namespace>, void, void> {
|
||||||
|
webhooks?: ValidatingWebhook[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export class ValidatingWebhookConfiguration extends KubeObject<
|
||||||
|
NamespaceScopedMetadata,
|
||||||
|
void,
|
||||||
|
void
|
||||||
|
> {
|
||||||
|
static kind = "ValidatingWebhookConfiguration";
|
||||||
|
static namespaced = false;
|
||||||
|
static apiBase = "/apis/admissionregistration.k8s.io/v1/validatingwebhookconfigurations";
|
||||||
|
|
||||||
|
webhooks?: ValidatingWebhook[];
|
||||||
|
|
||||||
|
constructor({ webhooks, ...rest }: ValidatingWebhookConfigurationData) {
|
||||||
|
super(rest);
|
||||||
|
this.webhooks = webhooks;
|
||||||
|
}
|
||||||
|
|
||||||
|
getWebhooks(): ValidatingWebhook[] {
|
||||||
|
return this.webhooks ?? [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class ValidatingWebhookConfigurationApi extends KubeApi<MutatingWebhookConfiguration> {
|
||||||
|
constructor(deps: KubeApiDependencies, opts?: DerivedKubeApiOptions) {
|
||||||
|
super(deps, {
|
||||||
|
...opts ?? {},
|
||||||
|
objectConstructor: MutatingWebhookConfiguration,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user