diff --git a/pkg/kubernetes/openshift.go b/pkg/kubernetes/openshift.go index 8b5c71f8..e94f9875 100644 --- a/pkg/kubernetes/openshift.go +++ b/pkg/kubernetes/openshift.go @@ -2,19 +2,15 @@ package kubernetes import ( "context" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime/schema" ) -func (m *Manager) IsOpenShift(ctx context.Context) bool { +func (m *Manager) IsOpenShift(_ context.Context) bool { // This method should be fast and not block (it's called at startup) - timeoutSeconds := int64(5) - if _, err := m.dynamicClient.Resource(schema.GroupVersionResource{ - Group: "project.openshift.io", - Version: "v1", - Resource: "projects", - }).List(ctx, metav1.ListOptions{Limit: 1, TimeoutSeconds: &timeoutSeconds}); err == nil { - return true - } - return false + _, err := m.discoveryClient.ServerResourcesForGroupVersion(schema.GroupVersion{ + Group: "project.openshift.io", + Version: "v1", + }.String()) + return err == nil } diff --git a/pkg/mcp/common_test.go b/pkg/mcp/common_test.go index 458ff8f7..340ed177 100644 --- a/pkg/mcp/common_test.go +++ b/pkg/mcp/common_test.go @@ -184,7 +184,7 @@ func testCaseWithContext(t *testing.T, mcpCtx *mcpContext, test func(c *mcpConte func (c *mcpContext) withKubeConfig(rc *rest.Config) *api.Config { fakeConfig := api.NewConfig() fakeConfig.Clusters["fake"] = api.NewCluster() - fakeConfig.Clusters["fake"].Server = "https://example.com" + fakeConfig.Clusters["fake"].Server = "https://127.0.0.1:6443" fakeConfig.Clusters["additional-cluster"] = api.NewCluster() fakeConfig.AuthInfos["fake"] = api.NewAuthInfo() fakeConfig.AuthInfos["additional-auth"] = api.NewAuthInfo() diff --git a/pkg/mcp/configuration_test.go b/pkg/mcp/configuration_test.go index 3d50d486..5cc31570 100644 --- a/pkg/mcp/configuration_test.go +++ b/pkg/mcp/configuration_test.go @@ -50,7 +50,7 @@ func TestConfigurationView(t *testing.T) { if decoded.Clusters[0].Name != "fake" { t.Errorf("fake-cluster not found: %v", decoded.Clusters) } - if decoded.Clusters[0].Cluster.Server != "https://example.com" { + if decoded.Clusters[0].Cluster.Server != "https://127.0.0.1:6443" { t.Errorf("fake-server not found: %v", decoded.Clusters) } })