mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
62 lines
1.5 KiB
TypeScript
62 lines
1.5 KiB
TypeScript
import type { ClusterScopedMetadata } from "../api-types";
|
|
import { KubeObject } from "../kube-object";
|
|
|
|
export interface IngressClassParametersReference {
|
|
/**
|
|
* For example: `"k8s.example.net"`
|
|
*/
|
|
apiGroup: string;
|
|
scope: "Namespace" | "Cluster";
|
|
kind: "ClusterIngressParameter" | "IngressParameter";
|
|
name: string;
|
|
/**
|
|
* The namespace for IngressClass must be defined in `spec.parameters.namespace` instead of `metadata.namespace` (!)
|
|
*/
|
|
namespace?: string;
|
|
}
|
|
|
|
export interface IngressClassSpec {
|
|
controller: string; // "example.com/ingress-controller"
|
|
parameters?: IngressClassParametersReference;
|
|
}
|
|
|
|
export interface IngressClassStatus {}
|
|
|
|
export class IngressClass extends KubeObject<ClusterScopedMetadata, IngressClassStatus, IngressClassSpec> {
|
|
static readonly kind = "IngressClass";
|
|
|
|
static readonly namespaced = false;
|
|
|
|
static readonly apiBase = "/apis/networking.k8s.io/v1/ingressclasses";
|
|
|
|
static readonly ANNOTATION_IS_DEFAULT = "ingressclass.kubernetes.io/is-default-class";
|
|
|
|
getController(): string {
|
|
return this.spec.controller;
|
|
}
|
|
|
|
getCtrlApiGroup() {
|
|
return this.spec.parameters?.apiGroup;
|
|
}
|
|
|
|
getCtrlScope() {
|
|
return this.spec.parameters?.scope;
|
|
}
|
|
|
|
getCtrlNs() {
|
|
return this.spec.parameters?.namespace;
|
|
}
|
|
|
|
getCtrlKind() {
|
|
return this.spec.parameters?.kind;
|
|
}
|
|
|
|
getCtrlName() {
|
|
return this.spec.parameters?.name;
|
|
}
|
|
|
|
get isDefault() {
|
|
return this.metadata.annotations?.[IngressClass.ANNOTATION_IS_DEFAULT] === "true";
|
|
}
|
|
}
|