mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
chore: Extract @k8slens/kube-object package
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
1 parent
4eb15e1a04
commit
9969b5f2b8
466 files changed
+6838
-6375
No files matched your search
@@ -0,0 +1,61 @@
|
||||
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";
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user