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 type http from "http";
|
||||||
import { action, autorun, makeObservable, observable, observe, reaction, toJS } from "mobx";
|
import { action, autorun, makeObservable, observable, observe, reaction, toJS } from "mobx";
|
||||||
import { ClusterId, ClusterStore, getClusterIdFromHost } from "../common/cluster-store";
|
import { ClusterId, ClusterStore, getClusterIdFromHost } from "../common/cluster-store";
|
||||||
import type { Cluster } from "./cluster";
|
import { Cluster } from "./cluster";
|
||||||
import logger from "./logger";
|
import logger from "./logger";
|
||||||
import { apiKubePrefix } from "../common/vars";
|
import { apiKubePrefix } from "../common/vars";
|
||||||
import { Singleton } from "../common/utils";
|
import { Singleton } from "../common/utils";
|
||||||
@ -103,13 +103,13 @@ export class ClusterManager extends Singleton {
|
|||||||
|
|
||||||
this.updateEntityStatus(entity, cluster);
|
this.updateEntityStatus(entity, cluster);
|
||||||
|
|
||||||
entity.metadata.labels = Object.assign({}, cluster.labels, entity.metadata.labels);
|
entity.metadata.labels = {
|
||||||
entity.metadata.labels.distro = cluster.distribution;
|
...entity.metadata.labels,
|
||||||
|
...cluster.labels,
|
||||||
if (cluster.preferences?.clusterName) {
|
distro: cluster.distribution,
|
||||||
entity.metadata.name = cluster.preferences.clusterName;
|
"kube-version": cluster.version,
|
||||||
}
|
};
|
||||||
|
entity.metadata.name = cluster.name;
|
||||||
entity.spec.metrics ||= { source: "local" };
|
entity.spec.metrics ||= { source: "local" };
|
||||||
|
|
||||||
if (entity.spec.metrics.source === "local") {
|
if (entity.spec.metrics.source === "local") {
|
||||||
@ -236,7 +236,9 @@ export function catalogEntityFromCluster(cluster: Cluster) {
|
|||||||
name: cluster.name,
|
name: cluster.name,
|
||||||
source: "local",
|
source: "local",
|
||||||
labels: {
|
labels: {
|
||||||
|
...cluster.labels,
|
||||||
distro: cluster.distribution,
|
distro: cluster.distribution,
|
||||||
|
"kube-version": cluster.version,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
spec: {
|
spec: {
|
||||||
|
|||||||
@ -234,8 +234,18 @@ export class Cluster implements ClusterModel, ClusterState {
|
|||||||
return this.preferences.clusterName || this.contextName;
|
return this.preferences.clusterName || this.contextName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The detected kubernetes distribution
|
||||||
|
*/
|
||||||
@computed get distribution(): string {
|
@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 });
|
return toJS({ prometheus, prometheusProvider });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Kubernetes version
|
|
||||||
*/
|
|
||||||
get version(): string {
|
|
||||||
return String(this.metadata?.version ?? "");
|
|
||||||
}
|
|
||||||
|
|
||||||
constructor(model: ClusterModel) {
|
constructor(model: ClusterModel) {
|
||||||
makeObservable(this);
|
makeObservable(this);
|
||||||
this.id = model.id;
|
this.id = model.id;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user