Skip to content

Commit 6aaba59

Browse files
authored
feat: Detect k0s distribution in analyser (#1527)
1 parent f18b5d7 commit 6aaba59

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

pkg/analyze/distribution.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ type providers struct {
2828
k3s bool
2929
oke bool
3030
kind bool
31+
k0s bool
3132
}
3233

3334
type Provider int
@@ -49,6 +50,7 @@ const (
4950
k3s Provider = iota
5051
oke Provider = iota
5152
kind Provider = iota
53+
k0s Provider = iota
5254
)
5355

5456
type AnalyzeDistribution struct {
@@ -134,6 +136,10 @@ func ParseNodesForProviders(nodes []corev1.Node) (providers, string) {
134136
foundProviders.oke = true
135137
stringProvider = "oke"
136138
}
139+
if k == "node.k0sproject.io/role" {
140+
foundProviders.k0s = true
141+
stringProvider = "k0s"
142+
}
137143
}
138144

139145
for k := range node.ObjectMeta.Annotations {
@@ -343,6 +349,8 @@ func compareDistributionConditionalToActual(conditional string, actual providers
343349
isMatch = actual.oke
344350
case kind:
345351
isMatch = actual.kind
352+
case k0s:
353+
isMatch = actual.k0s
346354
}
347355

348356
switch parts[0] {
@@ -387,6 +395,8 @@ func mustNormalizeDistributionName(raw string) Provider {
387395
return oke
388396
case "kind":
389397
return kind
398+
case "k0s":
399+
return k0s
390400
}
391401

392402
return unknown

pkg/analyze/distribution_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@ func Test_compareDistributionConditionalToActual(t *testing.T) {
4747
},
4848
expected: true,
4949
},
50+
{
51+
name: "== k0s when k0s is found",
52+
conditional: "== k0s",
53+
input: providers{
54+
k0s: true,
55+
},
56+
expected: true,
57+
},
5058
}
5159
for _, test := range tests {
5260
t.Run(test.name, func(t *testing.T) {

0 commit comments

Comments
 (0)