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
+20
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* 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 priorityClassesRouteInjectable from "./priority-classes-route.injectable";
|
||||
import { navigateToRouteInjectionToken } from "../../../../navigate-to-route-injection-token";
|
||||
|
||||
const navigateToPriorityClassesInjectable = getInjectable({
|
||||
id: "navigate-to-priority-classes",
|
||||
|
||||
instantiate: (di) => {
|
||||
const navigateToRoute = di.inject(navigateToRouteInjectionToken);
|
||||
const route = di.inject(priorityClassesRouteInjectable);
|
||||
|
||||
return () => navigateToRoute(route);
|
||||
},
|
||||
});
|
||||
|
||||
export default navigateToPriorityClassesInjectable;
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* 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 isAllowedResourceInjectable from "../../../../../utils/is-allowed-resource.injectable";
|
||||
import { frontEndRouteInjectionToken } from "../../../../front-end-route-injection-token";
|
||||
|
||||
const priorityClassesRouteInjectable = getInjectable({
|
||||
id: "priority-classes-route",
|
||||
|
||||
instantiate: (di) => {
|
||||
const isAllowedResource = di.inject(isAllowedResourceInjectable, "priorityclasses");
|
||||
|
||||
return {
|
||||
path: "/priorityclasses",
|
||||
clusterFrame: true,
|
||||
isEnabled: isAllowedResource,
|
||||
};
|
||||
},
|
||||
|
||||
injectionToken: frontEndRouteInjectionToken,
|
||||
});
|
||||
|
||||
export default priorityClassesRouteInjectable;
|
||||
@@ -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";
|
||||
+2
-1
@@ -7,7 +7,7 @@ export type KubeResource =
|
||||
"namespaces" | "nodes" | "events" | "resourcequotas" | "services" | "limitranges" |
|
||||
"secrets" | "configmaps" | "ingresses" | "networkpolicies" | "persistentvolumeclaims" | "persistentvolumes" | "storageclasses" |
|
||||
"pods" | "daemonsets" | "deployments" | "statefulsets" | "replicasets" | "jobs" | "cronjobs" |
|
||||
"endpoints" | "customresourcedefinitions" | "horizontalpodautoscalers" | "podsecuritypolicies" | "poddisruptionbudgets" |
|
||||
"endpoints" | "customresourcedefinitions" | "horizontalpodautoscalers" | "podsecuritypolicies" | "poddisruptionbudgets" | "priorityclasses" |
|
||||
"roles" | "clusterroles" | "rolebindings" | "clusterrolebindings" | "serviceaccounts";
|
||||
|
||||
export interface KubeApiResource extends KubeApiResourceData {
|
||||
@@ -41,6 +41,7 @@ export const apiResourceRecord: Record<KubeResource, KubeApiResourceData> = {
|
||||
"pods": { kind: "Pod" },
|
||||
"poddisruptionbudgets": { kind: "PodDisruptionBudget", group: "policy" },
|
||||
"podsecuritypolicies": { kind: "PodSecurityPolicy", group: "policy" },
|
||||
"priorityclasses": { kind: "PriorityClass", group: "scheduling.k8s.io" },
|
||||
"resourcequotas": { kind: "ResourceQuota" },
|
||||
"replicasets": { kind: "ReplicaSet", group: "apps" },
|
||||
"roles": { kind: "Role", group: "rbac.authorization.k8s.io" },
|
||||
|
||||
Reference in new issue
Block a user