From 9274eea1335cc3782c5c2060ceb15c4d3a33b0ac Mon Sep 17 00:00:00 2001 From: Carlos Eduardo Arango Gutierrez Date: Tue, 6 Aug 2024 12:29:03 +0200 Subject: [PATCH] Add apiextensionsclientset to Framework struct Signed-off-by: Carlos Eduardo Arango Gutierrez --- go.mod | 2 +- pkg/framework/framework.go | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 76945d2e..a23cdc9c 100644 --- a/go.mod +++ b/go.mod @@ -7,6 +7,7 @@ require ( github.com/onsi/ginkgo/v2 v2.19.1 github.com/onsi/gomega v1.34.0 k8s.io/api v0.30.3 + k8s.io/apiextensions-apiserver v0.30.0 k8s.io/apimachinery v0.30.3 k8s.io/client-go v0.30.3 k8s.io/klog/v2 v2.130.1 @@ -139,7 +140,6 @@ require ( gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect helm.sh/helm/v3 v3.15.2 // indirect - k8s.io/apiextensions-apiserver v0.30.0 // indirect k8s.io/apiserver v0.30.0 // indirect k8s.io/cli-runtime v0.30.0 // indirect k8s.io/component-base v0.30.0 // indirect diff --git a/pkg/framework/framework.go b/pkg/framework/framework.go index c371a138..38cf0c75 100644 --- a/pkg/framework/framework.go +++ b/pkg/framework/framework.go @@ -35,6 +35,7 @@ import ( "github.com/onsi/ginkgo/v2" "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" + apiextensionsclientset "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset" apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" @@ -73,6 +74,7 @@ type Framework struct { clientConfig *rest.Config ClientSet clientset.Interface + ApiExtClient *apiextensionsclientset.Clientset // Helm HelmClient helm.Client @@ -134,6 +136,10 @@ func (f *Framework) BeforeEach(ctx context.Context) { f.ClientSet, err = clientset.NewForConfig(config) gomega.Expect(err).NotTo(gomega.HaveOccurred()) + // Create an API extensions client + f.ApiExtClient, err = apiextensionsclientset.NewForConfig(config) + gomega.Expect(err).NotTo(gomega.HaveOccurred()) + if !f.SkipNamespaceCreation { ginkgo.By(fmt.Sprintf("Building a namespace with basename %s", f.BaseName)) namespace, err := f.CreateNamespace(ctx, f.BaseName, map[string]string{