Leases view (#6378)

* Leases view

Signed-off-by: Piotr Roszatycki <piotr.roszatycki@gmail.com>

* Renamed default exports

Signed-off-by: Piotr Roszatycki <piotr.roszatycki@gmail.com>
This commit is contained in:
Piotr Roszatycki authored and GitHub committed 2022-10-11 10:40:23 -04:00
1 parent f021d9d0db
commit 51af8f8aa4
17 files changed
+428 -1

No files matched your search

+1
View File
@@ -19,6 +19,7 @@ export * from "./events.api";
export * from "./horizontal-pod-autoscaler.api";
export * from "./ingress.api";
export * from "./job.api";
export * from "./lease.api";
export * from "./limit-range.api";
export * from "./namespace.api";
export * from "./network-policy.api";
@@ -0,0 +1,22 @@
/**
* 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 { LeaseApi } from "./lease.api";
import { kubeApiInjectionToken } from "../kube-api/kube-api-injection-token";
const leaseApiInjectable = getInjectable({
id: "lease-api",
instantiate: (di) => {
assert(di.inject(storesAndApisCanBeCreatedInjectionToken), "leaseApi is only available in certain environments");
return new LeaseApi();
},
injectionToken: kubeApiInjectionToken,
});
export default leaseApiInjectable;
+56
View File
@@ -0,0 +1,56 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import type { DerivedKubeApiOptions, IgnoredKubeApiOptions } from "../kube-api";
import { KubeApi } from "../kube-api";
import type { NamespaceScopedMetadata } from "../kube-object";
import { KubeObject } from "../kube-object";
export interface LeaseSpec {
acquireTime?: string;
holderIdentity: string;
leaseDurationSeconds: number;
leaseTransitions?: number;
renewTime: string;
}
export class Lease extends KubeObject<
NamespaceScopedMetadata,
void,
LeaseSpec
> {
static readonly kind = "Lease";
static readonly namespaced = true;
static readonly apiBase = "/apis/coordination.k8s.io/v1/leases";
getAcquireTime(): string {
return this.spec.acquireTime || "";
}
getHolderIdentity(): string {
return this.spec.holderIdentity;
}
getLeaseDurationSeconds(): number {
return this.spec.leaseDurationSeconds;
}
getLeaseTransitions(): number | undefined {
return this.spec.leaseTransitions;
}
getRenewTime(): string {
return this.spec.renewTime;
}
}
export class LeaseApi extends KubeApi<Lease> {
constructor(opts: DerivedKubeApiOptions & IgnoredKubeApiOptions = {}) {
super({
...opts,
objectConstructor: Lease,
});
}
}