@@ -18,6 +18,7 @@ import (
1818 monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
1919 appsv1 "k8s.io/api/apps/v1"
2020 v1 "k8s.io/api/core/v1"
21+ apiextensionsclientset "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset"
2122 "k8s.io/apimachinery/pkg/api/errors"
2223 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2324 "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
@@ -348,6 +349,13 @@ var _ = Describe("Managed Cluster Validating Webhooks", Ordered, func() {
348349 It ("allows backplane-cluster-admin to manage MustGather CRs" , func (ctx context.Context ) {
349350 backplanecadmin , err := client .Impersonate ("backplane-cluster-admin" , "system:serviceaccounts:backplane-cluster-admin" )
350351 Expect (err ).ShouldNot (HaveOccurred (), "Unable to setup impersonated backplane-cluster-admin client" )
352+ crdClient , err := apiextensionsclientset .NewForConfig (backplanecadmin .GetConfig ())
353+ Expect (err ).ShouldNot (HaveOccurred (), "Unable to create CRD client" )
354+ _ , err = crdClient .ApiextensionsV1 ().CustomResourceDefinitions ().Get (ctx , "mustgathers.managed.openshift.io" , metav1.GetOptions {})
355+ if err != nil {
356+ Skip ("Skipping test: MustGather CRD not found in cluster" )
357+ }
358+
351359 dynamicClient , err = dynamic .NewForConfig (backplanecadmin .GetConfig ())
352360 Expect (err ).ShouldNot (HaveOccurred (), "failed creating the dynamic client: %w" , err )
353361
0 commit comments