Skip to content

Commit 6f7acec

Browse files
authored
feat: distribution analyzer support for kind (#1521)
1 parent 123d17a commit 6f7acec

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

examples/preflight/sample-preflight.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ spec:
7575
- pass:
7676
when: "== oke"
7777
message: OKE is a supported distribution
78+
- pass:
79+
when: "== kind"
80+
message: Kind is a supported distribution
7881
- warn:
7982
message: Unable to determine the distribution of Kubernetes
8083
- nodeResources:

pkg/analyze/distribution.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ type providers struct {
2727
rke2 bool
2828
k3s bool
2929
oke bool
30+
kind bool
3031
}
3132

3233
type Provider int
@@ -47,6 +48,7 @@ const (
4748
rke2 Provider = iota
4849
k3s Provider = iota
4950
oke Provider = iota
51+
kind Provider = iota
5052
)
5153

5254
type AnalyzeDistribution struct {
@@ -162,6 +164,10 @@ func ParseNodesForProviders(nodes []corev1.Node) (providers, string) {
162164
foundProviders.ibm = true
163165
stringProvider = "ibm"
164166
}
167+
if strings.HasPrefix(node.Spec.ProviderID, "kind:") {
168+
foundProviders.kind = true
169+
stringProvider = "kind"
170+
}
165171
}
166172

167173
if foundMaster {
@@ -335,6 +341,8 @@ func compareDistributionConditionalToActual(conditional string, actual providers
335341
isMatch = actual.k3s
336342
case oke:
337343
isMatch = actual.oke
344+
case kind:
345+
isMatch = actual.kind
338346
}
339347

340348
switch parts[0] {
@@ -377,6 +385,8 @@ func mustNormalizeDistributionName(raw string) Provider {
377385
return k3s
378386
case "oke":
379387
return oke
388+
case "kind":
389+
return kind
380390
}
381391

382392
return unknown

pkg/analyze/distribution_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@ func Test_compareDistributionConditionalToActual(t *testing.T) {
3939
},
4040
expected: true,
4141
},
42+
{
43+
name: "== kind when kind is found",
44+
conditional: "== kind",
45+
input: providers{
46+
kind: true,
47+
},
48+
expected: true,
49+
},
4250
}
4351
for _, test := range tests {
4452
t.Run(test.name, func(t *testing.T) {

0 commit comments

Comments
 (0)