Skip to content

Commit a374b0a

Browse files
authored
feat: Detect EC as a distribution (#1529)
1 parent 6aaba59 commit a374b0a

File tree

3 files changed

+113
-34
lines changed

3 files changed

+113
-34
lines changed

docs/design/proposal-standard-interface.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ An initially unintended benefit of using the Aggregation Layer is that any HostC
4242
* [microk8s implementation](https://github.com/canonical/microk8s/blob/master/build-scripts/patches/0000-Kubelite-integration.patch) - bundles slightly modified binaries
4343
* [k0s uses upstream binaries statically compiled](https://docs.k0sproject.io/v1.23.8+k0s.0/architecture/) - bundles statically compiled binaries that self extract and uses a process monitor to run them
4444

45-
2. Can you in fact push metadat like "Status" into an api-server or do we have to write directly to etcd?
45+
2. Can you in fact push metadata like "Status" into an api-server or do we have to write directly to etcd?
4646

4747
* If we can't push to the api-server is just writing the information directly into etcd something we can do and have a reasonable expectation of compatibility?
4848

pkg/analyze/distribution.go

Lines changed: 44 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -13,44 +13,46 @@ import (
1313
)
1414

1515
type providers struct {
16-
microk8s bool
17-
dockerDesktop bool
18-
eks bool
19-
gke bool
20-
digitalOcean bool
21-
openShift bool
22-
tanzu bool
23-
kurl bool
24-
aks bool
25-
ibm bool
26-
minikube bool
27-
rke2 bool
28-
k3s bool
29-
oke bool
30-
kind bool
31-
k0s bool
16+
microk8s bool
17+
dockerDesktop bool
18+
eks bool
19+
gke bool
20+
digitalOcean bool
21+
openShift bool
22+
tanzu bool
23+
kurl bool
24+
aks bool
25+
ibm bool
26+
minikube bool
27+
rke2 bool
28+
k3s bool
29+
oke bool
30+
kind bool
31+
k0s bool
32+
embeddedCluster bool
3233
}
3334

3435
type Provider int
3536

3637
const (
37-
unknown Provider = iota
38-
microk8s Provider = iota
39-
dockerDesktop Provider = iota
40-
eks Provider = iota
41-
gke Provider = iota
42-
digitalOcean Provider = iota
43-
openShift Provider = iota
44-
tanzu Provider = iota
45-
kurl Provider = iota
46-
aks Provider = iota
47-
ibm Provider = iota
48-
minikube Provider = iota
49-
rke2 Provider = iota
50-
k3s Provider = iota
51-
oke Provider = iota
52-
kind Provider = iota
53-
k0s Provider = iota
38+
unknown Provider = iota
39+
microk8s Provider = iota
40+
dockerDesktop Provider = iota
41+
eks Provider = iota
42+
gke Provider = iota
43+
digitalOcean Provider = iota
44+
openShift Provider = iota
45+
tanzu Provider = iota
46+
kurl Provider = iota
47+
aks Provider = iota
48+
ibm Provider = iota
49+
minikube Provider = iota
50+
rke2 Provider = iota
51+
k3s Provider = iota
52+
oke Provider = iota
53+
kind Provider = iota
54+
k0s Provider = iota
55+
embeddedCluster Provider = iota
5456
)
5557

5658
type AnalyzeDistribution struct {
@@ -140,6 +142,11 @@ func ParseNodesForProviders(nodes []corev1.Node) (providers, string) {
140142
foundProviders.k0s = true
141143
stringProvider = "k0s"
142144
}
145+
146+
if k == "kots.io/embedded-cluster-role" {
147+
foundProviders.embeddedCluster = true
148+
stringProvider = "embedded-cluster"
149+
}
143150
}
144151

145152
for k := range node.ObjectMeta.Annotations {
@@ -351,6 +358,8 @@ func compareDistributionConditionalToActual(conditional string, actual providers
351358
isMatch = actual.kind
352359
case k0s:
353360
isMatch = actual.k0s
361+
case embeddedCluster:
362+
isMatch = actual.embeddedCluster
354363
}
355364

356365
switch parts[0] {
@@ -397,6 +406,8 @@ func mustNormalizeDistributionName(raw string) Provider {
397406
return kind
398407
case "k0s":
399408
return k0s
409+
case "embeddedcluster":
410+
return embeddedCluster
400411
}
401412

402413
return unknown

pkg/analyze/distribution_test.go

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ func Test_compareDistributionConditionalToActual(t *testing.T) {
5555
},
5656
expected: true,
5757
},
58+
{
59+
name: "== embedded-cluster when embedded-cluster is found",
60+
conditional: "== embedded-cluster",
61+
input: providers{
62+
embeddedCluster: true,
63+
},
64+
expected: true,
65+
},
5866
}
5967
for _, test := range tests {
6068
t.Run(test.name, func(t *testing.T) {
@@ -89,6 +97,66 @@ func Test_mustNormalizeDistributionName(t *testing.T) {
8997
raw: "Docker-Desktop",
9098
expected: dockerDesktop,
9199
},
100+
{
101+
raw: "embedded-cluster",
102+
expected: embeddedCluster,
103+
},
104+
{
105+
raw: "k0s",
106+
expected: k0s,
107+
},
108+
{
109+
raw: "kind",
110+
expected: kind,
111+
},
112+
{
113+
raw: "k3s",
114+
expected: k3s,
115+
},
116+
{
117+
raw: "ibm",
118+
expected: ibm,
119+
},
120+
{
121+
raw: "ibmcloud",
122+
expected: ibm,
123+
},
124+
{
125+
raw: "ibm cloud",
126+
expected: ibm,
127+
},
128+
{
129+
raw: "gke",
130+
expected: gke,
131+
},
132+
{
133+
raw: "aks",
134+
expected: aks,
135+
},
136+
{
137+
raw: "eks",
138+
expected: eks,
139+
},
140+
{
141+
raw: "oke",
142+
expected: oke,
143+
},
144+
{
145+
raw: "rke2",
146+
expected: rke2,
147+
},
148+
{
149+
raw: "dockerdesktop",
150+
expected: dockerDesktop,
151+
},
152+
{
153+
raw: "docker desktop",
154+
expected: dockerDesktop,
155+
},
156+
{
157+
raw: "docker-desktop",
158+
expected: dockerDesktop,
159+
},
92160
}
93161

94162
for _, test := range tests {

0 commit comments

Comments
 (0)