MCPcopy Create free account
hub / github.com/devfile/devworkspace-operator / detect

Function detect

pkg/infrastructure/cluster.go:75–97  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

73}
74
75func detect() (Type, error) {
76 kubeCfg, err := config.GetConfig()
77 if err != nil {
78 return Unsupported, fmt.Errorf("could not get kube config: %w", err)
79 }
80 discoveryClient, err := discovery.NewDiscoveryClientForConfig(kubeCfg)
81 if err != nil {
82 return Unsupported, fmt.Errorf("could not get discovery client: %w", err)
83 }
84 apiList, err := discoveryClient.ServerGroups()
85 if err != nil {
86 return Unsupported, fmt.Errorf("could not read API groups: %w", err)
87 }
88 if findAPIGroup(apiList.Groups, "route.openshift.io") == nil {
89 return Kubernetes, nil
90 } else {
91 if findAPIGroup(apiList.Groups, "config.openshift.io") == nil {
92 return Unsupported, nil
93 } else {
94 return OpenShiftv4, nil
95 }
96 }
97}
98
99func findAPIGroup(source []metav1.APIGroup, apiName string) *metav1.APIGroup {
100 for i := 0; i < len(source); i++ {

Callers 1

InitializeFunction · 0.85

Calls 1

findAPIGroupFunction · 0.85

Tested by

no test coverage detected