From d66a9092c34b7e90a5b1af9e509cf39b592067ed Mon Sep 17 00:00:00 2001 From: Diamon Wiggins Date: Mon, 12 Aug 2024 16:40:20 -0400 Subject: [PATCH] detect embedded-cluster distribution for reporting --- pkg/report/distribution.go | 3 +++ pkg/report/distribution_test.go | 17 +++++++++++++++++ pkg/report/types/types.go | 3 +++ 3 files changed, 23 insertions(+) diff --git a/pkg/report/distribution.go b/pkg/report/distribution.go index 759a356b..b0054659 100644 --- a/pkg/report/distribution.go +++ b/pkg/report/distribution.go @@ -81,6 +81,9 @@ func distributionFromLabels(clientset kubernetes.Interface) types.Distribution { if k == "minikube.k8s.io/version" { return types.Minikube } + if k == "kots.io/embedded-cluster-role" { + return types.EmbeddedCluster + } } } return types.UnknownDistribution diff --git a/pkg/report/distribution_test.go b/pkg/report/distribution_test.go index f79a6ee4..0e84ab6b 100644 --- a/pkg/report/distribution_test.go +++ b/pkg/report/distribution_test.go @@ -163,6 +163,23 @@ func TestGetDistribution(t *testing.T) { }, want: types.Minikube, }, + { + name: "embedded-cluster from labels", + args: args{ + clientset: mockClientsetForDistribution(&mockClientsetForDistributionOpts{ + objects: []runtime.Object{ + &corev1.Node{ + ObjectMeta: metav1.ObjectMeta{ + Labels: map[string]string{ + "kots.io/embedded-cluster-role": "total-1", + }, + }, + }, + }, + }), + }, + want: types.EmbeddedCluster, + }, { name: "gke from version", args: args{ diff --git a/pkg/report/types/types.go b/pkg/report/types/types.go index 5d56ff35..c9f53c68 100644 --- a/pkg/report/types/types.go +++ b/pkg/report/types/types.go @@ -12,6 +12,7 @@ const ( AKS DigitalOcean EKS + EmbeddedCluster GKE K0s K3s @@ -46,6 +47,8 @@ func (d Distribution) String() string { return "digital-ocean" case EKS: return "eks" + case EmbeddedCluster: + return "embedded-cluster" case GKE: return "gke" case K0s: