@@ -30,8 +30,10 @@ import (
30
30
. "github.com/onsi/ginkgo/v2"
31
31
. "github.com/onsi/gomega"
32
32
appsv1 "k8s.io/api/apps/v1"
33
+ apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
33
34
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
34
35
36
+ "k8s.io/apimachinery/pkg/labels"
35
37
"k8s.io/apimachinery/pkg/runtime"
36
38
"k8s.io/klog/v2"
37
39
operatorv1alpha1 "sigs.k8s.io/cluster-api-operator/api/v1alpha1"
@@ -42,6 +44,7 @@ import (
42
44
"sigs.k8s.io/cluster-api/test/framework/bootstrap"
43
45
"sigs.k8s.io/cluster-api/test/framework/clusterctl"
44
46
ctrl "sigs.k8s.io/controller-runtime"
47
+ "sigs.k8s.io/controller-runtime/pkg/client"
45
48
"sigs.k8s.io/yaml"
46
49
)
47
50
@@ -334,6 +337,25 @@ func ensureCertManager(clusterProxy framework.ClusterProxy, config *clusterctl.E
334
337
})
335
338
}
336
339
340
+ func deleteClusterAPICRDs (clusterProxy framework.ClusterProxy ) {
341
+ // To get all Cluster API CRDs we need filter them by labels:
342
+ // cluster.x-k8s.io/provider: cluster-api
343
+ // clusterctl.cluster.x-k8s.io: ""
344
+ crds := & apiextensionsv1.CustomResourceDefinitionList {}
345
+ Expect (clusterProxy .GetClient ().List (ctx , crds , & client.ListOptions {
346
+ LabelSelector : labels .SelectorFromSet (
347
+ map [string ]string {
348
+ "cluster.x-k8s.io/provider" : "cluster-api" ,
349
+ "clusterctl.cluster.x-k8s.io" : "" ,
350
+ },
351
+ ),
352
+ })).To (Succeed ())
353
+
354
+ for _ , crd := range crds .Items {
355
+ Expect (clusterProxy .GetClient ().Delete (ctx , & crd )).To (Succeed ())
356
+ }
357
+ }
358
+
337
359
func initHelmChart () {
338
360
helmChart = & HelmChart {
339
361
BinaryPath : helmBinaryPath ,
0 commit comments