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
576373b16b
commit
1bf24db797
466 files changed
+6838
-6375
No files matched your search
+2
-2
@@ -5,9 +5,9 @@
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { reaction } from "mobx";
|
||||
import { customResourceDefinitionApiInjectionToken } from "../../../common/k8s-api/api-manager/crd-api-token";
|
||||
import type { CustomResourceDefinition } from "../../../common/k8s-api/endpoints";
|
||||
import type { CustomResourceDefinition } from "@k8slens/kube-object";
|
||||
import { KubeApi } from "../../../common/k8s-api/kube-api";
|
||||
import { KubeObject } from "../../../common/k8s-api/kube-object";
|
||||
import { KubeObject } from "@k8slens/kube-object";
|
||||
import maybeKubeApiInjectable from "../../../common/k8s-api/maybe-kube-api.injectable";
|
||||
import loggerInjectable from "../../../common/logger.injectable";
|
||||
import { injectableDifferencingRegistratorWith } from "../../../common/utils/registrator-helper";
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
import type { CronJobStore } from "../workloads-cronjobs/store";
|
||||
import cronJobStoreInjectable from "../workloads-cronjobs/store.injectable";
|
||||
import { CronJob } from "../../../common/k8s-api/endpoints";
|
||||
import { CronJob } from "@k8slens/kube-object";
|
||||
import storesAndApisCanBeCreatedInjectable from "../../stores-apis-can-be-created.injectable";
|
||||
import { getDiForUnitTesting } from "../../getDiForUnitTesting";
|
||||
import directoryForUserDataInjectable from "../../../common/app-paths/directory-for-user-data/directory-for-user-data.injectable";
|
||||
|
||||
@@ -7,7 +7,7 @@ import { observable } from "mobx";
|
||||
import type { DaemonSetStore } from "../workloads-daemonsets/store";
|
||||
import daemonSetStoreInjectable from "../workloads-daemonsets/store.injectable";
|
||||
import podStoreInjectable from "../workloads-pods/store.injectable";
|
||||
import { DaemonSet, Pod } from "../../../common/k8s-api/endpoints";
|
||||
import { DaemonSet, Pod } from "@k8slens/kube-object";
|
||||
import storesAndApisCanBeCreatedInjectable from "../../stores-apis-can-be-created.injectable";
|
||||
import { getDiForUnitTesting } from "../../getDiForUnitTesting";
|
||||
import directoryForUserDataInjectable from "../../../common/app-paths/directory-for-user-data/directory-for-user-data.injectable";
|
||||
|
||||
@@ -7,8 +7,8 @@ import { observable } from "mobx";
|
||||
import type { DeploymentStore } from "../workloads-deployments/store";
|
||||
import deploymentStoreInjectable from "../workloads-deployments/store.injectable";
|
||||
import podStoreInjectable from "../workloads-pods/store.injectable";
|
||||
import type { PodSpec } from "../../../common/k8s-api/endpoints";
|
||||
import { Deployment, Pod } from "../../../common/k8s-api/endpoints";
|
||||
import type { PodSpec } from "@k8slens/kube-object";
|
||||
import { Deployment, Pod } from "@k8slens/kube-object";
|
||||
import storesAndApisCanBeCreatedInjectable from "../../stores-apis-can-be-created.injectable";
|
||||
import { getDiForUnitTesting } from "../../getDiForUnitTesting";
|
||||
import directoryForUserDataInjectable from "../../../common/app-paths/directory-for-user-data/directory-for-user-data.injectable";
|
||||
|
||||
@@ -7,7 +7,7 @@ import { observable } from "mobx";
|
||||
import type { JobStore } from "../workloads-jobs/store";
|
||||
import jobStoreInjectable from "../workloads-jobs/store.injectable";
|
||||
import podStoreInjectable from "../workloads-pods/store.injectable";
|
||||
import { Job, Pod } from "../../../common/k8s-api/endpoints";
|
||||
import { Job, Pod } from "@k8slens/kube-object";
|
||||
import storesAndApisCanBeCreatedInjectable from "../../stores-apis-can-be-created.injectable";
|
||||
import { getDiForUnitTesting } from "../../getDiForUnitTesting";
|
||||
import directoryForUserDataInjectable from "../../../common/app-paths/directory-for-user-data/directory-for-user-data.injectable";
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import { formatNodeTaint } from "../../../common/k8s-api/endpoints";
|
||||
import { formatNodeTaint } from "@k8slens/kube-object";
|
||||
|
||||
describe("formatNodeTaint tests", () => {
|
||||
it("should use value if defined", () => {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import { Pod } from "../../../common/k8s-api/endpoints";
|
||||
import { Pod } from "@k8slens/kube-object";
|
||||
import type { PodStore } from "../workloads-pods/store";
|
||||
import podStoreInjectable from "../workloads-pods/store.injectable";
|
||||
import storesAndApisCanBeCreatedInjectable from "../../stores-apis-can-be-created.injectable";
|
||||
|
||||
@@ -7,7 +7,7 @@ import { observable } from "mobx";
|
||||
import podStoreInjectable from "../workloads-pods/store.injectable";
|
||||
import replicasetsStoreInjectable from "../workloads-replicasets/store.injectable";
|
||||
import type { ReplicaSetStore } from "../workloads-replicasets/store";
|
||||
import { ReplicaSet, Pod } from "../../../common/k8s-api/endpoints";
|
||||
import { ReplicaSet, Pod } from "@k8slens/kube-object";
|
||||
import storesAndApisCanBeCreatedInjectable from "../../stores-apis-can-be-created.injectable";
|
||||
import { getDiForUnitTesting } from "../../getDiForUnitTesting";
|
||||
import directoryForUserDataInjectable from "../../../common/app-paths/directory-for-user-data/directory-for-user-data.injectable";
|
||||
|
||||
@@ -7,7 +7,7 @@ import { observable } from "mobx";
|
||||
import podStoreInjectable from "../workloads-pods/store.injectable";
|
||||
import type { StatefulSetStore } from "../workloads-statefulsets/store";
|
||||
import statefulSetStoreInjectable from "../workloads-statefulsets/store.injectable";
|
||||
import { StatefulSet, Pod } from "../../../common/k8s-api/endpoints";
|
||||
import { StatefulSet, Pod } from "@k8slens/kube-object";
|
||||
import storesAndApisCanBeCreatedInjectable from "../../stores-apis-can-be-created.injectable";
|
||||
import { getDiForUnitTesting } from "../../getDiForUnitTesting";
|
||||
import directoryForUserDataInjectable from "../../../common/app-paths/directory-for-user-data/directory-for-user-data.injectable";
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
import styles from "../catalog.module.scss";
|
||||
import React from "react";
|
||||
import type { RegisteredAdditionalCategoryColumn } from "../custom-category-columns";
|
||||
import { KubeObject } from "../../../../common/k8s-api/kube-object";
|
||||
import { KubeObject } from "@k8slens/kube-object";
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import getLabelBadgesInjectable from "../get-label-badges.injectable";
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import React from "react";
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import type { CatalogEntity } from "../../api/catalog-entity";
|
||||
import searchUrlPageParamInjectable from "../input/search-url-page-param.injectable";
|
||||
import { KubeObject } from "../../../common/k8s-api/kube-object";
|
||||
import { KubeObject } from "@k8slens/kube-object";
|
||||
import { Badge } from "../badge";
|
||||
|
||||
export type GetLabelBadges = (entity: CatalogEntity, onClick?: (evt: React.MouseEvent<any, MouseEvent>) => void) => JSX.Element[];
|
||||
|
||||
@@ -13,7 +13,6 @@ import { Icon } from "../icon";
|
||||
import { SubHeader } from "../layout/sub-header";
|
||||
import { Table, TableCell, TableHead, TableRow } from "../table";
|
||||
import { cssNames, prevDefault } from "@k8slens/utilities";
|
||||
import type { ItemObject } from "@k8slens/list-layout";
|
||||
import { Spinner } from "../spinner";
|
||||
import type { ApiManager } from "../../../common/k8s-api/api-manager";
|
||||
import { KubeObjectAge } from "../kube-object/age";
|
||||
@@ -34,7 +33,9 @@ export interface ClusterIssuesProps {
|
||||
className?: string;
|
||||
}
|
||||
|
||||
interface Warning extends ItemObject {
|
||||
interface Warning {
|
||||
getId: () => string;
|
||||
getName: () => string;
|
||||
kind: string;
|
||||
message: string | undefined;
|
||||
selfLink: string;
|
||||
@@ -70,8 +71,8 @@ class NonInjectedClusterIssues extends React.Component<ClusterIssuesProps & Depe
|
||||
node.getWarningConditions()
|
||||
.map(({ message }) => ({
|
||||
selfLink: node.selfLink,
|
||||
getId: node.getId,
|
||||
getName: node.getName,
|
||||
getId: () => node.getId(),
|
||||
getName: () => node.getName(),
|
||||
kind: node.kind,
|
||||
message,
|
||||
renderAge: () => <KubeObjectAge key="age" object={node} />,
|
||||
|
||||
+9
-5
@@ -3,10 +3,11 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import { action, observable, reaction, when, makeObservable } from "mobx";
|
||||
import { action, observable, reaction, when, makeObservable, runInAction } from "mobx";
|
||||
import type { KubeObjectStoreDependencies } from "../../../../common/k8s-api/kube-object.store";
|
||||
import { KubeObjectStore } from "../../../../common/k8s-api/kube-object.store";
|
||||
import type { Cluster, ClusterApi } from "../../../../common/k8s-api/endpoints";
|
||||
import type { ClusterApi } from "../../../../common/k8s-api/endpoints";
|
||||
import type { Cluster } from "@k8slens/kube-object";
|
||||
import type { StorageLayer } from "../../../utils/storage-helper";
|
||||
import type { NodeStore } from "../../nodes/store";
|
||||
import type { ClusterMetricData, RequestClusterMetricsByNodeNames } from "../../../../common/k8s-api/endpoints/metrics.api/request-cluster-metrics-by-node-names.injectable";
|
||||
@@ -72,7 +73,7 @@ export class ClusterOverviewStore extends KubeObjectStore<Cluster, ClusterApi> i
|
||||
reaction(() => this.metricNodeRole, () => {
|
||||
if (this.metrics) {
|
||||
this.resetMetrics();
|
||||
this.loadMetrics();
|
||||
void this.loadMetrics();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -85,13 +86,16 @@ export class ClusterOverviewStore extends KubeObjectStore<Cluster, ClusterApi> i
|
||||
});
|
||||
}
|
||||
|
||||
@action
|
||||
async loadMetrics(params?: RequestMetricsParams) {
|
||||
await when(() => this.dependencies.nodeStore.isLoaded);
|
||||
const { masterNodes, workerNodes } = this.dependencies.nodeStore;
|
||||
const nodes = this.metricNodeRole === MetricNodeRole.MASTER && masterNodes.length ? masterNodes : workerNodes;
|
||||
|
||||
this.metrics = await this.dependencies.requestClusterMetricsByNodeNames(nodes.map(node => node.getName()), params);
|
||||
const metrics = await this.dependencies.requestClusterMetricsByNodeNames(nodes.map(node => node.getName()), params);
|
||||
|
||||
runInAction(() => {
|
||||
this.metrics = metrics;
|
||||
});
|
||||
}
|
||||
|
||||
getMetricsValues(source: Partial<ClusterMetricData>): [number, string][] {
|
||||
|
||||
+3
-1
@@ -6,7 +6,7 @@
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import type { IComputedValue } from "mobx";
|
||||
import { computed } from "mobx";
|
||||
import type { CustomResourceDefinition } from "../../../../common/k8s-api/endpoints";
|
||||
import type { CustomResourceDefinition } from "@k8slens/kube-object";
|
||||
import customResourceDefinitionsInjectable from "../../custom-resources/custom-resources.injectable";
|
||||
import type { LensRendererExtension } from "../../../../extensions/lens-renderer-extension";
|
||||
import rendererExtensionsInjectable from "../../../../extensions/renderer-extensions.injectable";
|
||||
@@ -33,6 +33,8 @@ const instantiateRegisteredCommands = ({ extensions, customResourceDefinitions,
|
||||
];
|
||||
|
||||
for (const { scope, isActive = () => true, ...command } of commands) {
|
||||
void scope;
|
||||
|
||||
if (!result.has(command.id)) {
|
||||
result.set(command.id, { ...command, isActive });
|
||||
}
|
||||
|
||||
+9
-9
@@ -7,7 +7,7 @@ import React from "react";
|
||||
import directoryForKubeConfigsInjectable from "../../../common/app-paths/directory-for-kube-configs/directory-for-kube-configs.injectable";
|
||||
import directoryForUserDataInjectable from "../../../common/app-paths/directory-for-user-data/directory-for-user-data.injectable";
|
||||
import { Cluster } from "../../../common/cluster/cluster";
|
||||
import { HorizontalPodAutoscaler, HpaMetricType } from "../../../common/k8s-api/endpoints";
|
||||
import { HorizontalPodAutoscaler } from "@k8slens/kube-object";
|
||||
import hostedClusterInjectable from "../../cluster-frame-context/hosted-cluster.injectable";
|
||||
import { getDiForUnitTesting } from "../../getDiForUnitTesting";
|
||||
import storesAndApisCanBeCreatedInjectable from "../../stores-apis-can-be-created.injectable";
|
||||
@@ -115,7 +115,7 @@ describe("<HpaDetails/>", () => {
|
||||
...hpaV2.spec,
|
||||
metrics: [
|
||||
{
|
||||
type: HpaMetricType.ContainerResource,
|
||||
type: "ContainerResource",
|
||||
containerResource: {
|
||||
name: "cpu",
|
||||
container: "nginx",
|
||||
@@ -145,7 +145,7 @@ describe("<HpaDetails/>", () => {
|
||||
...hpaV2.spec,
|
||||
metrics: [
|
||||
{
|
||||
type: HpaMetricType.Resource,
|
||||
type: "Resource",
|
||||
resource: {
|
||||
name: "cpu",
|
||||
target: {
|
||||
@@ -174,7 +174,7 @@ describe("<HpaDetails/>", () => {
|
||||
...hpaV2.spec,
|
||||
metrics: [
|
||||
{
|
||||
type: HpaMetricType.Pods,
|
||||
type: "Pods",
|
||||
pods: {
|
||||
metric: {
|
||||
name: "packets-per-second",
|
||||
@@ -205,7 +205,7 @@ describe("<HpaDetails/>", () => {
|
||||
...hpaV2.spec,
|
||||
metrics: [
|
||||
{
|
||||
type: HpaMetricType.Pods,
|
||||
type: "Pods",
|
||||
pods: {
|
||||
metricName: "packets-per-second",
|
||||
},
|
||||
@@ -230,7 +230,7 @@ describe("<HpaDetails/>", () => {
|
||||
...hpaV2.spec,
|
||||
metrics: [
|
||||
{
|
||||
type: HpaMetricType.Object,
|
||||
type: "Object",
|
||||
object: {
|
||||
metric: {
|
||||
name: "requests-per-second",
|
||||
@@ -266,7 +266,7 @@ describe("<HpaDetails/>", () => {
|
||||
...hpaV2.spec,
|
||||
metrics: [
|
||||
{
|
||||
type: HpaMetricType.Object,
|
||||
type: "Object",
|
||||
object: {
|
||||
metricName: "requests-per-second",
|
||||
},
|
||||
@@ -291,7 +291,7 @@ describe("<HpaDetails/>", () => {
|
||||
...hpaV2.spec,
|
||||
metrics: [
|
||||
{
|
||||
type: HpaMetricType.External,
|
||||
type: "External",
|
||||
external: {
|
||||
metric: {
|
||||
name: "queue_messages_ready",
|
||||
@@ -325,7 +325,7 @@ describe("<HpaDetails/>", () => {
|
||||
...hpaV2.spec,
|
||||
metrics: [
|
||||
{
|
||||
type: HpaMetricType.External,
|
||||
type: "External",
|
||||
external: {
|
||||
metricName: "queue_messages_ready",
|
||||
metricSelector: {
|
||||
|
||||
@@ -12,8 +12,8 @@ import { DrawerItem, DrawerTitle } from "../drawer";
|
||||
import { Badge } from "../badge";
|
||||
import type { KubeObjectDetailsProps } from "../kube-object-details";
|
||||
import { cssNames } from "@k8slens/utilities";
|
||||
import type { HorizontalPodAutoscalerMetricSpec, HorizontalPodAutoscalerMetricTarget } from "../../../common/k8s-api/endpoints/horizontal-pod-autoscaler.api";
|
||||
import { HorizontalPodAutoscaler, HpaMetricType } from "../../../common/k8s-api/endpoints/horizontal-pod-autoscaler.api";
|
||||
import type { HorizontalPodAutoscalerMetricSpec, HorizontalPodAutoscalerMetricTarget } from "@k8slens/kube-object";
|
||||
import { HorizontalPodAutoscaler } from "@k8slens/kube-object";
|
||||
import { Table, TableCell, TableHead, TableRow } from "../table";
|
||||
import type { ApiManager } from "../../../common/k8s-api/api-manager";
|
||||
import type { Logger } from "../../../common/logger";
|
||||
@@ -63,18 +63,18 @@ class NonInjectedHorizontalPodAutoscalerDetails extends React.Component<HpaDetai
|
||||
const metricName = getMetricName(metric);
|
||||
|
||||
switch (metric?.type) {
|
||||
case HpaMetricType.ContainerResource:
|
||||
case "ContainerResource":
|
||||
|
||||
// fallthrough
|
||||
case HpaMetricType.Resource: {
|
||||
case "Resource": {
|
||||
const metricSpec = metric.resource ?? metric.containerResource;
|
||||
|
||||
return `Resource ${metricSpec.name} on Pods`;
|
||||
}
|
||||
case HpaMetricType.Pods:
|
||||
return `${metricName} on Pods`;
|
||||
case "Pods":
|
||||
return `${metricName ?? ""} on Pods`;
|
||||
|
||||
case HpaMetricType.Object: {
|
||||
case "Object": {
|
||||
return (
|
||||
<>
|
||||
{metricName}
|
||||
@@ -83,8 +83,8 @@ class NonInjectedHorizontalPodAutoscalerDetails extends React.Component<HpaDetai
|
||||
</>
|
||||
);
|
||||
}
|
||||
case HpaMetricType.External:
|
||||
return `${metricName} on ${JSON.stringify(metric.external.metricSelector ?? metric.external.metric?.selector)}`;
|
||||
case "External":
|
||||
return `${metricName ?? ""} on ${JSON.stringify(metric.external.metricSelector ?? metric.external.metric?.selector)}`;
|
||||
default:
|
||||
return hpa.spec?.targetCPUUtilizationPercentage ? "CPU Utilization percentage" : "unknown";
|
||||
}
|
||||
|
||||
+6
-7
@@ -3,8 +3,7 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import { HpaMetricType } from "../../../common/k8s-api/endpoints";
|
||||
import type { LabelSelector } from "../../../common/k8s-api/kube-object";
|
||||
import type { HpaMetricType, LabelSelector } from "@k8slens/kube-object";
|
||||
|
||||
type MetricNames = Partial<Record<"resource" | "pods" | "object" | "external" | "containerResource", {
|
||||
name?: string;
|
||||
@@ -21,15 +20,15 @@ interface Metric extends MetricNames {
|
||||
|
||||
export function getMetricName(metric: Metric | undefined): string | undefined {
|
||||
switch (metric?.type) {
|
||||
case HpaMetricType.Resource:
|
||||
case "Resource":
|
||||
return metric.resource?.name;
|
||||
case HpaMetricType.Pods:
|
||||
case "Pods":
|
||||
return metric.pods?.metricName || metric.pods?.metric?.name;
|
||||
case HpaMetricType.Object:
|
||||
case "Object":
|
||||
return metric.object?.metricName || metric.object?.metric?.name;
|
||||
case HpaMetricType.External:
|
||||
case "External":
|
||||
return metric.external?.metricName || metric.external?.metric?.name;
|
||||
case HpaMetricType.ContainerResource:
|
||||
case "ContainerResource":
|
||||
return metric.containerResource?.name;
|
||||
default:
|
||||
return undefined;
|
||||
|
||||
+6
-7
@@ -3,8 +3,7 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import type { HorizontalPodAutoscaler, HorizontalPodAutoscalerMetricSpec, HorizontalPodAutoscalerMetricStatus } from "../../../common/k8s-api/endpoints";
|
||||
import { HpaMetricType } from "../../../common/k8s-api/endpoints";
|
||||
import type { HorizontalPodAutoscaler, HorizontalPodAutoscalerMetricSpec, HorizontalPodAutoscalerMetricStatus } from "@k8slens/kube-object";
|
||||
import { getMetricName } from "./get-metric-name";
|
||||
import { HorizontalPodAutoscalerV1MetricParser } from "./metric-parser-v1";
|
||||
import { HorizontalPodAutoscalerV2MetricParser } from "./metric-parser-v2";
|
||||
@@ -48,15 +47,15 @@ const getHorizontalPodAutoscalerMetrics = getInjectable({
|
||||
|
||||
function getMetricValues<Type extends Parser>(parser: Type, current: HorizontalPodAutoscalerMetricStatus | undefined, target: HorizontalPodAutoscalerMetricSpec) {
|
||||
switch (target.type) {
|
||||
case HpaMetricType.Resource:
|
||||
case "Resource":
|
||||
return parser.getResource({ current: current?.resource, target: target.resource });
|
||||
case HpaMetricType.Pods:
|
||||
case "Pods":
|
||||
return parser.getPods({ current: current?.pods, target: target.pods });
|
||||
case HpaMetricType.Object:
|
||||
case "Object":
|
||||
return parser.getObject({ current: current?.object, target: target.object });
|
||||
case HpaMetricType.External:
|
||||
case "External":
|
||||
return parser.getExternal({ current: current?.external, target: target.external });
|
||||
case HpaMetricType.ContainerResource:
|
||||
case "ContainerResource":
|
||||
return parser.getContainerResource({ current: current?.containerResource, target: target.containerResource });
|
||||
default:
|
||||
return {};
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ import "./list-view.scss";
|
||||
import React from "react";
|
||||
import { observer } from "mobx-react";
|
||||
import { KubeObjectListLayout } from "../kube-object-list-layout";
|
||||
import type { HorizontalPodAutoscaler } from "../../../common/k8s-api/endpoints/horizontal-pod-autoscaler.api";
|
||||
import type { HorizontalPodAutoscaler } from "@k8slens/kube-object";
|
||||
import { Badge } from "../badge";
|
||||
import { cssNames } from "@k8slens/utilities";
|
||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
||||
|
||||
+5
-5
@@ -2,7 +2,7 @@
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import type { MetricCurrentTarget, V2Beta1ContainerResourceMetricSource, V2Beta1ContainerResourceMetricStatus, V2Beta1ExternalMetricSource, V2Beta1ExternalMetricStatus, V2Beta1ObjectMetricSource, V2Beta1ObjectMetricStatus, V2Beta1PodsMetricSource, V2Beta1PodsMetricStatus, V2Beta1ResourceMetricSource, V2Beta1ResourceMetricStatus } from "../../../common/k8s-api/endpoints";
|
||||
import type { MetricCurrentTarget, V2Beta1ContainerResourceMetricSource, V2Beta1ContainerResourceMetricStatus, V2Beta1ExternalMetricSource, V2Beta1ExternalMetricStatus, V2Beta1ObjectMetricSource, V2Beta1ObjectMetricStatus, V2Beta1PodsMetricSource, V2Beta1PodsMetricStatus, V2Beta1ResourceMetricSource, V2Beta1ResourceMetricStatus } from "@k8slens/kube-object";
|
||||
|
||||
export class HorizontalPodAutoscalerV1MetricParser {
|
||||
public getResource({ current, target }: { current: V2Beta1ResourceMetricStatus | undefined; target: V2Beta1ResourceMetricSource }): MetricCurrentTarget {
|
||||
@@ -19,14 +19,14 @@ export class HorizontalPodAutoscalerV1MetricParser {
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public getPods({ current, target }: { current: V2Beta1PodsMetricStatus | undefined; target: V2Beta1PodsMetricSource }): MetricCurrentTarget {
|
||||
return {
|
||||
current: current?.currentAverageValue,
|
||||
target: target?.targetAverageValue,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public getObject({ current, target }: { current: V2Beta1ObjectMetricStatus | undefined; target: V2Beta1ObjectMetricSource }): MetricCurrentTarget {
|
||||
return {
|
||||
current: (
|
||||
@@ -39,7 +39,7 @@ export class HorizontalPodAutoscalerV1MetricParser {
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public getExternal({ current, target }: { current: V2Beta1ExternalMetricStatus | undefined; target: V2Beta1ExternalMetricSource }): MetricCurrentTarget {
|
||||
return {
|
||||
current: (
|
||||
@@ -52,7 +52,7 @@ export class HorizontalPodAutoscalerV1MetricParser {
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public getContainerResource({ current, target }: { current: V2Beta1ContainerResourceMetricStatus | undefined; target: V2Beta1ContainerResourceMetricSource }): MetricCurrentTarget {
|
||||
return {
|
||||
current: (
|
||||
|
||||
+7
-7
@@ -2,7 +2,7 @@
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import type { MetricCurrentTarget, V2ContainerResourceMetricSource, V2ContainerResourceMetricStatus, V2ExternalMetricSource, V2ExternalMetricStatus, V2ObjectMetricSource, V2ObjectMetricStatus, V2PodsMetricSource, V2PodsMetricStatus, V2ResourceMetricSource, V2ResourceMetricStatus } from "../../../common/k8s-api/endpoints";
|
||||
import type { MetricCurrentTarget, V2ContainerResourceMetricSource, V2ContainerResourceMetricStatus, V2ExternalMetricSource, V2ExternalMetricStatus, V2ObjectMetricSource, V2ObjectMetricStatus, V2PodsMetricSource, V2PodsMetricStatus, V2ResourceMetricSource, V2ResourceMetricStatus } from "@k8slens/kube-object";
|
||||
|
||||
export class HorizontalPodAutoscalerV2MetricParser {
|
||||
public getResource({ current, target }: { current: V2ResourceMetricStatus | undefined; target: V2ResourceMetricSource }): MetricCurrentTarget {
|
||||
@@ -17,14 +17,14 @@ export class HorizontalPodAutoscalerV2MetricParser {
|
||||
: target?.target?.averageValue,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public getPods({ current, target }: { current: V2PodsMetricStatus | undefined; target: V2PodsMetricSource }): MetricCurrentTarget {
|
||||
return {
|
||||
current: current?.current?.averageValue,
|
||||
target: target?.target?.averageValue,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public getObject({ current, target }: { current: V2ObjectMetricStatus | undefined; target: V2ObjectMetricSource }): MetricCurrentTarget {
|
||||
return {
|
||||
current: (
|
||||
@@ -37,7 +37,7 @@ export class HorizontalPodAutoscalerV2MetricParser {
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public getExternal({ current, target }: { current: V2ExternalMetricStatus | undefined; target: V2ExternalMetricSource }): MetricCurrentTarget {
|
||||
const currentAverage = current?.current?.averageValue ? `${current?.current?.averageValue} (avg)` : undefined;
|
||||
const targetAverage = target?.target?.averageValue ? `${target?.target?.averageValue} (avg)` : undefined;
|
||||
@@ -53,16 +53,16 @@ export class HorizontalPodAutoscalerV2MetricParser {
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public getContainerResource({ current, target }: { current: V2ContainerResourceMetricStatus | undefined; target: V2ContainerResourceMetricSource }): MetricCurrentTarget {
|
||||
return {
|
||||
current: (
|
||||
current?.current?.averageValue
|
||||
?? current?.current?.averageUtilization ? `${current?.current?.averageUtilization}%` : undefined
|
||||
?? (current?.current?.averageUtilization ? `${current.current.averageUtilization}%` : undefined)
|
||||
),
|
||||
target: (
|
||||
target?.target?.averageValue
|
||||
?? target?.target?.averageUtilization ? `${target?.target?.averageUtilization}%` : undefined
|
||||
?? (target?.target?.averageUtilization ? `${target.target.averageUtilization}%` : undefined)
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
+47
-47
@@ -5,7 +5,7 @@
|
||||
import type { DiContainer } from "@ogre-tools/injectable";
|
||||
import getHorizontalPodAutoscalerMetrics from "./get-metrics.injectable";
|
||||
import { getDiForUnitTesting } from "../../getDiForUnitTesting";
|
||||
import { HorizontalPodAutoscaler, HpaMetricType } from "../../../common/k8s-api/endpoints";
|
||||
import { HorizontalPodAutoscaler } from "@k8slens/kube-object";
|
||||
|
||||
const hpaV2 = {
|
||||
apiVersion: "autoscaling/v2",
|
||||
@@ -71,7 +71,7 @@ describe("getHorizontalPodAutoscalerMetrics", () => {
|
||||
...hpaV2.spec,
|
||||
metrics: [
|
||||
{
|
||||
type: HpaMetricType.Resource,
|
||||
type: "Resource",
|
||||
resource: {
|
||||
name: "cpu",
|
||||
target: {
|
||||
@@ -94,7 +94,7 @@ describe("getHorizontalPodAutoscalerMetrics", () => {
|
||||
...hpaV2.spec,
|
||||
metrics: [
|
||||
{
|
||||
type: HpaMetricType.Resource,
|
||||
type: "Resource",
|
||||
resource: {
|
||||
name: "cpu",
|
||||
target: {
|
||||
@@ -110,7 +110,7 @@ describe("getHorizontalPodAutoscalerMetrics", () => {
|
||||
desiredReplicas: 10,
|
||||
currentMetrics: [
|
||||
{
|
||||
type: HpaMetricType.Resource,
|
||||
type: "Resource",
|
||||
resource: {
|
||||
name: "cpu",
|
||||
current: {
|
||||
@@ -133,7 +133,7 @@ describe("getHorizontalPodAutoscalerMetrics", () => {
|
||||
...hpaV2.spec,
|
||||
metrics: [
|
||||
{
|
||||
type: HpaMetricType.Resource,
|
||||
type: "Resource",
|
||||
resource: {
|
||||
name: "cpu",
|
||||
target: {
|
||||
@@ -149,7 +149,7 @@ describe("getHorizontalPodAutoscalerMetrics", () => {
|
||||
desiredReplicas: 10,
|
||||
currentMetrics: [
|
||||
{
|
||||
type: HpaMetricType.Resource,
|
||||
type: "Resource",
|
||||
resource: {
|
||||
name: "cpu",
|
||||
current: {
|
||||
@@ -172,7 +172,7 @@ describe("getHorizontalPodAutoscalerMetrics", () => {
|
||||
...hpaV2.spec,
|
||||
metrics: [
|
||||
{
|
||||
type: HpaMetricType.ContainerResource,
|
||||
type: "ContainerResource",
|
||||
containerResource: {
|
||||
name: "cpu",
|
||||
container: "nginx",
|
||||
@@ -198,7 +198,7 @@ describe("getHorizontalPodAutoscalerMetrics", () => {
|
||||
...hpaV2.spec,
|
||||
metrics: [
|
||||
{
|
||||
type: HpaMetricType.ContainerResource,
|
||||
type: "ContainerResource",
|
||||
containerResource: {
|
||||
name: "cpu",
|
||||
container: "nginx",
|
||||
@@ -215,7 +215,7 @@ describe("getHorizontalPodAutoscalerMetrics", () => {
|
||||
desiredReplicas: 10,
|
||||
currentMetrics: [
|
||||
{
|
||||
type: HpaMetricType.ContainerResource,
|
||||
type: "ContainerResource",
|
||||
containerResource: {
|
||||
name: "cpu",
|
||||
current: {
|
||||
@@ -239,7 +239,7 @@ describe("getHorizontalPodAutoscalerMetrics", () => {
|
||||
...hpaV2.spec,
|
||||
metrics: [
|
||||
{
|
||||
type: HpaMetricType.Pods,
|
||||
type: "Pods",
|
||||
pods: {
|
||||
metric: {
|
||||
name: "packets-per-second",
|
||||
@@ -266,7 +266,7 @@ describe("getHorizontalPodAutoscalerMetrics", () => {
|
||||
...hpaV2.spec,
|
||||
metrics: [
|
||||
{
|
||||
type: HpaMetricType.Pods,
|
||||
type: "Pods",
|
||||
pods: {
|
||||
metric: {
|
||||
name: "packets-per-second",
|
||||
@@ -284,7 +284,7 @@ describe("getHorizontalPodAutoscalerMetrics", () => {
|
||||
desiredReplicas: 10,
|
||||
currentMetrics: [
|
||||
{
|
||||
type: HpaMetricType.Pods,
|
||||
type: "Pods",
|
||||
pods: {
|
||||
metric: {
|
||||
name: "packets-per-second",
|
||||
@@ -310,7 +310,7 @@ describe("getHorizontalPodAutoscalerMetrics", () => {
|
||||
...hpaV2.spec,
|
||||
metrics: [
|
||||
{
|
||||
type: HpaMetricType.Object,
|
||||
type: "Object",
|
||||
object: {
|
||||
metric: {
|
||||
name: "requests-per-second",
|
||||
@@ -337,7 +337,7 @@ describe("getHorizontalPodAutoscalerMetrics", () => {
|
||||
...hpaV2.spec,
|
||||
metrics: [
|
||||
{
|
||||
type: HpaMetricType.Object,
|
||||
type: "Object",
|
||||
object: {
|
||||
metric: {
|
||||
name: "requests-per-second",
|
||||
@@ -364,7 +364,7 @@ describe("getHorizontalPodAutoscalerMetrics", () => {
|
||||
...hpaV2.spec,
|
||||
metrics: [
|
||||
{
|
||||
type: HpaMetricType.Object,
|
||||
type: "Object",
|
||||
object: {
|
||||
metric: {
|
||||
name: "requests-per-second",
|
||||
@@ -382,7 +382,7 @@ describe("getHorizontalPodAutoscalerMetrics", () => {
|
||||
desiredReplicas: 10,
|
||||
currentMetrics: [
|
||||
{
|
||||
type: HpaMetricType.Object,
|
||||
type: "Object",
|
||||
object: {
|
||||
metric: {
|
||||
name: "requests-per-second",
|
||||
@@ -408,7 +408,7 @@ describe("getHorizontalPodAutoscalerMetrics", () => {
|
||||
...hpaV2.spec,
|
||||
metrics: [
|
||||
{
|
||||
type: HpaMetricType.External,
|
||||
type: "External",
|
||||
external: {
|
||||
metric: {
|
||||
name: "queue_messages_ready",
|
||||
@@ -438,7 +438,7 @@ describe("getHorizontalPodAutoscalerMetrics", () => {
|
||||
...hpaV2.spec,
|
||||
metrics: [
|
||||
{
|
||||
type: HpaMetricType.External,
|
||||
type: "External",
|
||||
external: {
|
||||
metric: {
|
||||
name: "queue_messages_ready",
|
||||
@@ -468,7 +468,7 @@ describe("getHorizontalPodAutoscalerMetrics", () => {
|
||||
...hpaV2.spec,
|
||||
metrics: [
|
||||
{
|
||||
type: HpaMetricType.External,
|
||||
type: "External",
|
||||
external: {
|
||||
metric: {
|
||||
name: "queue_messages_ready",
|
||||
@@ -489,7 +489,7 @@ describe("getHorizontalPodAutoscalerMetrics", () => {
|
||||
desiredReplicas: 10,
|
||||
currentMetrics: [
|
||||
{
|
||||
type: HpaMetricType.External,
|
||||
type: "External",
|
||||
external: {
|
||||
metric: {
|
||||
name: "queue_messages_ready",
|
||||
@@ -515,7 +515,7 @@ describe("getHorizontalPodAutoscalerMetrics", () => {
|
||||
...hpaV2.spec,
|
||||
metrics: [
|
||||
{
|
||||
type: HpaMetricType.External,
|
||||
type: "External",
|
||||
external: {
|
||||
metric: {
|
||||
name: "queue_messages_ready",
|
||||
@@ -536,7 +536,7 @@ describe("getHorizontalPodAutoscalerMetrics", () => {
|
||||
desiredReplicas: 10,
|
||||
currentMetrics: [
|
||||
{
|
||||
type: HpaMetricType.External,
|
||||
type: "External",
|
||||
external: {
|
||||
metric: {
|
||||
name: "queue_messages_ready",
|
||||
@@ -562,7 +562,7 @@ describe("getHorizontalPodAutoscalerMetrics", () => {
|
||||
...hpaV2.spec,
|
||||
metrics: [
|
||||
{
|
||||
type: HpaMetricType.External,
|
||||
type: "External",
|
||||
external: {
|
||||
metric: {
|
||||
name: "queue_messages_ready",
|
||||
@@ -583,7 +583,7 @@ describe("getHorizontalPodAutoscalerMetrics", () => {
|
||||
desiredReplicas: 10,
|
||||
currentMetrics: [
|
||||
{
|
||||
type: HpaMetricType.External,
|
||||
type: "External",
|
||||
external: {
|
||||
metric: {
|
||||
name: "queue_messages_NOT_ready",
|
||||
@@ -616,7 +616,7 @@ describe("getHorizontalPodAutoscalerMetrics", () => {
|
||||
...hpaV2Beta1.spec,
|
||||
metrics: [
|
||||
{
|
||||
type: HpaMetricType.Resource,
|
||||
type: "Resource",
|
||||
resource: {
|
||||
name: "cpu",
|
||||
targetAverageUtilization: 50,
|
||||
@@ -636,7 +636,7 @@ describe("getHorizontalPodAutoscalerMetrics", () => {
|
||||
...hpaV2Beta1.spec,
|
||||
metrics: [
|
||||
{
|
||||
type: HpaMetricType.Resource,
|
||||
type: "Resource",
|
||||
resource: {
|
||||
name: "cpu",
|
||||
targetAverageUtilization: 50,
|
||||
@@ -649,7 +649,7 @@ describe("getHorizontalPodAutoscalerMetrics", () => {
|
||||
desiredReplicas: 10,
|
||||
currentMetrics: [
|
||||
{
|
||||
type: HpaMetricType.Resource,
|
||||
type: "Resource",
|
||||
resource: {
|
||||
name: "cpu",
|
||||
currentAverageUtilization: 10,
|
||||
@@ -669,7 +669,7 @@ describe("getHorizontalPodAutoscalerMetrics", () => {
|
||||
...hpaV2Beta1.spec,
|
||||
metrics: [
|
||||
{
|
||||
type: HpaMetricType.Resource,
|
||||
type: "Resource",
|
||||
resource: {
|
||||
name: "cpu",
|
||||
targetAverageValue: "100m",
|
||||
@@ -682,7 +682,7 @@ describe("getHorizontalPodAutoscalerMetrics", () => {
|
||||
desiredReplicas: 10,
|
||||
currentMetrics: [
|
||||
{
|
||||
type: HpaMetricType.Resource,
|
||||
type: "Resource",
|
||||
resource: {
|
||||
name: "cpu",
|
||||
currentAverageValue: "500m",
|
||||
@@ -703,7 +703,7 @@ describe("getHorizontalPodAutoscalerMetrics", () => {
|
||||
...hpaV2Beta1.spec,
|
||||
metrics: [
|
||||
{
|
||||
type: HpaMetricType.ContainerResource,
|
||||
type: "ContainerResource",
|
||||
containerResource: {
|
||||
name: "cpu",
|
||||
container: "nginx",
|
||||
@@ -726,7 +726,7 @@ describe("getHorizontalPodAutoscalerMetrics", () => {
|
||||
...hpaV2Beta1.spec,
|
||||
metrics: [
|
||||
{
|
||||
type: HpaMetricType.ContainerResource,
|
||||
type: "ContainerResource",
|
||||
containerResource: {
|
||||
name: "cpu",
|
||||
container: "nginx",
|
||||
@@ -740,7 +740,7 @@ describe("getHorizontalPodAutoscalerMetrics", () => {
|
||||
desiredReplicas: 10,
|
||||
currentMetrics: [
|
||||
{
|
||||
type: HpaMetricType.ContainerResource,
|
||||
type: "ContainerResource",
|
||||
containerResource: {
|
||||
name: "cpu",
|
||||
currentAverageUtilization: 10,
|
||||
@@ -762,7 +762,7 @@ describe("getHorizontalPodAutoscalerMetrics", () => {
|
||||
...hpaV2Beta1.spec,
|
||||
metrics: [
|
||||
{
|
||||
type: HpaMetricType.Pods,
|
||||
type: "Pods",
|
||||
pods: {
|
||||
metricName: "packets-per-second",
|
||||
targetAverageValue: "1k",
|
||||
@@ -784,7 +784,7 @@ describe("getHorizontalPodAutoscalerMetrics", () => {
|
||||
...hpaV2Beta1.spec,
|
||||
metrics: [
|
||||
{
|
||||
type: HpaMetricType.Pods,
|
||||
type: "Pods",
|
||||
pods: {
|
||||
metricName: "packets-per-second",
|
||||
|
||||
@@ -798,7 +798,7 @@ describe("getHorizontalPodAutoscalerMetrics", () => {
|
||||
desiredReplicas: 10,
|
||||
currentMetrics: [
|
||||
{
|
||||
type: HpaMetricType.Pods,
|
||||
type: "Pods",
|
||||
pods: {
|
||||
metricName: "packets-per-second",
|
||||
currentAverageValue: "10",
|
||||
@@ -820,7 +820,7 @@ describe("getHorizontalPodAutoscalerMetrics", () => {
|
||||
...hpaV2Beta1.spec,
|
||||
metrics: [
|
||||
{
|
||||
type: HpaMetricType.Object,
|
||||
type: "Object",
|
||||
object: {
|
||||
metricName: "packets-per-second",
|
||||
targetValue: "10k",
|
||||
@@ -842,7 +842,7 @@ describe("getHorizontalPodAutoscalerMetrics", () => {
|
||||
...hpaV2Beta1.spec,
|
||||
metrics: [
|
||||
{
|
||||
type: HpaMetricType.Object,
|
||||
type: "Object",
|
||||
object: {
|
||||
metricName: "packets-per-second",
|
||||
averageValue: "5k",
|
||||
@@ -864,7 +864,7 @@ describe("getHorizontalPodAutoscalerMetrics", () => {
|
||||
...hpaV2Beta1.spec,
|
||||
metrics: [
|
||||
{
|
||||
type: HpaMetricType.Object,
|
||||
type: "Object",
|
||||
object: {
|
||||
metricName: "packets-per-second",
|
||||
targetValue: "5k",
|
||||
@@ -877,7 +877,7 @@ describe("getHorizontalPodAutoscalerMetrics", () => {
|
||||
desiredReplicas: 10,
|
||||
currentMetrics: [
|
||||
{
|
||||
type: HpaMetricType.Object,
|
||||
type: "Object",
|
||||
object: {
|
||||
metricName: "packets-per-second",
|
||||
currentValue: "10k",
|
||||
@@ -899,7 +899,7 @@ describe("getHorizontalPodAutoscalerMetrics", () => {
|
||||
...hpaV2Beta1.spec,
|
||||
metrics: [
|
||||
{
|
||||
type: HpaMetricType.External,
|
||||
type: "External",
|
||||
external: {
|
||||
metricName: "queue_messages_ready",
|
||||
metricSelector: { matchLabels: { queue: "worker_tasks" }},
|
||||
@@ -922,7 +922,7 @@ describe("getHorizontalPodAutoscalerMetrics", () => {
|
||||
...hpaV2Beta1.spec,
|
||||
metrics: [
|
||||
{
|
||||
type: HpaMetricType.External,
|
||||
type: "External",
|
||||
external: {
|
||||
metricName: "queue_messages_ready",
|
||||
metricSelector: { matchLabels: { queue: "worker_tasks" }},
|
||||
@@ -945,7 +945,7 @@ describe("getHorizontalPodAutoscalerMetrics", () => {
|
||||
...hpaV2Beta1.spec,
|
||||
metrics: [
|
||||
{
|
||||
type: HpaMetricType.External,
|
||||
type: "External",
|
||||
external: {
|
||||
metricName: "queue_messages_ready",
|
||||
metricSelector: { matchLabels: { queue: "worker_tasks" }},
|
||||
@@ -959,7 +959,7 @@ describe("getHorizontalPodAutoscalerMetrics", () => {
|
||||
desiredReplicas: 10,
|
||||
currentMetrics: [
|
||||
{
|
||||
type: HpaMetricType.External,
|
||||
type: "External",
|
||||
external: {
|
||||
metricName: "queue_messages_ready",
|
||||
currentValue: "10",
|
||||
@@ -981,7 +981,7 @@ describe("getHorizontalPodAutoscalerMetrics", () => {
|
||||
...hpaV2Beta1.spec,
|
||||
metrics: [
|
||||
{
|
||||
type: HpaMetricType.External,
|
||||
type: "External",
|
||||
external: {
|
||||
metricName: "queue_messages_ready",
|
||||
metricSelector: { matchLabels: { queue: "worker_tasks" }},
|
||||
@@ -995,7 +995,7 @@ describe("getHorizontalPodAutoscalerMetrics", () => {
|
||||
desiredReplicas: 10,
|
||||
currentMetrics: [
|
||||
{
|
||||
type: HpaMetricType.External,
|
||||
type: "External",
|
||||
external: {
|
||||
metricName: "queue_messages_ready",
|
||||
currentAverageValue: "10",
|
||||
@@ -1016,7 +1016,7 @@ describe("getHorizontalPodAutoscalerMetrics", () => {
|
||||
...hpaV2Beta1.spec,
|
||||
metrics: [
|
||||
{
|
||||
type: HpaMetricType.Resource,
|
||||
type: "Resource",
|
||||
resource: {
|
||||
name: "cpu",
|
||||
targetAverageUtilization: 50,
|
||||
@@ -1029,7 +1029,7 @@ describe("getHorizontalPodAutoscalerMetrics", () => {
|
||||
desiredReplicas: 10,
|
||||
currentMetrics: [
|
||||
{
|
||||
type: HpaMetricType.Resource,
|
||||
type: "Resource",
|
||||
resource: {
|
||||
name: "memory",
|
||||
currentAverageUtilization: 10,
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
*/
|
||||
|
||||
import { KubeObjectStore } from "../../../common/k8s-api/kube-object.store";
|
||||
import type { HorizontalPodAutoscaler, HorizontalPodAutoscalerApi } from "../../../common/k8s-api/endpoints/horizontal-pod-autoscaler.api";
|
||||
import type { HorizontalPodAutoscalerApi } from "../../../common/k8s-api/endpoints/horizontal-pod-autoscaler.api";
|
||||
import type { HorizontalPodAutoscaler } from "@k8slens/kube-object";
|
||||
|
||||
export class HorizontalPodAutoscalerStore extends KubeObjectStore<HorizontalPodAutoscaler, HorizontalPodAutoscalerApi> {
|
||||
}
|
||||
@@ -9,7 +9,7 @@ import React from "react";
|
||||
import { observer } from "mobx-react";
|
||||
import { DrawerItem } from "../drawer";
|
||||
import type { KubeObjectDetailsProps } from "../kube-object-details";
|
||||
import type { Lease } from "../../../common/k8s-api/endpoints";
|
||||
import type { Lease } from "@k8slens/kube-object";
|
||||
|
||||
export interface LeaseDetailsProps extends KubeObjectDetailsProps<Lease> {
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import "./leases.scss";
|
||||
|
||||
import * as React from "react";
|
||||
import { observer } from "mobx-react";
|
||||
import type { Lease } from "../../../common/k8s-api/endpoints/lease.api";
|
||||
import type { Lease } from "@k8slens/kube-object";
|
||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
||||
import type { KubeObjectDetailsProps } from "../kube-object-details";
|
||||
import { KubeObjectListLayout } from "../kube-object-list-layout";
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
*/
|
||||
|
||||
import { KubeObjectStore } from "../../../common/k8s-api/kube-object.store";
|
||||
import type { Lease, LeaseApi } from "../../../common/k8s-api/endpoints/lease.api";
|
||||
import type { LeaseApi } from "../../../common/k8s-api/endpoints/lease.api";
|
||||
import type { Lease } from "@k8slens/kube-object";
|
||||
|
||||
export class LeaseStore extends KubeObjectStore<Lease, LeaseApi> {
|
||||
}
|
||||
@@ -8,8 +8,8 @@ import "./limit-range-details.scss";
|
||||
import React from "react";
|
||||
import { observer } from "mobx-react";
|
||||
import type { KubeObjectDetailsProps } from "../kube-object-details";
|
||||
import type { LimitRangeItem } from "../../../common/k8s-api/endpoints/limit-range.api";
|
||||
import { LimitPart, LimitRange, Resource } from "../../../common/k8s-api/endpoints/limit-range.api";
|
||||
import type { LimitRangeItem } from "@k8slens/kube-object";
|
||||
import { LimitPart, LimitRange, Resource } from "@k8slens/kube-object";
|
||||
import { DrawerItem } from "../drawer/drawer-item";
|
||||
import { Badge } from "../badge";
|
||||
import type { Logger } from "../../../common/logger";
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
*/
|
||||
|
||||
import { KubeObjectStore } from "../../../common/k8s-api/kube-object.store";
|
||||
import type { LimitRange, LimitRangeApi } from "../../../common/k8s-api/endpoints/limit-range.api";
|
||||
import type { LimitRangeApi } from "../../../common/k8s-api/endpoints/limit-range.api";
|
||||
import type { LimitRange } from "@k8slens/kube-object";
|
||||
|
||||
export class LimitRangeStore extends KubeObjectStore<LimitRange, LimitRangeApi> {
|
||||
}
|
||||
@@ -12,7 +12,7 @@ import { DrawerTitle } from "../drawer";
|
||||
import type { ShowNotification } from "../notifications";
|
||||
import { Button } from "@k8slens/button";
|
||||
import type { KubeObjectDetailsProps } from "../kube-object-details";
|
||||
import { ConfigMap } from "../../../common/k8s-api/endpoints";
|
||||
import { ConfigMap } from "@k8slens/kube-object";
|
||||
import type { Logger } from "../../../common/logger";
|
||||
import type { ConfigMapStore } from "./store";
|
||||
import { withInjectables } from "@ogre-tools/injectable-react";
|
||||
@@ -42,7 +42,7 @@ class NonInjectedConfigMapDetails extends React.Component<ConfigMapDetailsProps
|
||||
makeObservable(this);
|
||||
}
|
||||
|
||||
async componentDidMount() {
|
||||
componentDidMount() {
|
||||
disposeOnUnmount(this, [
|
||||
autorun(() => {
|
||||
const { object: configMap } = this.props;
|
||||
@@ -54,27 +54,29 @@ class NonInjectedConfigMapDetails extends React.Component<ConfigMapDetailsProps
|
||||
]);
|
||||
}
|
||||
|
||||
save = async () => {
|
||||
save = () => {
|
||||
const { object: configMap, configMapStore } = this.props;
|
||||
|
||||
try {
|
||||
this.isSaving = true;
|
||||
await configMapStore.update(configMap, {
|
||||
...configMap,
|
||||
data: Object.fromEntries(this.data),
|
||||
});
|
||||
this.props.showSuccessNotification((
|
||||
<p>
|
||||
{"ConfigMap "}
|
||||
<b>{configMap.getName()}</b>
|
||||
{" successfully updated."}
|
||||
</p>
|
||||
));
|
||||
} catch (error) {
|
||||
this.props.showErrorNotification(`Failed to save config map: ${error}`);
|
||||
} finally {
|
||||
this.isSaving = false;
|
||||
}
|
||||
void (async () => {
|
||||
try {
|
||||
this.isSaving = true;
|
||||
await configMapStore.update(configMap, {
|
||||
...configMap,
|
||||
data: Object.fromEntries(this.data),
|
||||
});
|
||||
this.props.showSuccessNotification((
|
||||
<p>
|
||||
{"ConfigMap "}
|
||||
<b>{configMap.getName()}</b>
|
||||
{" successfully updated."}
|
||||
</p>
|
||||
));
|
||||
} catch (error) {
|
||||
this.props.showErrorNotification(`Failed to save config map: ${String(error)}`);
|
||||
} finally {
|
||||
this.isSaving = false;
|
||||
}
|
||||
})();
|
||||
};
|
||||
|
||||
render() {
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
*/
|
||||
|
||||
import { KubeObjectStore } from "../../../common/k8s-api/kube-object.store";
|
||||
import type { ConfigMap, ConfigMapApi, ConfigMapData } from "../../../common/k8s-api/endpoints/config-map.api";
|
||||
import type { ConfigMap, ConfigMapData } from "@k8slens/kube-object";
|
||||
import type { ConfigMapApi } from "../../../common/k8s-api/endpoints";
|
||||
|
||||
export class ConfigMapStore extends KubeObjectStore<ConfigMap, ConfigMapApi, ConfigMapData> {
|
||||
}
|
||||
+4
-5
@@ -4,15 +4,14 @@
|
||||
*/
|
||||
import type { RenderResult } from "@testing-library/react";
|
||||
import React from "react";
|
||||
import {
|
||||
MutatingWebhookConfiguration,
|
||||
} from "../../../common/k8s-api/endpoints";
|
||||
import type { MutatingWebhookConfigurationData } from "@k8slens/kube-object";
|
||||
import { MutatingWebhookConfiguration } from "@k8slens/kube-object";
|
||||
import { getDiForUnitTesting } from "../../getDiForUnitTesting";
|
||||
import type { DiRender } from "../test-utils/renderFor";
|
||||
import { renderFor } from "../test-utils/renderFor";
|
||||
import { MutatingWebhookDetails } from "./mutating-webhook-configurations-details";
|
||||
|
||||
const mutatingWebhookConfig = {
|
||||
const mutatingWebhookConfig: MutatingWebhookConfigurationData = {
|
||||
apiVersion: "admissionregistration.k8s.io/v1",
|
||||
kind: "MutatingWebhookConfiguration",
|
||||
metadata: {
|
||||
@@ -51,7 +50,7 @@ describe("MutatingWebhookConfigsDetails", () => {
|
||||
let result: RenderResult;
|
||||
let render: DiRender;
|
||||
|
||||
beforeEach(async () => {
|
||||
beforeEach(() => {
|
||||
const di = getDiForUnitTesting();
|
||||
|
||||
render = renderFor(di);
|
||||
|
||||
+2
-14
@@ -2,21 +2,9 @@
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import type {
|
||||
MutatingWebhookConfiguration,
|
||||
MutatingWebhookConfigurationApi,
|
||||
} from "../../../common/k8s-api/endpoints";
|
||||
import type {
|
||||
KubeObjectStoreDependencies,
|
||||
KubeObjectStoreOptions,
|
||||
} from "../../../common/k8s-api/kube-object.store";
|
||||
import type { MutatingWebhookConfiguration } from "@k8slens/kube-object";
|
||||
import type { MutatingWebhookConfigurationApi } from "../../../common/k8s-api/endpoints";
|
||||
import { KubeObjectStore } from "../../../common/k8s-api/kube-object.store";
|
||||
|
||||
export interface MutatingWebhookConfigurationStoreDependencies extends KubeObjectStoreDependencies {
|
||||
}
|
||||
|
||||
export class MutatingWebhookConfigurationStore extends KubeObjectStore<MutatingWebhookConfiguration, MutatingWebhookConfigurationApi> {
|
||||
constructor(protected readonly dependencies: MutatingWebhookConfigurationStoreDependencies, api: MutatingWebhookConfigurationApi, opts?: KubeObjectStoreOptions) {
|
||||
super(dependencies, api, opts);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -6,7 +6,7 @@ import React from "react";
|
||||
import { observer } from "mobx-react";
|
||||
import { DrawerItem, DrawerTitle } from "../drawer";
|
||||
import type { KubeObjectDetailsProps } from "../kube-object-details";
|
||||
import type { MutatingWebhookConfiguration } from "../../../common/k8s-api/endpoints";
|
||||
import type { MutatingWebhookConfiguration } from "@k8slens/kube-object";
|
||||
import { WebhookConfig } from "./webhook-config";
|
||||
|
||||
export interface MutatingWebhookDetailsProps extends KubeObjectDetailsProps<MutatingWebhookConfiguration> {
|
||||
|
||||
+4
-4
@@ -4,12 +4,12 @@
|
||||
*/
|
||||
import React from "react";
|
||||
import styles from "./webhook-config.module.css";
|
||||
import type { MutatingWebhook, ValidatingWebhook } from "../../../common/k8s-api/endpoints";
|
||||
import type { Webhook } from "@k8slens/kube-object";
|
||||
import { DrawerItem } from "../drawer";
|
||||
import { Badge } from "../badge";
|
||||
|
||||
interface WebhookProps {
|
||||
webhook: ValidatingWebhook | MutatingWebhook;
|
||||
webhook: Webhook;
|
||||
}
|
||||
|
||||
export const WebhookConfig: React.FC<WebhookProps> = ({ webhook }) => {
|
||||
@@ -82,7 +82,7 @@ export const WebhookConfig: React.FC<WebhookProps> = ({ webhook }) => {
|
||||
<div>Match Labels:</div>
|
||||
<div className={styles.matchLabels}>
|
||||
{Object.entries(webhook.namespaceSelector.matchLabels).map(([key, value], index) => (
|
||||
<Badge label={`${key}=${value}`} key={index} />
|
||||
<Badge label={`${key}=${value ?? ""}`} key={index} />
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
@@ -118,7 +118,7 @@ export const WebhookConfig: React.FC<WebhookProps> = ({ webhook }) => {
|
||||
<div>Match Labels:</div>
|
||||
<div className={styles.matchLabels}>
|
||||
{Object.entries(webhook.objectSelector.matchLabels).map(([key, value], index) => (
|
||||
<Badge label={`${key}=${value}`} key={index} />
|
||||
<Badge label={`${key}=${value ?? ""}`} key={index} />
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+2
-2
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
import React from "react";
|
||||
import { PodDisruptionBudget } from "../../../../common/k8s-api/endpoints";
|
||||
import { PodDisruptionBudget } from "@k8slens/kube-object";
|
||||
import { getDiForUnitTesting } from "../../../getDiForUnitTesting";
|
||||
import { renderFor } from "../../test-utils/renderFor";
|
||||
import { PodDisruptionBudgets } from "../pod-disruption-budgets";
|
||||
@@ -106,7 +106,7 @@ describe("<PodDisruptionBudgets />", () => {
|
||||
|
||||
expect(result.container.querySelector(".TableRow .min-available")?.textContent).toEqual("N/A");
|
||||
});
|
||||
|
||||
|
||||
it("should display maxUnavailable as 0", () => {
|
||||
di.override(podDisruptionBudgetStoreInjectable, () => getPodDisruptionBudgetStoreInjectableMock(pdb));
|
||||
const result = renderFor(di)(<PodDisruptionBudgets object={pdb}/>);
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ import { observer } from "mobx-react";
|
||||
import { DrawerItem } from "../drawer";
|
||||
import { Badge } from "../badge";
|
||||
import type { KubeObjectDetailsProps } from "../kube-object-details";
|
||||
import type { PodDisruptionBudget } from "../../../common/k8s-api/endpoints";
|
||||
import type { PodDisruptionBudget } from "@k8slens/kube-object";
|
||||
|
||||
export interface PodDisruptionBudgetDetailsProps extends KubeObjectDetailsProps<PodDisruptionBudget> {
|
||||
}
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ import "./pod-disruption-budgets.scss";
|
||||
|
||||
import * as React from "react";
|
||||
import { observer } from "mobx-react";
|
||||
import type { PodDisruptionBudget } from "../../../common/k8s-api/endpoints/pod-disruption-budget.api";
|
||||
import type { PodDisruptionBudget } from "@k8slens/kube-object";
|
||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
||||
import type { KubeObjectDetailsProps } from "../kube-object-details";
|
||||
import { KubeObjectListLayout } from "../kube-object-list-layout";
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
*/
|
||||
|
||||
import { KubeObjectStore } from "../../../common/k8s-api/kube-object.store";
|
||||
import type { PodDisruptionBudget, PodDisruptionBudgetApi } from "../../../common/k8s-api/endpoints/pod-disruption-budget.api";
|
||||
import type { PodDisruptionBudgetApi } from "../../../common/k8s-api/endpoints/pod-disruption-budget.api";
|
||||
import type { PodDisruptionBudget } from "@k8slens/kube-object";
|
||||
|
||||
export class PodDisruptionBudgetStore extends KubeObjectStore<PodDisruptionBudget, PodDisruptionBudgetApi> {
|
||||
}
|
||||
+1
-1
@@ -9,7 +9,7 @@ import React from "react";
|
||||
import { observer } from "mobx-react";
|
||||
import { DrawerItem } from "../drawer";
|
||||
import type { KubeObjectDetailsProps } from "../kube-object-details";
|
||||
import type { PriorityClass } from "../../../common/k8s-api/endpoints";
|
||||
import type { PriorityClass } from "@k8slens/kube-object";
|
||||
|
||||
export interface PriorityClassesDetailsProps extends KubeObjectDetailsProps<PriorityClass> {
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import "./priority-classes.scss";
|
||||
|
||||
import * as React from "react";
|
||||
import { observer } from "mobx-react";
|
||||
import type { PriorityClass } from "../../../common/k8s-api/endpoints/priority-class.api";
|
||||
import type { PriorityClass } from "@k8slens/kube-object";
|
||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
||||
import type { KubeObjectDetailsProps } from "../kube-object-details";
|
||||
import { KubeObjectListLayout } from "../kube-object-list-layout";
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
*/
|
||||
|
||||
import { KubeObjectStore } from "../../../common/k8s-api/kube-object.store";
|
||||
import type { PriorityClass, PriorityClassApi } from "../../../common/k8s-api/endpoints/priority-class.api";
|
||||
import type { PriorityClassApi } from "../../../common/k8s-api/endpoints/priority-class.api";
|
||||
import type { PriorityClass } from "@k8slens/kube-object";
|
||||
|
||||
export class PriorityClassStore extends KubeObjectStore<PriorityClass, PriorityClassApi> {
|
||||
}
|
||||
@@ -14,7 +14,8 @@ import { Dialog } from "../../dialog";
|
||||
import { Wizard, WizardStep } from "../../wizard";
|
||||
import { Input } from "../../input";
|
||||
import { systemName } from "../../input/input_validators";
|
||||
import type { IResourceQuotaValues, ResourceQuotaApi } from "../../../../common/k8s-api/endpoints";
|
||||
import type { ResourceQuotaValues } from "@k8slens/kube-object";
|
||||
import type { ResourceQuotaApi } from "../../../../common/k8s-api/endpoints";
|
||||
import { Select } from "../../select";
|
||||
import { Icon } from "../../icon";
|
||||
import { Button } from "@k8slens/button";
|
||||
@@ -37,7 +38,7 @@ interface Dependencies {
|
||||
showCheckedErrorNotification: ShowCheckedErrorNotification;
|
||||
}
|
||||
|
||||
const defaultQuotas = JSON.stringify({
|
||||
const getDefaultQuotas = (): ResourceQuotaValues => ({
|
||||
"limits.cpu": "",
|
||||
"limits.memory": "",
|
||||
"requests.cpu": "",
|
||||
@@ -56,7 +57,7 @@ const defaultQuotas = JSON.stringify({
|
||||
"count/jobs.batch": "",
|
||||
"count/cronjobs.batch": "",
|
||||
"count/deployments.extensions": "",
|
||||
} as IResourceQuotaValues);
|
||||
});
|
||||
|
||||
@observer
|
||||
class NonInjectedAddQuotaDialog extends React.Component<AddQuotaDialogProps & Dependencies> {
|
||||
@@ -67,7 +68,7 @@ class NonInjectedAddQuotaDialog extends React.Component<AddQuotaDialogProps & De
|
||||
@observable quotaSelectValue: string | null = null;
|
||||
@observable quotaInputValue = "";
|
||||
@observable namespace: string | null = this.defaultNamespace;
|
||||
@observable quotas: IResourceQuotaValues = JSON.parse(defaultQuotas);
|
||||
readonly quotas = observable.box(getDefaultQuotas());
|
||||
|
||||
constructor(props: AddQuotaDialogProps & Dependencies) {
|
||||
super(props);
|
||||
@@ -75,7 +76,7 @@ class NonInjectedAddQuotaDialog extends React.Component<AddQuotaDialogProps & De
|
||||
}
|
||||
|
||||
@computed get quotaEntries() {
|
||||
return Object.entries(this.quotas)
|
||||
return Object.entries(this.quotas.get())
|
||||
.filter(([, value]) => !!value?.trim());
|
||||
}
|
||||
|
||||
@@ -97,7 +98,7 @@ class NonInjectedAddQuotaDialog extends React.Component<AddQuotaDialogProps & De
|
||||
|
||||
setQuota = () => {
|
||||
if (!this.quotaSelectValue) return;
|
||||
this.quotas[this.quotaSelectValue] = this.quotaInputValue;
|
||||
this.quotas.get()[this.quotaSelectValue] = this.quotaInputValue;
|
||||
this.quotaInputValue = "";
|
||||
};
|
||||
|
||||
@@ -110,7 +111,7 @@ class NonInjectedAddQuotaDialog extends React.Component<AddQuotaDialogProps & De
|
||||
this.quotaSelectValue = "";
|
||||
this.quotaInputValue = "";
|
||||
this.namespace = this.defaultNamespace;
|
||||
this.quotas = JSON.parse(defaultQuotas);
|
||||
this.quotas.set(getDefaultQuotas());
|
||||
};
|
||||
|
||||
addQuota = async () => {
|
||||
@@ -130,7 +131,7 @@ class NonInjectedAddQuotaDialog extends React.Component<AddQuotaDialogProps & De
|
||||
});
|
||||
this.close();
|
||||
} catch (err) {
|
||||
this.props.showCheckedErrorNotification(err, "Unknown error occured while creating ResourceQuota");
|
||||
this.props.showCheckedErrorNotification(err, "Unknown error occurred while creating ResourceQuota");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -147,6 +148,9 @@ class NonInjectedAddQuotaDialog extends React.Component<AddQuotaDialogProps & De
|
||||
const { closeAddQuotaDialog, isAddQuotaDialogOpen, resourceQuotaApi, ...dialogProps } = this.props;
|
||||
const header = <h5>Create ResourceQuota</h5>;
|
||||
|
||||
void closeAddQuotaDialog;
|
||||
void resourceQuotaApi;
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
{...dialogProps}
|
||||
@@ -225,7 +229,7 @@ class NonInjectedAddQuotaDialog extends React.Component<AddQuotaDialogProps & De
|
||||
onClick={this.setQuota}
|
||||
>
|
||||
<Icon
|
||||
material={this.quotaSelectValue && this.quotas[this.quotaSelectValue] ? "edit" : "add"}
|
||||
material={this.quotaSelectValue && this.quotas.get()[this.quotaSelectValue] ? "edit" : "add"}
|
||||
tooltip="Set quota"
|
||||
/>
|
||||
</Button>
|
||||
@@ -235,7 +239,7 @@ class NonInjectedAddQuotaDialog extends React.Component<AddQuotaDialogProps & De
|
||||
<div key={quota} className="quota gaps inline align-center">
|
||||
<div className="name">{quota}</div>
|
||||
<div className="value">{value}</div>
|
||||
<Icon material="clear" onClick={() => this.quotas[quota] = ""} />
|
||||
<Icon material="clear" onClick={() => this.quotas.get()[quota] = ""} />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ import { observer } from "mobx-react";
|
||||
import { DrawerItem, DrawerTitle } from "../drawer";
|
||||
import { cpuUnitsToNumber, cssNames, unitsToBytes, metricUnitsToNumber, object, hasDefinedTupleValue } from "@k8slens/utilities";
|
||||
import type { KubeObjectDetailsProps } from "../kube-object-details";
|
||||
import { ResourceQuota } from "../../../common/k8s-api/endpoints/resource-quota.api";
|
||||
import { ResourceQuota } from "@k8slens/kube-object";
|
||||
import { LineProgress } from "../line-progress";
|
||||
import { Table, TableCell, TableHead, TableRow } from "../table";
|
||||
import type { Logger } from "../../../common/logger";
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
*/
|
||||
|
||||
import { KubeObjectStore } from "../../../common/k8s-api/kube-object.store";
|
||||
import type { ResourceQuota, ResourceQuotaApi } from "../../../common/k8s-api/endpoints/resource-quota.api";
|
||||
import type { ResourceQuotaApi } from "../../../common/k8s-api/endpoints/resource-quota.api";
|
||||
import type { ResourceQuota } from "@k8slens/kube-object";
|
||||
|
||||
export class ResourceQuotaStore extends KubeObjectStore<ResourceQuota, ResourceQuotaApi> {
|
||||
}
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
import "./runtime-classes-details-tolerations.scss";
|
||||
import React from "react";
|
||||
import { DrawerParamToggler, DrawerItem } from "../drawer";
|
||||
import type { Toleration, KubeObject } from "../../../common/k8s-api/kube-object";
|
||||
import type { Toleration, KubeObject } from "@k8slens/kube-object";
|
||||
import { RuntimeClassTolerations } from "./runtime-classes-tolerations";
|
||||
|
||||
export interface KubeObjectWithTolerations extends KubeObject {
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ import React from "react";
|
||||
import { observer } from "mobx-react";
|
||||
import { DrawerItem } from "../drawer";
|
||||
import type { KubeObjectDetailsProps } from "../kube-object-details";
|
||||
import type { RuntimeClass } from "../../../common/k8s-api/endpoints";
|
||||
import type { RuntimeClass } from "@k8slens/kube-object";
|
||||
import { Badge } from "../badge";
|
||||
import { RuntimeClassDetailsTolerations } from "./runtime-classes-details-tolerations";
|
||||
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ import "./runtime-classes-tolerations.scss";
|
||||
import React from "react";
|
||||
import uniqueId from "lodash/uniqueId";
|
||||
|
||||
import type { Toleration } from "../../../common/k8s-api/kube-object";
|
||||
import type { Toleration } from "@k8slens/kube-object";
|
||||
import { Table, TableCell, TableHead, TableRow } from "../table";
|
||||
|
||||
export interface RuntimeClassTolerationsProps {
|
||||
|
||||
@@ -7,7 +7,7 @@ import "./runtime-classes.scss";
|
||||
|
||||
import * as React from "react";
|
||||
import { observer } from "mobx-react";
|
||||
import type { RuntimeClass } from "../../../common/k8s-api/endpoints/runtime-class.api";
|
||||
import type { RuntimeClass } from "@k8slens/kube-object";
|
||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
||||
import type { KubeObjectDetailsProps } from "../kube-object-details";
|
||||
import { KubeObjectListLayout } from "../kube-object-list-layout";
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
*/
|
||||
|
||||
import { KubeObjectStore } from "../../../common/k8s-api/kube-object.store";
|
||||
import type { RuntimeClass, RuntimeClassApi } from "../../../common/k8s-api/endpoints/runtime-class.api";
|
||||
import type { RuntimeClassApi } from "../../../common/k8s-api/endpoints/runtime-class.api";
|
||||
import type { RuntimeClass } from "@k8slens/kube-object";
|
||||
|
||||
export class RuntimeClassStore extends KubeObjectStore<RuntimeClass, RuntimeClassApi> {
|
||||
}
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
|
||||
import React from "react";
|
||||
import { SecretDetails } from "../secret-details";
|
||||
import { Secret, SecretType } from "../../../../common/k8s-api/endpoints";
|
||||
import { Secret, SecretType } from "@k8slens/kube-object";
|
||||
import { getDiForUnitTesting } from "../../../getDiForUnitTesting";
|
||||
import { renderFor } from "../../test-utils/renderFor";
|
||||
import storesAndApisCanBeCreatedInjectable from "../../../stores-apis-can-be-created.injectable";
|
||||
|
||||
@@ -15,7 +15,7 @@ import { Wizard, WizardStep } from "../../wizard";
|
||||
import { Input } from "../../input";
|
||||
import { systemName } from "../../input/input_validators";
|
||||
import type { SecretApi } from "../../../../common/k8s-api/endpoints";
|
||||
import { reverseSecretTypeMap, SecretType } from "../../../../common/k8s-api/endpoints";
|
||||
import { reverseSecretTypeMap, SecretType } from "@k8slens/kube-object";
|
||||
import { SubTitle } from "../../layout/sub-title";
|
||||
import { NamespaceSelect } from "../../namespaces/namespace-select";
|
||||
import { Select } from "../../select";
|
||||
@@ -117,7 +117,7 @@ class NonInjectedAddSecretDialog extends React.Component<AddSecretDialogProps &
|
||||
this.props.showDetails(newSecret?.selfLink);
|
||||
this.close();
|
||||
} catch (err) {
|
||||
this.props.showCheckedErrorNotification(err, "Unknown error occured while creating a Secret");
|
||||
this.props.showCheckedErrorNotification(err, "Unknown error occurred while creating a Secret");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -190,6 +190,10 @@ class NonInjectedAddSecretDialog extends React.Component<AddSecretDialogProps &
|
||||
const { namespace, name, type } = this;
|
||||
const header = <h5>Create Secret</h5>;
|
||||
|
||||
void closeAddSecretDialog;
|
||||
void secretApi;
|
||||
void showDetails;
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
{...dialogProps}
|
||||
|
||||
@@ -15,7 +15,7 @@ import type { ShowNotification } from "../notifications";
|
||||
import { base64, toggle } from "@k8slens/utilities";
|
||||
import { Icon } from "../icon";
|
||||
import type { KubeObjectDetailsProps } from "../kube-object-details";
|
||||
import { Secret } from "../../../common/k8s-api/endpoints";
|
||||
import { Secret } from "@k8slens/kube-object";
|
||||
import type { Logger } from "../../../common/logger";
|
||||
import type { SecretStore } from "./store";
|
||||
import { withInjectables } from "@ogre-tools/injectable-react";
|
||||
@@ -46,7 +46,7 @@ class NonInjectedSecretDetails extends React.Component<SecretDetailsProps & Depe
|
||||
makeObservable(this);
|
||||
}
|
||||
|
||||
async componentDidMount() {
|
||||
componentDidMount() {
|
||||
disposeOnUnmount(this, [
|
||||
autorun(() => {
|
||||
const { object: secret } = this.props;
|
||||
@@ -59,18 +59,20 @@ class NonInjectedSecretDetails extends React.Component<SecretDetailsProps & Depe
|
||||
]);
|
||||
}
|
||||
|
||||
saveSecret = async () => {
|
||||
saveSecret = () => {
|
||||
const { object: secret } = this.props;
|
||||
|
||||
this.isSaving = true;
|
||||
void (async () => {
|
||||
this.isSaving = true;
|
||||
|
||||
try {
|
||||
await this.props.secretStore.update(secret, { ...secret, data: this.data });
|
||||
this.props.showSuccessNotification("Secret successfully updated.");
|
||||
} catch (err) {
|
||||
this.props.showCheckedErrorNotification(err, "Unknown error occured while updating the secret");
|
||||
}
|
||||
this.isSaving = false;
|
||||
try {
|
||||
await this.props.secretStore.update(secret, { ...secret, data: this.data });
|
||||
this.props.showSuccessNotification("Secret successfully updated.");
|
||||
} catch (err) {
|
||||
this.props.showCheckedErrorNotification(err, "Unknown error occurred while updating the secret");
|
||||
}
|
||||
this.isSaving = false;
|
||||
})();
|
||||
};
|
||||
|
||||
editData = (name: string, value: string, encoded: boolean) => {
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
*/
|
||||
|
||||
import { KubeObjectStore } from "../../../common/k8s-api/kube-object.store";
|
||||
import type { Secret, SecretApi, SecretData } from "../../../common/k8s-api/endpoints";
|
||||
import type { SecretApi } from "../../../common/k8s-api/endpoints";
|
||||
import type { Secret, SecretData } from "@k8slens/kube-object";
|
||||
|
||||
export class SecretStore extends KubeObjectStore<Secret, SecretApi, SecretData> {
|
||||
}
|
||||
+4
-5
@@ -4,15 +4,14 @@
|
||||
*/
|
||||
import type { RenderResult } from "@testing-library/react";
|
||||
import React from "react";
|
||||
import {
|
||||
ValidatingWebhookConfiguration,
|
||||
} from "../../../common/k8s-api/endpoints";
|
||||
import type { ValidatingWebhookConfigurationData } from "@k8slens/kube-object";
|
||||
import { ValidatingWebhookConfiguration } from "@k8slens/kube-object";
|
||||
import { getDiForUnitTesting } from "../../getDiForUnitTesting";
|
||||
import type { DiRender } from "../test-utils/renderFor";
|
||||
import { renderFor } from "../test-utils/renderFor";
|
||||
import { ValidatingWebhookDetails } from "./validating-webhook-configurations-details";
|
||||
|
||||
const validatingWebhookConfig = {
|
||||
const validatingWebhookConfig: ValidatingWebhookConfigurationData = {
|
||||
apiVersion: "admissionregistration.k8s.io/v1",
|
||||
kind: "ValidatingWebhookConfiguration",
|
||||
metadata: {
|
||||
@@ -52,7 +51,7 @@ describe("ValidatingWebhookConfigsDetails", () => {
|
||||
let result: RenderResult;
|
||||
let render: DiRender;
|
||||
|
||||
beforeEach(async () => {
|
||||
beforeEach(() => {
|
||||
const di = getDiForUnitTesting();
|
||||
|
||||
render = renderFor(di);
|
||||
|
||||
+2
-14
@@ -2,21 +2,9 @@
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import type {
|
||||
ValidatingWebhookConfiguration,
|
||||
ValidatingWebhookConfigurationApi,
|
||||
} from "../../../common/k8s-api/endpoints";
|
||||
import type {
|
||||
KubeObjectStoreDependencies,
|
||||
KubeObjectStoreOptions,
|
||||
} from "../../../common/k8s-api/kube-object.store";
|
||||
import type { ValidatingWebhookConfiguration } from "@k8slens/kube-object";
|
||||
import type { ValidatingWebhookConfigurationApi } from "../../../common/k8s-api/endpoints";
|
||||
import { KubeObjectStore } from "../../../common/k8s-api/kube-object.store";
|
||||
|
||||
export interface ValidatingWebhookConfigurationStoreDependencies extends KubeObjectStoreDependencies {
|
||||
}
|
||||
|
||||
export class ValidatingWebhookConfigurationStore extends KubeObjectStore<ValidatingWebhookConfiguration, ValidatingWebhookConfigurationApi> {
|
||||
constructor(protected readonly dependencies: ValidatingWebhookConfigurationStoreDependencies, api: ValidatingWebhookConfigurationApi, opts?: KubeObjectStoreOptions) {
|
||||
super(dependencies, api, opts);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -7,7 +7,7 @@ import { observer } from "mobx-react";
|
||||
import { DrawerItem, DrawerTitle } from "../drawer";
|
||||
import type { KubeObjectDetailsProps } from "../kube-object-details";
|
||||
import { WebhookConfig } from "../config-mutating-webhook-configurations/webhook-config";
|
||||
import type { ValidatingWebhookConfiguration } from "../../../common/k8s-api/endpoints";
|
||||
import type { ValidatingWebhookConfiguration } from "@k8slens/kube-object";
|
||||
|
||||
export interface ValidatingWebhookProps extends KubeObjectDetailsProps<ValidatingWebhookConfiguration> {
|
||||
}
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
*/
|
||||
|
||||
import { KubeObjectStore } from "../../../common/k8s-api/kube-object.store";
|
||||
import type { VerticalPodAutoscaler, VerticalPodAutoscalerApi } from "../../../common/k8s-api/endpoints/vertical-pod-autoscaler.api";
|
||||
import type { VerticalPodAutoscalerApi } from "../../../common/k8s-api/endpoints/vertical-pod-autoscaler.api";
|
||||
import type { VerticalPodAutoscaler } from "@k8slens/kube-object";
|
||||
|
||||
export class VerticalPodAutoscalerStore extends KubeObjectStore<VerticalPodAutoscaler, VerticalPodAutoscalerApi> {
|
||||
}
|
||||
+37
-39
@@ -13,8 +13,8 @@ import { DrawerItem, DrawerTitle } from "../drawer";
|
||||
import { Badge } from "../badge";
|
||||
import type { KubeObjectDetailsProps } from "../kube-object-details";
|
||||
import { cssNames } from "@k8slens/utilities";
|
||||
import { ContainerScalingMode, ControlledValues, ResourceName, UpdateMode, VerticalPodAutoscaler } from "../../../common/k8s-api/endpoints/vertical-pod-autoscaler.api";
|
||||
import type { PodUpdatePolicy, PodResourcePolicy, VerticalPodAutoscalerStatus } from "../../../common/k8s-api/endpoints/vertical-pod-autoscaler.api";
|
||||
import { ContainerScalingMode, ControlledValues, ResourceName, UpdateMode, VerticalPodAutoscaler } from "@k8slens/kube-object";
|
||||
import type { PodUpdatePolicy, PodResourcePolicy, VerticalPodAutoscalerStatus } from "@k8slens/kube-object";
|
||||
import type { ApiManager } from "../../../common/k8s-api/api-manager";
|
||||
import loggerInjectable from "../../../common/logger.injectable";
|
||||
import type { Logger } from "../../../common/logger";
|
||||
@@ -59,47 +59,45 @@ class NonInjectedVpaDetails extends React.Component<VpaDetailsProps & Dependenci
|
||||
|
||||
{recommendation?.containerRecommendations && (
|
||||
recommendation.containerRecommendations
|
||||
.map( ({ containerName, target, lowerBound, upperBound, uncappedTarget }) => {
|
||||
return (
|
||||
<div key={containerName}>
|
||||
<DrawerTitle>{`Container Recommendation for ${containerName}`}</DrawerTitle>
|
||||
<DrawerItem name="target" >
|
||||
{Object.entries(target).map(([name, value]) => (
|
||||
.map( ({ containerName, target, lowerBound, upperBound, uncappedTarget }) => (
|
||||
<div key={containerName}>
|
||||
<DrawerTitle>{`Container Recommendation for ${containerName ?? "<unknown>"}`}</DrawerTitle>
|
||||
<DrawerItem name="target">
|
||||
{Object.entries(target).map(([name, value]) => (
|
||||
<DrawerItem key={name} name={startCase(name)}>
|
||||
{value}
|
||||
</DrawerItem>
|
||||
))}
|
||||
</DrawerItem>
|
||||
{lowerBound && (
|
||||
<DrawerItem name="lowerBound">
|
||||
{Object.entries(lowerBound).map(([name, value]) => (
|
||||
<DrawerItem key={name} name={startCase(name)}>
|
||||
{value}
|
||||
</DrawerItem>
|
||||
))}
|
||||
</DrawerItem>
|
||||
{lowerBound && (
|
||||
<DrawerItem name="lowerBound" >
|
||||
{Object.entries(lowerBound).map(([name, value]) => (
|
||||
<DrawerItem key={name} name={startCase(name)}>
|
||||
{value}
|
||||
</DrawerItem>
|
||||
))}
|
||||
</DrawerItem>
|
||||
)}
|
||||
{upperBound && (
|
||||
<DrawerItem name="upperBound" >
|
||||
{Object.entries(upperBound).map(([name, value]) => (
|
||||
<DrawerItem key={name} name={startCase(name)}>
|
||||
{value}
|
||||
</DrawerItem>
|
||||
))}
|
||||
</DrawerItem>
|
||||
)}
|
||||
{uncappedTarget && (
|
||||
<DrawerItem name="uncappedTarget" >
|
||||
{Object.entries(uncappedTarget).map(([name, value]) => (
|
||||
<DrawerItem key={name} name={startCase(name)}>
|
||||
{value}
|
||||
</DrawerItem>
|
||||
))}
|
||||
</DrawerItem>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
})
|
||||
)}
|
||||
{upperBound && (
|
||||
<DrawerItem name="upperBound">
|
||||
{Object.entries(upperBound).map(([name, value]) => (
|
||||
<DrawerItem key={name} name={startCase(name)}>
|
||||
{value}
|
||||
</DrawerItem>
|
||||
))}
|
||||
</DrawerItem>
|
||||
)}
|
||||
{uncappedTarget && (
|
||||
<DrawerItem name="uncappedTarget">
|
||||
{Object.entries(uncappedTarget).map(([name, value]) => (
|
||||
<DrawerItem key={name} name={startCase(name)}>
|
||||
{value}
|
||||
</DrawerItem>
|
||||
))}
|
||||
</DrawerItem>
|
||||
)}
|
||||
</div>
|
||||
))
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
@@ -128,7 +126,7 @@ class NonInjectedVpaDetails extends React.Component<VpaDetailsProps & Dependenci
|
||||
.map( ({ containerName, mode, minAllowed, maxAllowed, controlledResources, controlledValues }) => {
|
||||
return (
|
||||
<div key={containerName}>
|
||||
<DrawerTitle>{`Container Policy for ${containerName}`}</DrawerTitle>
|
||||
<DrawerTitle>{`Container Policy for ${containerName ?? "<unknown>"}`}</DrawerTitle>
|
||||
<DrawerItem name="mode" >
|
||||
{mode ?? ContainerScalingMode.ContainerScalingModeAuto}
|
||||
</DrawerItem>
|
||||
|
||||
@@ -79,7 +79,7 @@ class NonInjectedConfirmDialog extends React.Component<ConfirmDialogProps & Depe
|
||||
? error.message
|
||||
: typeof error === "string"
|
||||
? error
|
||||
: "Unknown error occured while ok-ing"
|
||||
: "Unknown error occurred while ok-ing"
|
||||
)}
|
||||
</p>
|
||||
</>,
|
||||
@@ -107,7 +107,7 @@ class NonInjectedConfirmDialog extends React.Component<ConfirmDialogProps & Depe
|
||||
? error.message
|
||||
: typeof error === "string"
|
||||
? error
|
||||
: "Unknown error occured while cancelling"
|
||||
: "Unknown error occurred while cancelling"
|
||||
)}
|
||||
</p>
|
||||
</>,
|
||||
|
||||
+2
-2
@@ -4,8 +4,8 @@
|
||||
*/
|
||||
|
||||
import React from "react";
|
||||
import { CustomResourceDefinition } from "../../../../common/k8s-api/endpoints";
|
||||
import { KubeObject } from "../../../../common/k8s-api/kube-object";
|
||||
import { CustomResourceDefinition } from "@k8slens/kube-object";
|
||||
import { KubeObject } from "@k8slens/kube-object";
|
||||
import { getDiForUnitTesting } from "../../../getDiForUnitTesting";
|
||||
import type { DiRender } from "../../test-utils/renderFor";
|
||||
import { renderFor } from "../../test-utils/renderFor";
|
||||
|
||||
@@ -8,7 +8,7 @@ import "./crd-details.scss";
|
||||
import React from "react";
|
||||
import { Link } from "react-router-dom";
|
||||
import { observer } from "mobx-react";
|
||||
import { CustomResourceDefinition } from "../../../common/k8s-api/endpoints/custom-resource-definition.api";
|
||||
import { CustomResourceDefinition } from "@k8slens/kube-object";
|
||||
import { Badge } from "../badge";
|
||||
import { DrawerItem, DrawerTitle } from "../drawer";
|
||||
import type { KubeObjectDetailsProps } from "../kube-object-details";
|
||||
|
||||
@@ -12,10 +12,8 @@ import { Badge } from "../badge";
|
||||
import { DrawerItem } from "../drawer";
|
||||
import type { KubeObjectDetailsProps } from "../kube-object-details";
|
||||
import { Input } from "../input";
|
||||
import type { AdditionalPrinterColumnsV1 } from "../../../common/k8s-api/endpoints/custom-resource-definition.api";
|
||||
import { CustomResourceDefinition } from "../../../common/k8s-api/endpoints/custom-resource-definition.api";
|
||||
import type { KubeObjectMetadata, KubeObjectStatus } from "../../../common/k8s-api/kube-object";
|
||||
import { KubeObject } from "../../../common/k8s-api/kube-object";
|
||||
import type { AdditionalPrinterColumnsV1, KubeObjectMetadata, KubeObjectStatus } from "@k8slens/kube-object";
|
||||
import { CustomResourceDefinition, KubeObject } from "@k8slens/kube-object";
|
||||
import type { Logger } from "../../../common/logger";
|
||||
import { withInjectables } from "@ogre-tools/injectable-react";
|
||||
import loggerInjectable from "../../../common/logger.injectable";
|
||||
@@ -91,7 +89,7 @@ class NonInjectedCustomResourceDetails extends React.Component<CustomResourceDet
|
||||
}))
|
||||
.map(({ kind, message, status }, index) => (
|
||||
<Badge
|
||||
key={kind + index}
|
||||
key={`${kind}${index}`}
|
||||
label={kind}
|
||||
disabled={status === "False"}
|
||||
className={kind.toLowerCase()}
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
import { computed, makeObservable } from "mobx";
|
||||
import type { KubeObjectStoreDependencies, KubeObjectStoreOptions } from "../../../common/k8s-api/kube-object.store";
|
||||
import { KubeObjectStore } from "../../../common/k8s-api/kube-object.store";
|
||||
import type { CustomResourceDefinition, CustomResourceDefinitionApi } from "../../../common/k8s-api/endpoints/custom-resource-definition.api";
|
||||
import type { KubeObject } from "../../../common/k8s-api/kube-object";
|
||||
import type { CustomResourceDefinition, KubeObject } from "@k8slens/kube-object";
|
||||
import autoBind from "auto-bind";
|
||||
import type { CustomResourceDefinitionApi } from "../../../common/k8s-api/endpoints";
|
||||
|
||||
export class CustomResourceDefinitionStore extends KubeObjectStore<CustomResourceDefinition, CustomResourceDefinitionApi> {
|
||||
constructor(
|
||||
|
||||
@@ -96,7 +96,7 @@ class NonInjectedCreateResource extends React.Component<CreateResourceProps & De
|
||||
|
||||
if (!result.callWasSuccessful) {
|
||||
this.props.logger.warn("Failed to create resource", { resource }, result.error);
|
||||
this.props.showCheckedErrorNotification(result.error, "Unknown error occured while creating resources");
|
||||
this.props.showCheckedErrorNotification(result.error, "Unknown error occurred while creating resources");
|
||||
|
||||
throw result.error;
|
||||
}
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ import { waitUntilDefined } from "@k8slens/utilities";
|
||||
import editResourceTabStoreInjectable from "../store.injectable";
|
||||
import type { EditingResource, EditResourceTabStore } from "../store";
|
||||
import { action, computed, observable, runInAction } from "mobx";
|
||||
import type { KubeObject, RawKubeObject } from "../../../../../common/k8s-api/kube-object";
|
||||
import type { KubeObject, RawKubeObject } from "@k8slens/kube-object";
|
||||
import yaml from "js-yaml";
|
||||
import assert from "assert";
|
||||
import type { RequestPatchKubeResource } from "./request-patch-kube-resource.injectable";
|
||||
|
||||
+2
-3
@@ -3,12 +3,11 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import type { KubeObjectMetadata, KubeObjectScope } from "../../../../../common/k8s-api/kube-object";
|
||||
import { KubeObject } from "../../../../../common/k8s-api/kube-object";
|
||||
import type { KubeObjectMetadata, KubeObjectScope, KubeJsonApiData } from "@k8slens/kube-object";
|
||||
import { KubeObject } from "@k8slens/kube-object";
|
||||
import type { AsyncResult } from "@k8slens/utilities";
|
||||
import { getErrorMessage } from "../../../../../common/utils/get-error-message";
|
||||
import type { Writable } from "type-fest";
|
||||
import type { KubeJsonApiData } from "../../../../../common/k8s-api/kube-json-api";
|
||||
import { parseKubeApi } from "../../../../../common/k8s-api/kube-api-parse";
|
||||
import apiKubeGetInjectable from "../../../../k8s/api-kube-get.injectable";
|
||||
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import editResourceTabStoreInjectable from "./store.injectable";
|
||||
import dockStoreInjectable from "../dock/store.injectable";
|
||||
import type { KubeObject } from "../../../../common/k8s-api/kube-object";
|
||||
import type { KubeObject } from "@k8slens/kube-object";
|
||||
import type { DockTabCreateSpecific, TabId } from "../dock/store";
|
||||
import { TabKind } from "../dock/store";
|
||||
import { runInAction } from "mobx";
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
import type { DockTabStoreDependencies } from "../dock-tab-store/dock-tab.store";
|
||||
import { DockTabStore } from "../dock-tab-store/dock-tab.store";
|
||||
import type { KubeObject } from "../../../../common/k8s-api/kube-object";
|
||||
import type { KubeObject } from "@k8slens/kube-object";
|
||||
|
||||
export interface EditingResource {
|
||||
resource: string; // resource path, e.g. /api/v1/namespaces/default
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import { Pod } from "../../../../../common/k8s-api/endpoints";
|
||||
import { Pod } from "@k8slens/kube-object";
|
||||
|
||||
export const dockerPod = new Pod({
|
||||
apiVersion: "v1",
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import type { PodLogsQuery } from "../../../../common/k8s-api/endpoints";
|
||||
import type { PodLogsQuery } from "@k8slens/kube-object";
|
||||
import podApiInjectable from "../../../../common/k8s-api/endpoints/pod.api.injectable";
|
||||
import type { ResourceDescriptor } from "../../../../common/k8s-api/kube-api";
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import type { Container, Pod } from "../../../../common/k8s-api/endpoints";
|
||||
import type { Container, Pod } from "@k8slens/kube-object";
|
||||
import type { TabId } from "../dock/store";
|
||||
import createLogsTabInjectable from "./create-logs-tab.injectable";
|
||||
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import type { GetPodsByOwnerId } from "../../workloads-pods/get-pods-by-owner-id.injectable";
|
||||
import getPodsByOwnerIdInjectable from "../../workloads-pods/get-pods-by-owner-id.injectable";
|
||||
import type { DaemonSet, Deployment, Job, ReplicaSet, StatefulSet } from "../../../../common/k8s-api/endpoints";
|
||||
import type { DaemonSet, Deployment, Job, ReplicaSet, StatefulSet } from "@k8slens/kube-object";
|
||||
import type { TabId } from "../dock/store";
|
||||
import type { CreateLogsTabData } from "./create-logs-tab.injectable";
|
||||
import createLogsTabInjectable from "./create-logs-tab.injectable";
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import type { PodLogsQuery } from "../../../../common/k8s-api/endpoints";
|
||||
import type { PodLogsQuery } from "@k8slens/kube-object";
|
||||
import type { ResourceDescriptor } from "../../../../common/k8s-api/kube-api";
|
||||
import loggerInjectable from "../../../../common/logger.injectable";
|
||||
import openSaveFileDialogInjectable from "../../../utils/save-file.injectable";
|
||||
@@ -18,7 +18,7 @@ const downloadAllLogsInjectable = getInjectable({
|
||||
const openSaveFileDialog = di.inject(openSaveFileDialogInjectable);
|
||||
const logger = di.inject(loggerInjectable);
|
||||
const showErrorNotification = di.inject(showErrorNotificationInjectable);
|
||||
|
||||
|
||||
return async (params: ResourceDescriptor, query: PodLogsQuery) => {
|
||||
const logs = await callForLogs(params, query).catch(error => {
|
||||
logger.error("Can't download logs: ", error);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import type { IComputedValue } from "mobx";
|
||||
import type { Pod } from "../../../../common/k8s-api/endpoints";
|
||||
import type { Pod } from "@k8slens/kube-object";
|
||||
import logStoreInjectable from "./store.injectable";
|
||||
import type { LogTabData } from "./tab-store";
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import type { IComputedValue } from "mobx";
|
||||
import { computed } from "mobx";
|
||||
import type { TabId } from "../dock/store";
|
||||
import type { SearchStore } from "../../../search-store/search-store";
|
||||
import type { Pod, PodLogsQuery } from "../../../../common/k8s-api/endpoints";
|
||||
import type { Pod, PodLogsQuery } from "@k8slens/kube-object";
|
||||
import { isDefined } from "@k8slens/utilities";
|
||||
import assert from "assert";
|
||||
import type { GetPodById } from "../../workloads-pods/get-pod-by-id.injectable";
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import type { IComputedValue } from "mobx";
|
||||
import type { Pod } from "../../../../common/k8s-api/endpoints";
|
||||
import type { Pod } from "@k8slens/kube-object";
|
||||
import logStoreInjectable from "./store.injectable";
|
||||
import type { LogTabData } from "./tab-store";
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import { Badge } from "../../badge";
|
||||
import type { SelectOption } from "../../select";
|
||||
import { Select } from "../../select";
|
||||
import type { LogTabViewModel } from "./logs-view-model";
|
||||
import type { Container, Pod } from "../../../../common/k8s-api/endpoints";
|
||||
import type { Container, Pod } from "@k8slens/kube-object";
|
||||
import type { SingleValue } from "react-select";
|
||||
|
||||
export interface LogResourceSelectorProps {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
import type { IComputedValue } from "mobx";
|
||||
import { observable } from "mobx";
|
||||
import type { PodLogsQuery, Pod } from "../../../../common/k8s-api/endpoints";
|
||||
import type { PodLogsQuery, Pod } from "@k8slens/kube-object";
|
||||
import { waitUntilDefined, getOrInsertWith, interval } from "@k8slens/utilities";
|
||||
import type { IntervalFn } from "@k8slens/utilities";
|
||||
import type { TabId } from "../dock/store";
|
||||
|
||||
@@ -7,7 +7,7 @@ import React from "react";
|
||||
import type { DrawerItemProps } from "./drawer-item";
|
||||
import { DrawerItem } from "./drawer-item";
|
||||
import { Badge } from "../badge";
|
||||
import { KubeObject } from "../../../common/k8s-api/kube-object";
|
||||
import { KubeObject } from "@k8slens/kube-object";
|
||||
|
||||
export interface DrawerItemLabelsProps extends DrawerItemProps {
|
||||
labels: string[] | Partial<Record<string, string>>;
|
||||
|
||||
@@ -11,7 +11,7 @@ import { DrawerItem, DrawerTitle } from "../drawer";
|
||||
import { Link } from "react-router-dom";
|
||||
import { observer } from "mobx-react";
|
||||
import type { KubeObjectDetailsProps } from "../kube-object-details";
|
||||
import { KubeEvent } from "../../../common/k8s-api/endpoints/events.api";
|
||||
import { KubeEvent } from "@k8slens/kube-object";
|
||||
import { Table, TableCell, TableHead, TableRow } from "../table";
|
||||
import type { ApiManager } from "../../../common/k8s-api/api-manager";
|
||||
import type { Logger } from "../../../common/logger";
|
||||
|
||||
@@ -13,8 +13,8 @@ import { TabLayout } from "../layout/tab-layout-2";
|
||||
import type { EventStore } from "./store";
|
||||
import type { KubeObjectListLayoutProps } from "../kube-object-list-layout";
|
||||
import { KubeObjectListLayout } from "../kube-object-list-layout";
|
||||
import type { KubeEvent, KubeEventApi, KubeEventData } from "../../../common/k8s-api/endpoints/events.api";
|
||||
import type { TableSortCallbacks, TableSortParams } from "../table";
|
||||
import type { KubeEvent, KubeEventData } from "@k8slens/kube-object";
|
||||
import type { TableSortParams, TableSortCallbacks } from "../table";
|
||||
import type { HeaderCustomizer } from "../item-object-list";
|
||||
import { Tooltip } from "@k8slens/tooltip";
|
||||
import { Link } from "react-router-dom";
|
||||
@@ -31,6 +31,7 @@ import eventStoreInjectable from "./store.injectable";
|
||||
import type { GetDetailsUrl } from "../kube-detail-params/get-details-url.injectable";
|
||||
import getDetailsUrlInjectable from "../kube-detail-params/get-details-url.injectable";
|
||||
import { NamespaceSelectBadge } from "../namespaces/namespace-select-badge";
|
||||
import type { KubeEventApi } from "../../../common/k8s-api/endpoints";
|
||||
|
||||
enum columnId {
|
||||
message = "message",
|
||||
@@ -64,10 +65,10 @@ interface Dependencies {
|
||||
class NonInjectedEvents extends React.Component<Dependencies & EventsProps> {
|
||||
static defaultProps = defaultProps as object;
|
||||
|
||||
@observable sorting: TableSortParams = {
|
||||
readonly sorting = observable.object<TableSortParams>({
|
||||
sortBy: columnId.age,
|
||||
orderBy: "asc",
|
||||
};
|
||||
});
|
||||
|
||||
private sortingCallbacks: TableSortCallbacks<KubeEvent> = {
|
||||
[columnId.namespace]: event => event.getNs(),
|
||||
@@ -162,7 +163,7 @@ class NonInjectedEvents extends React.Component<Dependencies & EventsProps> {
|
||||
tableProps={{
|
||||
sortSyncWithUrl: false,
|
||||
sortByDefault: this.sorting,
|
||||
onSort: params => this.sorting = params,
|
||||
onSort: params => Object.assign(this.sorting, params),
|
||||
}}
|
||||
sortingCallbacks={this.sortingCallbacks}
|
||||
searchFilters={[
|
||||
|
||||
@@ -7,7 +7,7 @@ import styles from "./kube-event-details.module.scss";
|
||||
|
||||
import React from "react";
|
||||
import { disposeOnUnmount, observer } from "mobx-react";
|
||||
import { KubeObject } from "../../../common/k8s-api/kube-object";
|
||||
import { KubeObject } from "@k8slens/kube-object";
|
||||
import { DrawerItem, DrawerTitle } from "../drawer";
|
||||
import { cssNames } from "@k8slens/utilities";
|
||||
import { LocaleDate } from "../locale-date";
|
||||
|
||||
@@ -7,9 +7,8 @@ import "./kube-event-icon.scss";
|
||||
|
||||
import React from "react";
|
||||
import { Icon } from "../icon";
|
||||
import type { KubeObject } from "../../../common/k8s-api/kube-object";
|
||||
import type { KubeObject, KubeEvent } from "@k8slens/kube-object";
|
||||
import { cssNames } from "@k8slens/utilities";
|
||||
import type { KubeEvent } from "../../../common/k8s-api/endpoints/events.api";
|
||||
import { KubeObjectAge } from "../kube-object/age";
|
||||
import type { EventStore } from "./store";
|
||||
import { withInjectables } from "@ogre-tools/injectable-react";
|
||||
|
||||
@@ -7,17 +7,19 @@ import groupBy from "lodash/groupBy";
|
||||
import compact from "lodash/compact";
|
||||
import type { KubeObjectStoreDependencies, KubeObjectStoreOptions } from "../../../common/k8s-api/kube-object.store";
|
||||
import { KubeObjectStore } from "../../../common/k8s-api/kube-object.store";
|
||||
import type { KubeEvent, KubeEventApi } from "../../../common/k8s-api/endpoints/events.api";
|
||||
import type { KubeObject } from "../../../common/k8s-api/kube-object";
|
||||
import { Pod } from "../../../common/k8s-api/endpoints/pod.api";
|
||||
import type { KubeEvent, KubeObject } from "@k8slens/kube-object";
|
||||
import { Pod } from "@k8slens/kube-object";
|
||||
import type { GetPodById } from "../workloads-pods/get-pod-by-id.injectable";
|
||||
import autoBind from "auto-bind";
|
||||
import type { KubeEventApi } from "../../../common/k8s-api/endpoints";
|
||||
|
||||
export interface EventStoreDependencies extends KubeObjectStoreDependencies {
|
||||
getPodById: GetPodById;
|
||||
}
|
||||
|
||||
export class EventStore extends KubeObjectStore<KubeEvent, KubeEventApi> {
|
||||
declare public readonly limit: number;
|
||||
|
||||
constructor(
|
||||
protected readonly dependencies: EventStoreDependencies,
|
||||
api: KubeEventApi,
|
||||
|
||||
@@ -73,7 +73,7 @@ class NonInjectedReleaseRollbackDialog extends React.Component<ReleaseRollbackDi
|
||||
await this.props.rollbackRelease(release.getName(), release.getNs(), revision.revision);
|
||||
this.close();
|
||||
} catch (err) {
|
||||
this.props.showCheckedErrorNotification(err, "Unknown error occured while rolling back release");
|
||||
this.props.showCheckedErrorNotification(err, "Unknown error occurred while rolling back release");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
+2
-2
@@ -13,7 +13,7 @@ import type { RequestHelmReleaseConfiguration } from "../../../../../common/k8s-
|
||||
import requestHelmReleaseConfigurationInjectable from "../../../../../common/k8s-api/endpoints/helm-releases.api/request-configuration.injectable";
|
||||
import { pipeline } from "@ogre-tools/fp";
|
||||
import { groupBy, map } from "lodash/fp";
|
||||
import type { KubeJsonApiData } from "../../../../../common/k8s-api/kube-json-api";
|
||||
import type { KubeJsonApiData } from "@k8slens/kube-object";
|
||||
import type { GetResourceDetailsUrl } from "./get-resource-details-url.injectable";
|
||||
import getResourceDetailsUrlInjectable from "./get-resource-details-url.injectable";
|
||||
import type { RequestHelmReleaseUpdate } from "../../../../../common/k8s-api/endpoints/helm-releases.api/request-update.injectable";
|
||||
@@ -131,7 +131,7 @@ export class ReleaseDetailsModel {
|
||||
if (!result.callWasSuccessful) {
|
||||
this.dependencies.showCheckedErrorNotification(
|
||||
result.error,
|
||||
"Unknown error occured while updating release",
|
||||
"Unknown error occurred while updating release",
|
||||
);
|
||||
|
||||
return;
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ import { getInjectable } from "@ogre-tools/injectable";
|
||||
import kubeDetailsUrlParamInjectable from "../kube-detail-params/kube-details-url.injectable";
|
||||
import apiManagerInjectable from "../../../common/k8s-api/api-manager/manager.injectable";
|
||||
import { asyncComputed } from "@ogre-tools/injectable-react";
|
||||
import type { KubeObject } from "../../../common/k8s-api/kube-object";
|
||||
import type { KubeObject } from "@k8slens/kube-object";
|
||||
|
||||
export type CurrentKubeObject =
|
||||
| undefined
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ import { kubeObjectDetailItemInjectionToken } from "../kube-object-detail-item-i
|
||||
import { computed } from "mobx";
|
||||
import { PodDisruptionBudgetDetails } from "../../../config-pod-disruption-budgets";
|
||||
import currentKubeObjectInDetailsInjectable from "../../current-kube-object-in-details.injectable";
|
||||
import { PodDisruptionBudget } from "../../../../../common/k8s-api/endpoints";
|
||||
import { PodDisruptionBudget } from "@k8slens/kube-object";
|
||||
|
||||
const podDisruptionBudgetDetailItemInjectable = getInjectable({
|
||||
id: "pod-disruption-budget-detail-item",
|
||||
|
||||
+2
-4
@@ -5,11 +5,9 @@
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { kubeObjectDetailItemInjectionToken } from "../kube-object-detail-item-injection-token";
|
||||
import { computed } from "mobx";
|
||||
import {
|
||||
kubeObjectMatchesToKindAndApiVersion,
|
||||
} from "../kube-object-matches-to-kind-and-api-version";
|
||||
import { kubeObjectMatchesToKindAndApiVersion } from "../kube-object-matches-to-kind-and-api-version";
|
||||
import currentKubeObjectInDetailsInjectable from "../../current-kube-object-in-details.injectable";
|
||||
import { ReplicationControllerDetails } from "../../../workloads-replicationcontrollers";
|
||||
import { ReplicationControllerDetails } from "../../../workloads-replication-controllers";
|
||||
|
||||
const replicationControllerDetailItemInjectable = getInjectable({
|
||||
id: "replication-controller-detail-item",
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import type { KubeObject } from "../../../../common/k8s-api/kube-object";
|
||||
import type { KubeObject } from "@k8slens/kube-object";
|
||||
|
||||
export const kubeObjectMatchesToKindAndApiVersion =
|
||||
(kind: string, apiVersions: string[]) =>
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import type { KubeObject } from "../../../common/k8s-api/kube-object";
|
||||
import type { KubeObject } from "@k8slens/kube-object";
|
||||
import type { KubeObjectDetailsProps } from "./kube-object-details";
|
||||
import type React from "react";
|
||||
import type { IComputedValue } from "mobx";
|
||||
|
||||
@@ -9,7 +9,7 @@ import React from "react";
|
||||
import { observer } from "mobx-react";
|
||||
import type { IComputedValue } from "mobx";
|
||||
import { Drawer } from "../drawer";
|
||||
import type { KubeObject } from "../../../common/k8s-api/kube-object";
|
||||
import type { KubeObject } from "@k8slens/kube-object";
|
||||
import { Spinner } from "../spinner";
|
||||
import { KubeObjectMenu } from "../kube-object-menu";
|
||||
import type { HideDetails } from "../kube-detail-params/hide-details.injectable";
|
||||
|
||||
+2
-2
@@ -10,7 +10,7 @@ import { computed, observable, reaction } from "mobx";
|
||||
import { disposeOnUnmount, observer } from "mobx-react";
|
||||
import type { Disposer } from "@k8slens/utilities";
|
||||
import { hasTypedProperty, isObject, isString, cssNames, isDefined } from "@k8slens/utilities";
|
||||
import type { KubeJsonApiDataFor, KubeObject } from "../../../common/k8s-api/kube-object";
|
||||
import type { KubeJsonApiDataFor, KubeObject } from "@k8slens/kube-object";
|
||||
import type { ItemListLayoutProps, ItemListStore } from "../item-object-list/list-layout";
|
||||
import { ItemListLayout } from "../item-object-list/list-layout";
|
||||
import { KubeObjectMenu } from "../kube-object-menu";
|
||||
@@ -39,7 +39,7 @@ export type KubeItemListStore<K extends KubeObject> = ItemListStore<K, false> &
|
||||
|
||||
export interface KubeObjectListLayoutProps<
|
||||
K extends KubeObject,
|
||||
// eslint-disable-next-line unused-imports/no-unused-vars-ts
|
||||
// eslint-disable-next-line unused-imports/no-unused-vars-ts, @typescript-eslint/no-unused-vars
|
||||
A extends KubeApi<K, D>,
|
||||
D extends KubeJsonApiDataFor<K>,
|
||||
> extends Omit<ItemListLayoutProps<K, false>, "getItems" | "dependentStores" | "preloadStores"> {
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
import { getInjectionToken } from "@ogre-tools/injectable";
|
||||
import type { IComputedValue } from "mobx";
|
||||
import type { KubeObjectMenuProps } from "./kube-object-menu";
|
||||
import type { KubeObject } from "../../../common/k8s-api/kube-object";
|
||||
import type { KubeObject } from "@k8slens/kube-object";
|
||||
import type React from "react";
|
||||
|
||||
export type KubeObjectMenuItemComponent = React.ElementType<
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
|
||||
|
||||
import type { KubeObject } from "../../../common/k8s-api/kube-object";
|
||||
import type { KubeObject } from "@k8slens/kube-object";
|
||||
import { computed } from "mobx";
|
||||
import { computedInjectManyInjectable } from "@ogre-tools/injectable-extension-for-mobx";
|
||||
import { kubeObjectMenuItemInjectionToken } from "./kube-object-menu-item-injection-token";
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
|
||||
import type { IComputedValue } from "mobx";
|
||||
import type React from "react";
|
||||
import type { KubeObject } from "../../../common/k8s-api/kube-object";
|
||||
import type { KubeObject } from "@k8slens/kube-object";
|
||||
|
||||
export interface KubeObjectMenuItemProps {
|
||||
object: KubeObject;
|
||||
|
||||
@@ -6,7 +6,7 @@ import React from "react";
|
||||
import type { RenderResult } from "@testing-library/react";
|
||||
import { screen, waitFor } from "@testing-library/react";
|
||||
import "@testing-library/jest-dom/extend-expect";
|
||||
import { KubeObject } from "../../../common/k8s-api/kube-object";
|
||||
import { KubeObject } from "@k8slens/kube-object";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import type { DiContainer } from "@ogre-tools/injectable";
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
import React from "react";
|
||||
import { cssNames } from "@k8slens/utilities";
|
||||
import type { KubeObject } from "../../../common/k8s-api/kube-object";
|
||||
import type { KubeObject } from "@k8slens/kube-object";
|
||||
import type { MenuActionsProps } from "../menu";
|
||||
import { MenuItem, MenuActions } from "../menu";
|
||||
import identity from "lodash/identity";
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import type { KubeObject } from "../../../common/k8s-api/kube-object";
|
||||
import type { KubeObject } from "@k8slens/kube-object";
|
||||
import type { KubeObjectOnContextMenuOpenContext } from "../../kube-object/handler";
|
||||
import kubeObjectHandlersInjectable from "../../kube-object/handlers.injectable";
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
*/
|
||||
|
||||
import React from "react";
|
||||
import type { KubeMetaField } from "../../../common/k8s-api/kube-object";
|
||||
import { KubeObject } from "../../../common/k8s-api/kube-object";
|
||||
import type { KubeMetaField } from "@k8slens/kube-object";
|
||||
import { KubeObject } from "@k8slens/kube-object";
|
||||
import { DrawerItem, DrawerItemLabels } from "../drawer";
|
||||
import type { ApiManager } from "../../../common/k8s-api/api-manager";
|
||||
import { Link } from "react-router-dom";
|
||||
@@ -34,8 +34,8 @@ interface Dependencies {
|
||||
logger: Logger;
|
||||
}
|
||||
|
||||
const NonInjectedKubeObjectMeta = observer((
|
||||
{
|
||||
const NonInjectedKubeObjectMeta = observer((props : Dependencies & KubeObjectMetaProps) => {
|
||||
const {
|
||||
apiManager,
|
||||
getDetailsUrl,
|
||||
object,
|
||||
@@ -46,8 +46,8 @@ const NonInjectedKubeObjectMeta = observer((
|
||||
],
|
||||
logger,
|
||||
namespaceApi,
|
||||
}
|
||||
: Dependencies & KubeObjectMetaProps) => {
|
||||
} = props;
|
||||
|
||||
if (!object) {
|
||||
return null;
|
||||
}
|
||||
@@ -60,15 +60,12 @@ const NonInjectedKubeObjectMeta = observer((
|
||||
|
||||
const isHidden = (field: KubeMetaField) => hideFields.includes(field);
|
||||
|
||||
const {
|
||||
getNs, getLabels, getResourceVersion, selfLink, getAnnotations,
|
||||
getFinalizers, getId, getName, metadata: { creationTimestamp },
|
||||
} = object;
|
||||
const { selfLink, metadata: { creationTimestamp }} = object;
|
||||
const ownerRefs = object.getOwnerRefs();
|
||||
const namespace = getNs();
|
||||
const namespaceDetailsUrl = namespace ? getDetailsUrl(
|
||||
namespaceApi.formatUrlForNotListing({ name: namespace }),
|
||||
) : "";
|
||||
const namespace = object.getNs();
|
||||
const namespaceDetailsUrl = namespace
|
||||
? getDetailsUrl(namespaceApi.formatUrlForNotListing({ name: namespace }))
|
||||
: "";
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -78,34 +75,34 @@ const NonInjectedKubeObjectMeta = observer((
|
||||
{creationTimestamp && <LocaleDate date={creationTimestamp} />}
|
||||
</DrawerItem>
|
||||
<DrawerItem name="Name" hidden={isHidden("name")}>
|
||||
{getName()}
|
||||
{object.getName()}
|
||||
<KubeObjectStatusIcon key="icon" object={object} />
|
||||
</DrawerItem>
|
||||
<DrawerItem name="Namespace" hidden={isHidden("namespace") || !namespace}>
|
||||
<Link to={namespaceDetailsUrl}>{namespace}</Link>
|
||||
</DrawerItem>
|
||||
<DrawerItem name="UID" hidden={isHidden("uid")}>
|
||||
{getId()}
|
||||
{object.getId()}
|
||||
</DrawerItem>
|
||||
<DrawerItem name="Link" hidden={isHidden("selfLink")}>
|
||||
{selfLink}
|
||||
</DrawerItem>
|
||||
<DrawerItem name="Resource Version" hidden={isHidden("resourceVersion")}>
|
||||
{getResourceVersion()}
|
||||
{object.getResourceVersion()}
|
||||
</DrawerItem>
|
||||
<DrawerItemLabels
|
||||
name="Labels"
|
||||
labels={getLabels()}
|
||||
labels={object.getLabels()}
|
||||
hidden={isHidden("labels")}
|
||||
/>
|
||||
<DrawerItemLabels
|
||||
name="Annotations"
|
||||
labels={getAnnotations()}
|
||||
labels={object.getAnnotations()}
|
||||
hidden={isHidden("annotations")}
|
||||
/>
|
||||
<DrawerItemLabels
|
||||
name="Finalizers"
|
||||
labels={getFinalizers()}
|
||||
labels={object.getFinalizers()}
|
||||
hidden={isHidden("finalizers")}
|
||||
/>
|
||||
{ownerRefs?.length > 0 && (
|
||||
|
||||
Loaded 100 of 466 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user