mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
- requestNamespaceListPermissions is infallable so no need to have the extra try/catch - Refactor isMetricHidden method away from Cluster - Refactor shouldShowResource out of Cluster - Refactor isInLocalKubeconfig out of Cluster - Remove depecrated and unused workspace from Cluster - Refactor out kubectl as a dependency of Cluster - Remove from cluster getter used only once - Split out ClusterConnection from Cluster - Also split out KubeAuthProxyServer from ContextHandler - Rename ContextHandler to PrometheusHandler - Cleanup onNetworkOffline/Online impls within ClusterManager - Remove annotations from ClusterConnection - Remove mobx annotations from Cluster - Rename loadConfigFromFileInjectable - Remove all uses of dead createClusterInjectionToken - Fix type errors related to broadcastConnectionUpdate Signed-off-by: Sebastian Malton <sebastian@malton.name>
44 lines
1.5 KiB
TypeScript
44 lines
1.5 KiB
TypeScript
/**
|
|
* 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 { toJS } from "mobx";
|
|
import type { KubernetesCluster } from "../../common/catalog-entities";
|
|
import { ClusterMetadataKey } from "../../common/cluster-types";
|
|
import type { Cluster } from "../../common/cluster/cluster";
|
|
import { enumKeys } from "../../common/utils/enum";
|
|
|
|
export type UpdateEntityMetadata = (entity: KubernetesCluster, cluster: Cluster) => void;
|
|
|
|
const updateEntityMetadataInjectable = getInjectable({
|
|
id: "update-entity-metadata",
|
|
|
|
instantiate: (): UpdateEntityMetadata => {
|
|
return (entity, cluster) => {
|
|
entity.metadata.labels = {
|
|
...entity.metadata.labels,
|
|
...toJS(cluster.labels),
|
|
};
|
|
entity.metadata.distro = cluster.distribution.get();
|
|
entity.metadata.kubeVersion = cluster.version.get();
|
|
|
|
enumKeys(ClusterMetadataKey).forEach((key) => {
|
|
const metadataKey = ClusterMetadataKey[key];
|
|
|
|
entity.metadata[metadataKey] = cluster.metadata[metadataKey];
|
|
});
|
|
|
|
if (cluster.preferences?.clusterName) {
|
|
/**
|
|
* Only set the name if the it is overriden in preferences. If it isn't
|
|
* set then the name of the entity has been explicitly set by its source
|
|
*/
|
|
entity.metadata.name = cluster.preferences.clusterName;
|
|
}
|
|
};
|
|
},
|
|
});
|
|
|
|
export default updateEntityMetadataInjectable;
|