mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
feat: New view for PriorityClasses under Config menu (#5816)
* feat: new view for PriorityClass under Config menu Signed-off-by: Piotr Roszatycki <piotr.roszatycki@gmail.com> * Added priorityClassDetailItemInjectable Signed-off-by: Piotr Roszatycki <piotr.roszatycki@gmail.com> * Removed uneccessary defensive code Signed-off-by: Piotr Roszatycki <piotr.roszatycki@gmail.com>
This commit is contained in:
1 parent
70105a6ef2
commit
f4b7fea54a
24 files changed
+470
-2
No files matched your search
@@ -29,6 +29,7 @@ export * from "./pod.api";
|
||||
export * from "./pod-disruption-budget.api";
|
||||
export * from "./pod-metrics.api";
|
||||
export * from "./pod-security-policy.api";
|
||||
export * from "./priority-class.api";
|
||||
export * from "./replica-set.api";
|
||||
export * from "./resource-quota.api";
|
||||
export * from "./role.api";
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* 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 { PriorityClassApi } from "./priority-class.api";
|
||||
|
||||
const priorityClassApiInjectable = getInjectable({
|
||||
id: "priority-class-api",
|
||||
instantiate: (di) => {
|
||||
assert(di.inject(storesAndApisCanBeCreatedInjectionToken), "PriorityClassApi is only available in certain environments");
|
||||
|
||||
return new PriorityClassApi();
|
||||
},
|
||||
});
|
||||
|
||||
export default priorityClassApiInjectable;
|
||||
@@ -0,0 +1,66 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import type { DerivedKubeApiOptions } from "../kube-api";
|
||||
import { KubeApi } from "../kube-api";
|
||||
import type { KubeJsonApiData } from "../kube-json-api";
|
||||
import type { ClusterScopedMetadata, KubeObjectMetadata, KubeObjectScope } from "../kube-object";
|
||||
import { KubeObject } from "../kube-object";
|
||||
import type { PreemptionPolicy } from "./types/preemption-policy";
|
||||
|
||||
export interface PriorityClassData extends KubeJsonApiData<KubeObjectMetadata<KubeObjectScope.Cluster>, void, void> {
|
||||
description?: string;
|
||||
globalDefault?: boolean;
|
||||
preemptionPolicy?: PreemptionPolicy;
|
||||
value: number;
|
||||
}
|
||||
|
||||
export class PriorityClass extends KubeObject<
|
||||
ClusterScopedMetadata,
|
||||
void,
|
||||
void
|
||||
> {
|
||||
static readonly kind = "PriorityClass";
|
||||
static readonly namespaced = false;
|
||||
static readonly apiBase = "/apis/scheduling.k8s.io/v1/priorityclasses";
|
||||
|
||||
description?: string;
|
||||
globalDefault?: boolean;
|
||||
preemptionPolicy?: PreemptionPolicy;
|
||||
value?: number;
|
||||
|
||||
constructor({ description, globalDefault, preemptionPolicy, value, ...rest }: PriorityClassData) {
|
||||
super(rest);
|
||||
this.description = description;
|
||||
this.globalDefault = globalDefault;
|
||||
this.preemptionPolicy = preemptionPolicy;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
getDescription() {
|
||||
return this.description || "";
|
||||
}
|
||||
|
||||
getGlobalDefault() {
|
||||
return (this.globalDefault || false).toString();
|
||||
}
|
||||
|
||||
getPreemptionPolicy() {
|
||||
return this.preemptionPolicy || "PreemptLowerPriority";
|
||||
}
|
||||
|
||||
getValue() {
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
|
||||
export class PriorityClassApi extends KubeApi<PriorityClass, PriorityClassData> {
|
||||
constructor(opts: DerivedKubeApiOptions = {}) {
|
||||
super({
|
||||
objectConstructor: PriorityClass,
|
||||
...opts,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
export type PreemptionPolicy = "Never" | "PreemptLowerPriority";
|
||||
Reference in new issue
Block a user