mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
fix replicaset.store.test.ts
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
c629d603fe
commit
474b509199
@ -8,6 +8,7 @@ import clusterRoleBindingApiInjectable from "./cluster-role-binding.api.injectab
|
|||||||
import clusterRoleApiInjectable from "./cluster-role.api.injectable";
|
import clusterRoleApiInjectable from "./cluster-role.api.injectable";
|
||||||
import daemonSetApiInjectable from "./daemon-set.api.injectable";
|
import daemonSetApiInjectable from "./daemon-set.api.injectable";
|
||||||
import podApiInjectable from "./pod.api.injectable";
|
import podApiInjectable from "./pod.api.injectable";
|
||||||
|
import replicaSetApiInjectable from "./replica-set.api.injectable";
|
||||||
import roleApiInjectable from "./role.api.injectable";
|
import roleApiInjectable from "./role.api.injectable";
|
||||||
import serviceAccountApiInjectable from "./service-account.api.injectable";
|
import serviceAccountApiInjectable from "./service-account.api.injectable";
|
||||||
|
|
||||||
@ -40,3 +41,8 @@ export const podApi = asLegacyGlobalForExtensionApi(podApiInjectable);
|
|||||||
* @deprecated use `di.inject(daemonSetApiInjectable)` instead
|
* @deprecated use `di.inject(daemonSetApiInjectable)` instead
|
||||||
*/
|
*/
|
||||||
export const daemonSetApi = asLegacyGlobalForExtensionApi(daemonSetApiInjectable);
|
export const daemonSetApi = asLegacyGlobalForExtensionApi(daemonSetApiInjectable);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use `di.inject(replicaSetApiInjectable)` instead
|
||||||
|
*/
|
||||||
|
export const replicaSetApi = asLegacyGlobalForExtensionApi(replicaSetApiInjectable);
|
||||||
|
|||||||
19
src/common/k8s-api/endpoints/replica-set.api.injectable.ts
Normal file
19
src/common/k8s-api/endpoints/replica-set.api.injectable.ts
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
|
import assert from "assert";
|
||||||
|
import { createStoresAndApisInjectionToken } from "../create-stores-apis.token";
|
||||||
|
import { ReplicaSetApi } from "./replica-set.api";
|
||||||
|
|
||||||
|
const replicaSetApiInjectable = getInjectable({
|
||||||
|
id: "replica-set-api",
|
||||||
|
instantiate: (di) => {
|
||||||
|
assert(di.inject(createStoresAndApisInjectionToken), "replicaSetApi is only available in certain environments");
|
||||||
|
|
||||||
|
return new ReplicaSetApi();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export default replicaSetApiInjectable;
|
||||||
@ -7,7 +7,6 @@ import type { DerivedKubeApiOptions, IgnoredKubeApiOptions } from "../kube-api";
|
|||||||
import { KubeApi } from "../kube-api";
|
import { KubeApi } from "../kube-api";
|
||||||
import { metricsApi } from "./metrics.api";
|
import { metricsApi } from "./metrics.api";
|
||||||
import type { PodMetricData } from "./pod.api";
|
import type { PodMetricData } from "./pod.api";
|
||||||
import { isClusterPageContext } from "../../utils/cluster-id-url-parsing";
|
|
||||||
import type { KubeObjectScope, KubeObjectStatus, LabelSelector } from "../kube-object";
|
import type { KubeObjectScope, KubeObjectStatus, LabelSelector } from "../kube-object";
|
||||||
import { KubeObject } from "../kube-object";
|
import { KubeObject } from "../kube-object";
|
||||||
import type { PodTemplateSpec } from "./types/pod-template-spec";
|
import type { PodTemplateSpec } from "./types/pod-template-spec";
|
||||||
@ -121,7 +120,3 @@ export class ReplicaSet extends KubeObject<ReplicaSetStatus, ReplicaSetSpec, Kub
|
|||||||
return containers.map(container => container.image);
|
return containers.map(container => container.image);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const replicaSetApi = isClusterPageContext()
|
|
||||||
? new ReplicaSetApi()
|
|
||||||
: undefined as never;
|
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import clusterRoleBindingApiInjectable from "../../common/k8s-api/endpoints/clus
|
|||||||
import clusterRoleApiInjectable from "../../common/k8s-api/endpoints/cluster-role.api.injectable";
|
import clusterRoleApiInjectable from "../../common/k8s-api/endpoints/cluster-role.api.injectable";
|
||||||
import daemonSetApiInjectable from "../../common/k8s-api/endpoints/daemon-set.api.injectable";
|
import daemonSetApiInjectable from "../../common/k8s-api/endpoints/daemon-set.api.injectable";
|
||||||
import podApiInjectable from "../../common/k8s-api/endpoints/pod.api.injectable";
|
import podApiInjectable from "../../common/k8s-api/endpoints/pod.api.injectable";
|
||||||
|
import replicaSetApiInjectable from "../../common/k8s-api/endpoints/replica-set.api.injectable";
|
||||||
import roleApiInjectable from "../../common/k8s-api/endpoints/role.api.injectable";
|
import roleApiInjectable from "../../common/k8s-api/endpoints/role.api.injectable";
|
||||||
import serviceAccountApiInjectable from "../../common/k8s-api/endpoints/service-account.api.injectable";
|
import serviceAccountApiInjectable from "../../common/k8s-api/endpoints/service-account.api.injectable";
|
||||||
import { asLegacyGlobalForExtensionApi } from "../as-legacy-globals-for-extension-api/as-legacy-global-object-for-extension-api";
|
import { asLegacyGlobalForExtensionApi } from "../as-legacy-globals-for-extension-api/as-legacy-global-object-for-extension-api";
|
||||||
@ -25,6 +26,7 @@ export const clusterRoleBindingApi = asLegacyGlobalForExtensionApi(clusterRoleBi
|
|||||||
export const roleApi = asLegacyGlobalForExtensionApi(roleApiInjectable);
|
export const roleApi = asLegacyGlobalForExtensionApi(roleApiInjectable);
|
||||||
export const podsApi = asLegacyGlobalForExtensionApi(podApiInjectable);
|
export const podsApi = asLegacyGlobalForExtensionApi(podApiInjectable);
|
||||||
export const daemonSetApi = asLegacyGlobalForExtensionApi(daemonSetApiInjectable);
|
export const daemonSetApi = asLegacyGlobalForExtensionApi(daemonSetApiInjectable);
|
||||||
|
export const replicaSetApi = asLegacyGlobalForExtensionApi(replicaSetApiInjectable);
|
||||||
|
|
||||||
export { ResourceStack } from "../../common/k8s/resource-stack";
|
export { ResourceStack } from "../../common/k8s/resource-stack";
|
||||||
export { apiManager } from "../../common/k8s-api/api-manager";
|
export { apiManager } from "../../common/k8s-api/api-manager";
|
||||||
@ -40,7 +42,7 @@ export { Job, jobApi } from "../../common/k8s-api/endpoints/job.api";
|
|||||||
export { CronJob, cronJobApi } from "../../common/k8s-api/endpoints/cron-job.api";
|
export { CronJob, cronJobApi } from "../../common/k8s-api/endpoints/cron-job.api";
|
||||||
export { ConfigMap, configMapApi } from "../../common/k8s-api/endpoints/configmap.api";
|
export { ConfigMap, configMapApi } from "../../common/k8s-api/endpoints/configmap.api";
|
||||||
export { Secret, secretApi as secretsApi } from "../../common/k8s-api/endpoints/secret.api";
|
export { Secret, secretApi as secretsApi } from "../../common/k8s-api/endpoints/secret.api";
|
||||||
export { ReplicaSet, replicaSetApi } from "../../common/k8s-api/endpoints/replica-set.api";
|
export { ReplicaSet } from "../../common/k8s-api/endpoints/replica-set.api";
|
||||||
export { ResourceQuota, resourceQuotaApi } from "../../common/k8s-api/endpoints/resource-quota.api";
|
export { ResourceQuota, resourceQuotaApi } from "../../common/k8s-api/endpoints/resource-quota.api";
|
||||||
export { LimitRange, limitRangeApi } from "../../common/k8s-api/endpoints/limit-range.api";
|
export { LimitRange, limitRangeApi } from "../../common/k8s-api/endpoints/limit-range.api";
|
||||||
export { HorizontalPodAutoscaler, horizontalPodAutoscalerApi as hpaApi } from "../../common/k8s-api/endpoints/hpa.api";
|
export { HorizontalPodAutoscaler, horizontalPodAutoscalerApi as hpaApi } from "../../common/k8s-api/endpoints/hpa.api";
|
||||||
|
|||||||
@ -14,6 +14,7 @@ import { asLegacyGlobalForExtensionApi } from "../as-legacy-globals-for-extensio
|
|||||||
import roleApiInjectable from "../../common/k8s-api/endpoints/role.api.injectable";
|
import roleApiInjectable from "../../common/k8s-api/endpoints/role.api.injectable";
|
||||||
import podApiInjectable from "../../common/k8s-api/endpoints/pod.api.injectable";
|
import podApiInjectable from "../../common/k8s-api/endpoints/pod.api.injectable";
|
||||||
import daemonSetApiInjectable from "../../common/k8s-api/endpoints/daemon-set.api.injectable";
|
import daemonSetApiInjectable from "../../common/k8s-api/endpoints/daemon-set.api.injectable";
|
||||||
|
import replicaSetApiInjectable from "../../common/k8s-api/endpoints/replica-set.api.injectable";
|
||||||
|
|
||||||
export function isAllowedResource(resource: KubeResource | KubeResource[]) {
|
export function isAllowedResource(resource: KubeResource | KubeResource[]) {
|
||||||
const resources = castArray(resource);
|
const resources = castArray(resource);
|
||||||
@ -34,6 +35,7 @@ export const clusterRoleBindingApi = asLegacyGlobalForExtensionApi(clusterRoleBi
|
|||||||
export const roleApi = asLegacyGlobalForExtensionApi(roleApiInjectable);
|
export const roleApi = asLegacyGlobalForExtensionApi(roleApiInjectable);
|
||||||
export const podsApi = asLegacyGlobalForExtensionApi(podApiInjectable);
|
export const podsApi = asLegacyGlobalForExtensionApi(podApiInjectable);
|
||||||
export const daemonSetApi = asLegacyGlobalForExtensionApi(daemonSetApiInjectable);
|
export const daemonSetApi = asLegacyGlobalForExtensionApi(daemonSetApiInjectable);
|
||||||
|
export const replicaSetApi = asLegacyGlobalForExtensionApi(replicaSetApiInjectable);
|
||||||
|
|
||||||
export {
|
export {
|
||||||
BaseKubeJsonApiObjectMetadata,
|
BaseKubeJsonApiObjectMetadata,
|
||||||
@ -52,7 +54,7 @@ export { Job, jobApi } from "../../common/k8s-api/endpoints/job.api";
|
|||||||
export { CronJob, cronJobApi } from "../../common/k8s-api/endpoints/cron-job.api";
|
export { CronJob, cronJobApi } from "../../common/k8s-api/endpoints/cron-job.api";
|
||||||
export { ConfigMap, configMapApi } from "../../common/k8s-api/endpoints/configmap.api";
|
export { ConfigMap, configMapApi } from "../../common/k8s-api/endpoints/configmap.api";
|
||||||
export { Secret, secretApi as secretsApi } from "../../common/k8s-api/endpoints/secret.api";
|
export { Secret, secretApi as secretsApi } from "../../common/k8s-api/endpoints/secret.api";
|
||||||
export { ReplicaSet, replicaSetApi } from "../../common/k8s-api/endpoints/replica-set.api";
|
export { ReplicaSet } from "../../common/k8s-api/endpoints/replica-set.api";
|
||||||
export { ResourceQuota, resourceQuotaApi } from "../../common/k8s-api/endpoints/resource-quota.api";
|
export { ResourceQuota, resourceQuotaApi } from "../../common/k8s-api/endpoints/resource-quota.api";
|
||||||
export { LimitRange, limitRangeApi } from "../../common/k8s-api/endpoints/limit-range.api";
|
export { LimitRange, limitRangeApi } from "../../common/k8s-api/endpoints/limit-range.api";
|
||||||
export { HorizontalPodAutoscaler, horizontalPodAutoscalerApi as hpaApi } from "../../common/k8s-api/endpoints/hpa.api";
|
export { HorizontalPodAutoscaler, horizontalPodAutoscalerApi as hpaApi } from "../../common/k8s-api/endpoints/hpa.api";
|
||||||
@ -93,7 +95,7 @@ export type { JobStore } from "../../renderer/components/+workloads-jobs/job.sto
|
|||||||
export type { CronJobStore } from "../../renderer/components/+workloads-cronjobs/cronjob.store";
|
export type { CronJobStore } from "../../renderer/components/+workloads-cronjobs/cronjob.store";
|
||||||
export type { ConfigMapStore as ConfigMapsStore } from "../../renderer/components/+config-maps/config-maps.store";
|
export type { ConfigMapStore as ConfigMapsStore } from "../../renderer/components/+config-maps/config-maps.store";
|
||||||
export type { SecretStore as SecretsStore } from "../../renderer/components/+config-secrets/secrets.store";
|
export type { SecretStore as SecretsStore } from "../../renderer/components/+config-secrets/secrets.store";
|
||||||
export type { ReplicaSetStore } from "../../renderer/components/+workloads-replicasets/replicasets.store";
|
export type { ReplicaSetStore } from "../../renderer/components/+workloads-replicasets/store";
|
||||||
export type { ResourceQuotaStore as ResourceQuotasStore } from "../../renderer/components/+config-resource-quotas/resource-quotas.store";
|
export type { ResourceQuotaStore as ResourceQuotasStore } from "../../renderer/components/+config-resource-quotas/resource-quotas.store";
|
||||||
export type { LimitRangeStore as LimitRangesStore } from "../../renderer/components/+config-limit-ranges/limit-ranges.store";
|
export type { LimitRangeStore as LimitRangesStore } from "../../renderer/components/+config-limit-ranges/limit-ranges.store";
|
||||||
export type { HorizontalPodAutoscalerStore as HPAStore } from "../../renderer/components/+config-autoscalers/hpa.store";
|
export type { HorizontalPodAutoscalerStore as HPAStore } from "../../renderer/components/+config-autoscalers/hpa.store";
|
||||||
|
|||||||
@ -21,7 +21,7 @@ import { PodCharts, podMetricTabs } from "../+workloads-pods/pod-charts";
|
|||||||
import { makeObservable, observable, reaction } from "mobx";
|
import { makeObservable, observable, reaction } from "mobx";
|
||||||
import { PodDetailsList } from "../+workloads-pods/pod-details-list";
|
import { PodDetailsList } from "../+workloads-pods/pod-details-list";
|
||||||
import { KubeObjectMeta } from "../kube-object-meta";
|
import { KubeObjectMeta } from "../kube-object-meta";
|
||||||
import { replicaSetStore } from "../+workloads-replicasets/replicasets.store";
|
import type { ReplicaSetStore } from "../+workloads-replicasets/store";
|
||||||
import { DeploymentReplicaSets } from "./deployment-replicasets";
|
import { DeploymentReplicaSets } from "./deployment-replicasets";
|
||||||
import { getActiveClusterEntity } from "../../api/catalog-entity-registry";
|
import { getActiveClusterEntity } from "../../api/catalog-entity-registry";
|
||||||
import { ClusterMetricsResourceType } from "../../../common/cluster-types";
|
import { ClusterMetricsResourceType } from "../../../common/cluster-types";
|
||||||
@ -31,6 +31,7 @@ import type { SubscribeStores } from "../../kube-watch-api/kube-watch-api";
|
|||||||
import subscribeStoresInjectable from "../../kube-watch-api/subscribe-stores.injectable";
|
import subscribeStoresInjectable from "../../kube-watch-api/subscribe-stores.injectable";
|
||||||
import type { PodStore } from "../+workloads-pods/store";
|
import type { PodStore } from "../+workloads-pods/store";
|
||||||
import podStoreInjectable from "../+workloads-pods/store.injectable";
|
import podStoreInjectable from "../+workloads-pods/store.injectable";
|
||||||
|
import replicaSetStoreInjectable from "../+workloads-replicasets/store.injectable";
|
||||||
|
|
||||||
export interface DeploymentDetailsProps extends KubeObjectDetailsProps<Deployment> {
|
export interface DeploymentDetailsProps extends KubeObjectDetailsProps<Deployment> {
|
||||||
}
|
}
|
||||||
@ -38,6 +39,7 @@ export interface DeploymentDetailsProps extends KubeObjectDetailsProps<Deploymen
|
|||||||
interface Dependencies {
|
interface Dependencies {
|
||||||
subscribeStores: SubscribeStores;
|
subscribeStores: SubscribeStores;
|
||||||
podStore: PodStore;
|
podStore: PodStore;
|
||||||
|
replicaSetStore: ReplicaSetStore;
|
||||||
}
|
}
|
||||||
|
|
||||||
@observer
|
@observer
|
||||||
@ -57,7 +59,7 @@ class NonInjectedDeploymentDetails extends React.Component<DeploymentDetailsProp
|
|||||||
|
|
||||||
this.props.subscribeStores([
|
this.props.subscribeStores([
|
||||||
this.props.podStore,
|
this.props.podStore,
|
||||||
replicaSetStore,
|
this.props.replicaSetStore,
|
||||||
]),
|
]),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@ -69,7 +71,7 @@ class NonInjectedDeploymentDetails extends React.Component<DeploymentDetailsProp
|
|||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { object: deployment, podStore } = this.props;
|
const { object: deployment, podStore, replicaSetStore } = this.props;
|
||||||
|
|
||||||
if (!deployment) {
|
if (!deployment) {
|
||||||
return null;
|
return null;
|
||||||
@ -168,6 +170,7 @@ export const DeploymentDetails = withInjectables<Dependencies, DeploymentDetails
|
|||||||
...props,
|
...props,
|
||||||
subscribeStores: di.inject(subscribeStoresInjectable),
|
subscribeStores: di.inject(subscribeStoresInjectable),
|
||||||
podStore: di.inject(podStoreInjectable),
|
podStore: di.inject(podStoreInjectable),
|
||||||
|
replicaSetStore: di.inject(replicaSetStoreInjectable),
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -15,7 +15,7 @@ import { prevDefault, stopPropagation } from "../../utils";
|
|||||||
import { DrawerTitle } from "../drawer";
|
import { DrawerTitle } from "../drawer";
|
||||||
import { Table, TableCell, TableHead, TableRow } from "../table";
|
import { Table, TableCell, TableHead, TableRow } from "../table";
|
||||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
||||||
import { replicaSetStore } from "../+workloads-replicasets/replicasets.store";
|
import { replicaSetStore } from "../+workloads-replicasets/legacy-store";
|
||||||
import { showDetails } from "../kube-detail-params";
|
import { showDetails } from "../kube-detail-params";
|
||||||
import { KubeObjectAge } from "../kube-object/age";
|
import { KubeObjectAge } from "../kube-object/age";
|
||||||
|
|
||||||
|
|||||||
@ -10,7 +10,6 @@ import { disposeOnUnmount, observer } from "mobx-react";
|
|||||||
import { eventStore } from "../+events/event.store";
|
import { eventStore } from "../+events/event.store";
|
||||||
import { deploymentStore } from "../+workloads-deployments/deployments.store";
|
import { deploymentStore } from "../+workloads-deployments/deployments.store";
|
||||||
import { statefulSetStore } from "../+workloads-statefulsets/statefulset.store";
|
import { statefulSetStore } from "../+workloads-statefulsets/statefulset.store";
|
||||||
import { replicaSetStore } from "../+workloads-replicasets/replicasets.store";
|
|
||||||
import { jobStore } from "../+workloads-jobs/job.store";
|
import { jobStore } from "../+workloads-jobs/job.store";
|
||||||
import { cronJobStore } from "../+workloads-cronjobs/cronjob.store";
|
import { cronJobStore } from "../+workloads-cronjobs/cronjob.store";
|
||||||
import type { IComputedValue } from "mobx";
|
import type { IComputedValue } from "mobx";
|
||||||
@ -29,6 +28,8 @@ import type { DaemonSetStore } from "../+workloads-daemonsets/store";
|
|||||||
import subscribeStoresInjectable from "../../kube-watch-api/subscribe-stores.injectable";
|
import subscribeStoresInjectable from "../../kube-watch-api/subscribe-stores.injectable";
|
||||||
import daemonSetStoreInjectable from "../+workloads-daemonsets/store.injectable";
|
import daemonSetStoreInjectable from "../+workloads-daemonsets/store.injectable";
|
||||||
import podStoreInjectable from "../+workloads-pods/store.injectable";
|
import podStoreInjectable from "../+workloads-pods/store.injectable";
|
||||||
|
import type { ReplicaSetStore } from "../+workloads-replicasets/store";
|
||||||
|
import replicaSetStoreInjectable from "../+workloads-replicasets/store.injectable";
|
||||||
|
|
||||||
interface Dependencies {
|
interface Dependencies {
|
||||||
detailComponents: IComputedValue<React.ComponentType<{}>[]>;
|
detailComponents: IComputedValue<React.ComponentType<{}>[]>;
|
||||||
@ -36,6 +37,7 @@ interface Dependencies {
|
|||||||
subscribeStores: SubscribeStores;
|
subscribeStores: SubscribeStores;
|
||||||
podStore: PodStore;
|
podStore: PodStore;
|
||||||
daemonSetStore: DaemonSetStore;
|
daemonSetStore: DaemonSetStore;
|
||||||
|
replicaSetStore: ReplicaSetStore;
|
||||||
}
|
}
|
||||||
|
|
||||||
@observer
|
@observer
|
||||||
@ -56,7 +58,7 @@ class NonInjectedWorkloadsOverview extends React.Component<Dependencies> {
|
|||||||
eventStore,
|
eventStore,
|
||||||
jobStore,
|
jobStore,
|
||||||
this.props.podStore,
|
this.props.podStore,
|
||||||
replicaSetStore,
|
this.props.replicaSetStore,
|
||||||
statefulSetStore,
|
statefulSetStore,
|
||||||
], {
|
], {
|
||||||
onLoadFailure: error => this.loadErrors.push(String(error)),
|
onLoadFailure: error => this.loadErrors.push(String(error)),
|
||||||
@ -115,5 +117,6 @@ export const WorkloadsOverview = withInjectables<Dependencies>(NonInjectedWorklo
|
|||||||
subscribeStores: di.inject(subscribeStoresInjectable),
|
subscribeStores: di.inject(subscribeStoresInjectable),
|
||||||
daemonSetStore: di.inject(daemonSetStoreInjectable),
|
daemonSetStore: di.inject(daemonSetStoreInjectable),
|
||||||
podStore: di.inject(podStoreInjectable),
|
podStore: di.inject(podStoreInjectable),
|
||||||
|
replicaSetStore: di.inject(replicaSetStoreInjectable),
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|||||||
@ -7,7 +7,7 @@ import { workloadInjectionToken } from "../workload-injection-token";
|
|||||||
import { ResourceNames } from "../../../../utils/rbac";
|
import { ResourceNames } from "../../../../utils/rbac";
|
||||||
import navigateToPodsInjectable from "../../../../../common/front-end-routing/routes/cluster/workloads/deployments/navigate-to-deployments.injectable";
|
import navigateToPodsInjectable from "../../../../../common/front-end-routing/routes/cluster/workloads/deployments/navigate-to-deployments.injectable";
|
||||||
import namespaceStoreInjectable from "../../../+namespaces/namespace-store/namespace-store.injectable";
|
import namespaceStoreInjectable from "../../../+namespaces/namespace-store/namespace-store.injectable";
|
||||||
import replicasetsStoreInjectable from "../../../+workloads-replicasets/replicasets-store.injectable";
|
import replicasetsStoreInjectable from "../../../+workloads-replicasets/store.injectable";
|
||||||
import { computed } from "mobx";
|
import { computed } from "mobx";
|
||||||
|
|
||||||
const replicasetsWorkloadInjectable = getInjectable({
|
const replicasetsWorkloadInjectable = getInjectable({
|
||||||
|
|||||||
@ -0,0 +1,12 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { asLegacyGlobalForExtensionApi } from "../../../extensions/as-legacy-globals-for-extension-api/as-legacy-global-object-for-extension-api";
|
||||||
|
import replicaSetStoreInjectable from "./store.injectable";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use `di.inject(replicaSetStoreInjectable)` instead
|
||||||
|
*/
|
||||||
|
export const replicaSetStore = asLegacyGlobalForExtensionApi(replicaSetStoreInjectable);
|
||||||
@ -8,7 +8,6 @@ import React from "react";
|
|||||||
import { makeObservable, observable, reaction } from "mobx";
|
import { makeObservable, observable, reaction } from "mobx";
|
||||||
import { DrawerItem } from "../drawer";
|
import { DrawerItem } from "../drawer";
|
||||||
import { Badge } from "../badge";
|
import { Badge } from "../badge";
|
||||||
import { replicaSetStore } from "./replicasets.store";
|
|
||||||
import { PodDetailsStatuses } from "../+workloads-pods/pod-details-statuses";
|
import { PodDetailsStatuses } from "../+workloads-pods/pod-details-statuses";
|
||||||
import { PodDetailsTolerations } from "../+workloads-pods/pod-details-tolerations";
|
import { PodDetailsTolerations } from "../+workloads-pods/pod-details-tolerations";
|
||||||
import { PodDetailsAffinities } from "../+workloads-pods/pod-details-affinities";
|
import { PodDetailsAffinities } from "../+workloads-pods/pod-details-affinities";
|
||||||
@ -28,6 +27,8 @@ import type { SubscribeStores } from "../../kube-watch-api/kube-watch-api";
|
|||||||
import subscribeStoresInjectable from "../../kube-watch-api/subscribe-stores.injectable";
|
import subscribeStoresInjectable from "../../kube-watch-api/subscribe-stores.injectable";
|
||||||
import type { PodStore } from "../+workloads-pods/store";
|
import type { PodStore } from "../+workloads-pods/store";
|
||||||
import podStoreInjectable from "../+workloads-pods/store.injectable";
|
import podStoreInjectable from "../+workloads-pods/store.injectable";
|
||||||
|
import type { ReplicaSetStore } from "./store";
|
||||||
|
import replicaSetStoreInjectable from "./store.injectable";
|
||||||
|
|
||||||
export interface ReplicaSetDetailsProps extends KubeObjectDetailsProps<ReplicaSet> {
|
export interface ReplicaSetDetailsProps extends KubeObjectDetailsProps<ReplicaSet> {
|
||||||
}
|
}
|
||||||
@ -35,6 +36,7 @@ export interface ReplicaSetDetailsProps extends KubeObjectDetailsProps<ReplicaSe
|
|||||||
interface Dependencies {
|
interface Dependencies {
|
||||||
subscribeStores: SubscribeStores;
|
subscribeStores: SubscribeStores;
|
||||||
podStore: PodStore;
|
podStore: PodStore;
|
||||||
|
replicaSetStore: ReplicaSetStore;
|
||||||
}
|
}
|
||||||
|
|
||||||
@observer
|
@observer
|
||||||
@ -65,7 +67,7 @@ class NonInjectedReplicaSetDetails extends React.Component<ReplicaSetDetailsProp
|
|||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { object: replicaSet, podStore } = this.props;
|
const { object: replicaSet, podStore, replicaSetStore } = this.props;
|
||||||
|
|
||||||
if (!replicaSet) {
|
if (!replicaSet) {
|
||||||
return null;
|
return null;
|
||||||
@ -138,5 +140,6 @@ export const ReplicaSetDetails = withInjectables<Dependencies, ReplicaSetDetails
|
|||||||
...props,
|
...props,
|
||||||
subscribeStores: di.inject(subscribeStoresInjectable),
|
subscribeStores: di.inject(subscribeStoresInjectable),
|
||||||
podStore: di.inject(podStoreInjectable),
|
podStore: di.inject(podStoreInjectable),
|
||||||
|
replicaSetStore: di.inject(replicaSetStoreInjectable),
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,14 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
|
||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
|
||||||
*/
|
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
|
||||||
import { replicaSetStore } from "./replicasets.store";
|
|
||||||
|
|
||||||
const replicasetsStoreInjectable = getInjectable({
|
|
||||||
id: "replicasets-store",
|
|
||||||
instantiate: () => replicaSetStore,
|
|
||||||
causesSideEffects: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
export default replicasetsStoreInjectable;
|
|
||||||
@ -7,7 +7,7 @@ import "./replicasets.scss";
|
|||||||
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { observer } from "mobx-react";
|
import { observer } from "mobx-react";
|
||||||
import { replicaSetStore } from "./replicasets.store";
|
import { replicaSetStore } from "./legacy-store";
|
||||||
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
import { KubeObjectStatusIcon } from "../kube-object-status-icon";
|
||||||
import { KubeObjectListLayout } from "../kube-object-list-layout";
|
import { KubeObjectListLayout } from "../kube-object-list-layout";
|
||||||
import { eventStore } from "../+events/event.store";
|
import { eventStore } from "../+events/event.store";
|
||||||
|
|||||||
@ -0,0 +1,30 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
|
*/
|
||||||
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
|
import assert from "assert";
|
||||||
|
import getPodsByOwnerIdInjectable from "../+workloads-pods/get-pods-by-owner-id.injectable";
|
||||||
|
import replicaSetApiInjectable from "../../../common/k8s-api/endpoints/replica-set.api.injectable";
|
||||||
|
import createStoresAndApisInjectable from "../../create-stores-apis.injectable";
|
||||||
|
import apiManagerInjectable from "../kube-object-menu/dependencies/api-manager.injectable";
|
||||||
|
import { ReplicaSetStore } from "./store";
|
||||||
|
|
||||||
|
const replicaSetStoreInjectable = getInjectable({
|
||||||
|
id: "replica-set-store",
|
||||||
|
instantiate: (di) => {
|
||||||
|
assert(di.inject(createStoresAndApisInjectable), "replicaSetStore is only available in certain environments");
|
||||||
|
|
||||||
|
const api = di.inject(replicaSetApiInjectable);
|
||||||
|
const apiManager = di.inject(apiManagerInjectable);
|
||||||
|
const store = new ReplicaSetStore({
|
||||||
|
getPodsByOwnerId: di.inject(getPodsByOwnerIdInjectable),
|
||||||
|
}, api);
|
||||||
|
|
||||||
|
apiManager.registerStore(store);
|
||||||
|
|
||||||
|
return store;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export default replicaSetStoreInjectable;
|
||||||
@ -3,17 +3,23 @@
|
|||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { podStore } from "../+workloads-pods/legacy-store";
|
import type { GetPodsByOwnerId } from "../+workloads-pods/get-pods-by-owner-id.injectable";
|
||||||
import { apiManager } from "../../../common/k8s-api/api-manager";
|
|
||||||
import type { Deployment, ReplicaSet, ReplicaSetApi } from "../../../common/k8s-api/endpoints";
|
import type { Deployment, ReplicaSet, ReplicaSetApi } from "../../../common/k8s-api/endpoints";
|
||||||
import { replicaSetApi } from "../../../common/k8s-api/endpoints";
|
|
||||||
import { PodStatusPhase } from "../../../common/k8s-api/endpoints/pod.api";
|
import { PodStatusPhase } from "../../../common/k8s-api/endpoints/pod.api";
|
||||||
|
import type { KubeObjectStoreOptions } from "../../../common/k8s-api/kube-object.store";
|
||||||
import { KubeObjectStore } from "../../../common/k8s-api/kube-object.store";
|
import { KubeObjectStore } from "../../../common/k8s-api/kube-object.store";
|
||||||
import { isClusterPageContext } from "../../utils";
|
|
||||||
|
export interface ReplicaSetStoreDependencies {
|
||||||
|
getPodsByOwnerId: GetPodsByOwnerId;
|
||||||
|
}
|
||||||
|
|
||||||
export class ReplicaSetStore extends KubeObjectStore<ReplicaSet, ReplicaSetApi> {
|
export class ReplicaSetStore extends KubeObjectStore<ReplicaSet, ReplicaSetApi> {
|
||||||
|
constructor(protected readonly dependencies: ReplicaSetStoreDependencies, api: ReplicaSetApi, opts?: KubeObjectStoreOptions) {
|
||||||
|
super(api, opts);
|
||||||
|
}
|
||||||
|
|
||||||
getChildPods(replicaSet: ReplicaSet) {
|
getChildPods(replicaSet: ReplicaSet) {
|
||||||
return podStore.getPodsByOwnerId(replicaSet.getId());
|
return this.dependencies.getPodsByOwnerId(replicaSet.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
getStatuses(replicaSets: ReplicaSet[]) {
|
getStatuses(replicaSets: ReplicaSet[]) {
|
||||||
@ -40,11 +46,3 @@ export class ReplicaSetStore extends KubeObjectStore<ReplicaSet, ReplicaSetApi>
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const replicaSetStore = isClusterPageContext()
|
|
||||||
? new ReplicaSetStore(replicaSetApi)
|
|
||||||
: undefined as never;
|
|
||||||
|
|
||||||
if (isClusterPageContext()) {
|
|
||||||
apiManager.registerStore(replicaSetStore);
|
|
||||||
}
|
|
||||||
@ -133,7 +133,7 @@ const failedPod = new Pod({
|
|||||||
describe("DaemonSet Store tests", () => {
|
describe("DaemonSet Store tests", () => {
|
||||||
let daemonSetStore: DaemonSetStore;
|
let daemonSetStore: DaemonSetStore;
|
||||||
|
|
||||||
beforeAll(() => {
|
beforeEach(() => {
|
||||||
const di = getDiForUnitTesting({ doGeneralOverrides: true });
|
const di = getDiForUnitTesting({ doGeneralOverrides: true });
|
||||||
|
|
||||||
di.override(createStoresAndApisInjectable, () => true);
|
di.override(createStoresAndApisInjectable, () => true);
|
||||||
|
|||||||
@ -4,9 +4,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { observable } from "mobx";
|
import { observable } from "mobx";
|
||||||
import { podStore } from "../+workloads-pods/legacy-store";
|
import podStoreInjectable from "../+workloads-pods/store.injectable";
|
||||||
import { replicaSetStore } from "../+workloads-replicasets/replicasets.store";
|
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 "../../../common/k8s-api/endpoints";
|
||||||
|
import createStoresAndApisInjectable from "../../create-stores-apis.injectable";
|
||||||
|
import { getDiForUnitTesting } from "../../getDiForUnitTesting";
|
||||||
|
|
||||||
const runningReplicaSet = new ReplicaSet({
|
const runningReplicaSet = new ReplicaSet({
|
||||||
apiVersion: "foo",
|
apiVersion: "foo",
|
||||||
@ -128,7 +131,16 @@ const failedPod = new Pod({
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("ReplicaSet Store tests", () => {
|
describe("ReplicaSet Store tests", () => {
|
||||||
beforeAll(() => {
|
let replicaSetStore: ReplicaSetStore;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
const di = getDiForUnitTesting({ doGeneralOverrides: true });
|
||||||
|
|
||||||
|
di.override(createStoresAndApisInjectable, () => true);
|
||||||
|
|
||||||
|
const podStore = di.inject(podStoreInjectable);
|
||||||
|
|
||||||
|
replicaSetStore = di.inject(replicasetsStoreInjectable);
|
||||||
podStore.items = observable.array([
|
podStore.items = observable.array([
|
||||||
runningPod,
|
runningPod,
|
||||||
failedPod,
|
failedPod,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user