mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Add kube-version as entity label
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
ad8dc8a7c9
commit
d9214ea829
@ -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,
|
||||
distro: cluster.distribution,
|
||||
"kube-version": cluster.version,
|
||||
};
|
||||
entity.metadata.name = cluster.name;
|
||||
entity.spec.metrics ||= { source: "local" };
|
||||
|
||||
if (entity.spec.metrics.source === "local") {
|
||||
@ -236,7 +236,9 @@ export function catalogEntityFromCluster(cluster: Cluster) {
|
||||
name: cluster.name,
|
||||
source: "local",
|
||||
labels: {
|
||||
...cluster.labels,
|
||||
distro: cluster.distribution,
|
||||
"kube-version": cluster.version,
|
||||
}
|
||||
},
|
||||
spec: {
|
||||
|
||||
@ -234,8 +234,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";
|
||||
}
|
||||
|
||||
/**
|
||||
@ -250,13 +260,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;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user