1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Fix KubernetesClusters overriding entity names too often (#3524)

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2021-07-29 05:11:45 -04:00 committed by GitHub
parent e43961ec4f
commit ad86502368
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -111,7 +111,15 @@ export class ClusterManager extends Singleton {
}; };
entity.metadata.distro = cluster.distribution; entity.metadata.distro = cluster.distribution;
entity.metadata.kubeVersion = cluster.version; entity.metadata.kubeVersion = cluster.version;
entity.metadata.name = cluster.name;
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;
}
entity.spec.metrics ||= { source: "local" }; entity.spec.metrics ||= { source: "local" };
if (entity.spec.metrics.source === "local") { if (entity.spec.metrics.source === "local") {
@ -164,14 +172,15 @@ export class ClusterManager extends Singleton {
if (!cluster) { if (!cluster) {
try { try {
/**
* Add the bare minimum of data to ClusterStore. And especially no
* preferences, as those might be configured by the entity's source
*/
this.store.addCluster({ this.store.addCluster({
id: entity.metadata.uid, id: entity.metadata.uid,
preferences: {
clusterName: entity.metadata.name
},
kubeConfigPath: entity.spec.kubeconfigPath, kubeConfigPath: entity.spec.kubeconfigPath,
contextName: entity.spec.kubeconfigContext, contextName: entity.spec.kubeconfigContext,
accessibleNamespaces: entity.spec.accessibleNamespaces accessibleNamespaces: entity.spec.accessibleNamespaces ?? [],
}); });
} catch (error) { } catch (error) {
if (error.code === "ENOENT" && error.path === entity.spec.kubeconfigPath) { if (error.code === "ENOENT" && error.path === entity.spec.kubeconfigPath) {