Skip to content

Commit

Permalink
Fix KubernetesClusters overriding entity names too often (#3524)
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian Malton <[email protected]>
  • Loading branch information
Nokel81 authored Jul 29, 2021
1 parent e43961e commit ad86502
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/main/cluster-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,15 @@ export class ClusterManager extends Singleton {
};
entity.metadata.distro = cluster.distribution;
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" };

if (entity.spec.metrics.source === "local") {
Expand Down Expand Up @@ -164,14 +172,15 @@ export class ClusterManager extends Singleton {

if (!cluster) {
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({
id: entity.metadata.uid,
preferences: {
clusterName: entity.metadata.name
},
kubeConfigPath: entity.spec.kubeconfigPath,
contextName: entity.spec.kubeconfigContext,
accessibleNamespaces: entity.spec.accessibleNamespaces
accessibleNamespaces: entity.spec.accessibleNamespaces ?? [],
});
} catch (error) {
if (error.code === "ENOENT" && error.path === entity.spec.kubeconfigPath) {
Expand Down

0 comments on commit ad86502

Please sign in to comment.