1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00
lens/packages/kube-object/src/specifics/ingress-class.ts
Sebastian Malton 1bf24db797 chore: Extract @k8slens/kube-object package
Signed-off-by: Sebastian Malton <sebastian@malton.name>
2023-05-02 10:11:52 -07:00

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";
}
}