Skip to content

Commit ed97d57

Browse files
Merge pull request #499 from redpinecube/feature/check-extensioninitialcontextname-set
✨ feature : check extensioninitialcontextname set
2 parents b5a84fc + e52e66f commit ed97d57

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

pkg/kubeconfig/extensions.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,3 +334,22 @@ func CheckContextScopeKubeflexExtensionSet(kconf clientcmdapi.Config, ctxName st
334334

335335
return DiagnosisStatusOK
336336
}
337+
338+
func CheckExtensionInitialContextNameSet(kconf clientcmdapi.Config) string {
339+
runtimeObj, exists := kconf.Extensions[ExtensionKubeflexKey]
340+
if !exists {
341+
return DiagnosisStatusWarning
342+
}
343+
344+
runtimeExtension := &RuntimeKubeflexExtension{}
345+
if err := ConvertRuntimeObjectToRuntimeExtension(runtimeObj, runtimeExtension); err != nil {
346+
return DiagnosisStatusWarning
347+
}
348+
349+
val, ok := runtimeExtension.Data[ExtensionInitialContextName]
350+
if !ok || val == "" {
351+
return DiagnosisStatusWarning
352+
}
353+
354+
return DiagnosisStatusOK
355+
}

pkg/kubeconfig/extensions_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,6 @@ func TestCheckHostingClusterContextNameSingle(t *testing.T) {
206206
}
207207
}
208208

209-
210-
211209
func TestCheckContextScopeKubeflexExtensionSetNoKubeflexExtensions(t *testing.T) {
212210
kconf := api.NewConfig()
213211
kconf.Clusters["cluster1"] = &api.Cluster{Server: "https://example.com:6443"}

0 commit comments

Comments
 (0)