Add kube-version and distro on detail panel (#3335)

This commit is contained in:
Sebastian Malton authored and GitHub committed 2021-07-14 08:30:57 -04:00
1 parent 9c2942c333
commit 0a8cf96415
8 files changed
+95 -27

No files matched your search

+12 -10
View File
@@ -23,7 +23,7 @@ import "../common/cluster-ipc";
import type http from "http";
import { action, autorun, makeObservable, observable, observe, reaction, toJS } from "mobx";
import { ClusterId, ClusterStore, getClusterIdFromHost } from "../common/cluster-store";
import type { Cluster } from "./cluster";
import { Cluster } from "./cluster";
import logger from "./logger";
import { apiKubePrefix } from "../common/vars";
import { Singleton } from "../common/utils";
@@ -103,13 +103,13 @@ export class ClusterManager extends Singleton {
this.updateEntityStatus(entity, cluster);
entity.metadata.labels = Object.assign({}, cluster.labels, entity.metadata.labels);
entity.metadata.labels.distro = cluster.distribution;
if (cluster.preferences?.clusterName) {
entity.metadata.name = cluster.preferences.clusterName;
}
entity.metadata.labels = {
...entity.metadata.labels,
...cluster.labels,
};
entity.metadata.distro = cluster.distribution;
entity.metadata.kubeVersion = cluster.version;
entity.metadata.name = cluster.name;
entity.spec.metrics ||= { source: "local" };
if (entity.spec.metrics.source === "local") {
@@ -236,8 +236,10 @@ export function catalogEntityFromCluster(cluster: Cluster) {
name: cluster.name,
source: "local",
labels: {
distro: cluster.distribution,
}
...cluster.labels,
},
distro: cluster.distribution,
kubeVersion: cluster.version,
},
spec: {
kubeconfigPath: cluster.kubeConfigPath,
+11 -8
View File
@@ -235,8 +235,18 @@ export class Cluster implements ClusterModel, ClusterState {
return this.preferences.clusterName || this.contextName;
}
/**
* The detected kubernetes distribution
*/
@computed get distribution(): string {
return this.metadata.distribution?.toString() || "unknown";
return this.metadata[ClusterMetadataKey.DISTRIBUTION]?.toString() || "unknown";
}
/**
* The detected kubernetes version
*/
@computed get version(): string {
return this.metadata[ClusterMetadataKey.VERSION]?.toString() || "unknown";
}
/**
@@ -251,13 +261,6 @@ export class Cluster implements ClusterModel, ClusterState {
return toJS({ prometheus, prometheusProvider });
}
/**
* Kubernetes version
*/
get version(): string {
return String(this.metadata?.version ?? "");
}
constructor(model: ClusterModel) {
makeObservable(this);
this.id = model.id;