From b419bc71ae1b67580a02ff3c64a5a188079e537e Mon Sep 17 00:00:00 2001 From: Hui Chen Date: Tue, 14 Dec 2021 17:42:58 +0800 Subject: [PATCH 01/17] Define strategy to provide value for bundleLookupTag in Cluster Template Signed-off-by: Hui Chen --- PROJECT | 4 ++ .../v1beta1/byocluster_webhook.go | 64 +++++++++++++++++++ .../v1beta1/byocluster_webhook_test.go | 51 +++++++++++++++ .../v1beta1/webhook_suite_test.go | 6 ++ config/crd/kustomization.yaml | 4 +- config/default/webhookcainjection_patch.yaml | 6 ++ config/webhook/manifests.yaml | 48 ++++++++++++++ main.go | 4 ++ .../v1beta1/cluster-template.yaml | 1 - .../v1beta1/cluster-with-kcp.yaml | 1 - 10 files changed, 185 insertions(+), 4 deletions(-) create mode 100644 apis/infrastructure/v1beta1/byocluster_webhook.go create mode 100644 apis/infrastructure/v1beta1/byocluster_webhook_test.go diff --git a/PROJECT b/PROJECT index a217fbfcf..5f2bb397c 100644 --- a/PROJECT +++ b/PROJECT @@ -32,6 +32,10 @@ resources: kind: ByoCluster path: github.com/vmware-tanzu/cluster-api-provider-bringyourownhost/apis/infrastructure/v1beta1 version: v1beta1 + webhooks: + defaulting: true + validation: true + webhookVersion: v1 - api: crdVersion: v1 namespaced: true diff --git a/apis/infrastructure/v1beta1/byocluster_webhook.go b/apis/infrastructure/v1beta1/byocluster_webhook.go new file mode 100644 index 000000000..4bfa982dc --- /dev/null +++ b/apis/infrastructure/v1beta1/byocluster_webhook.go @@ -0,0 +1,64 @@ +// Copyright 2021 VMware, Inc. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + +package v1beta1 + +import ( + "k8s.io/apimachinery/pkg/runtime" + ctrl "sigs.k8s.io/controller-runtime" + logf "sigs.k8s.io/controller-runtime/pkg/log" + "sigs.k8s.io/controller-runtime/pkg/webhook" +) + +// log is for logging in this package. +var byoclusterlog = logf.Log.WithName("byocluster-resource") + +func (r *ByoCluster) SetupWebhookWithManager(mgr ctrl.Manager) error { + return ctrl.NewWebhookManagedBy(mgr). + For(r). + Complete() +} + +// TODO(user): EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! + +//+kubebuilder:webhook:path=/mutate-infrastructure-cluster-x-k8s-io-v1beta1-byocluster,mutating=true,failurePolicy=fail,sideEffects=None,groups=infrastructure.cluster.x-k8s.io,resources=byoclusters,verbs=create;update,versions=v1beta1,name=mbyocluster.kb.io,admissionReviewVersions=v1 + +var _ webhook.Defaulter = &ByoCluster{} + +// Default implements webhook.Defaulter so a webhook will be registered for the type +func (r *ByoCluster) Default() { + byoclusterlog.Info("default", "name", r.Name) + + if r.Spec.BundleLookupTag == "" { + r.Spec.BundleLookupTag = "v0.1.0_alpha.2" + } +} + +// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation. +//+kubebuilder:webhook:path=/validate-infrastructure-cluster-x-k8s-io-v1beta1-byocluster,mutating=false,failurePolicy=fail,sideEffects=None,groups=infrastructure.cluster.x-k8s.io,resources=byoclusters,verbs=create;update,versions=v1beta1,name=vbyocluster.kb.io,admissionReviewVersions=v1 + +var _ webhook.Validator = &ByoCluster{} + +// ValidateCreate implements webhook.Validator so a webhook will be registered for the type +func (r *ByoCluster) ValidateCreate() error { + byoclusterlog.Info("validate create", "name", r.Name) + + // TODO(user): fill in your validation logic upon object creation. + return nil +} + +// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type +func (r *ByoCluster) ValidateUpdate(old runtime.Object) error { + byoclusterlog.Info("validate update", "name", r.Name) + + // TODO(user): fill in your validation logic upon object update. + return nil +} + +// ValidateDelete implements webhook.Validator so a webhook will be registered for the type +func (r *ByoCluster) ValidateDelete() error { + byoclusterlog.Info("validate delete", "name", r.Name) + + // TODO(user): fill in your validation logic upon object deletion. + return nil +} diff --git a/apis/infrastructure/v1beta1/byocluster_webhook_test.go b/apis/infrastructure/v1beta1/byocluster_webhook_test.go new file mode 100644 index 000000000..c7b161340 --- /dev/null +++ b/apis/infrastructure/v1beta1/byocluster_webhook_test.go @@ -0,0 +1,51 @@ +// Copyright 2021 VMware, Inc. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + +package v1beta1 + +import ( + "context" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/kubectl/pkg/scheme" + clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" + "sigs.k8s.io/controller-runtime/pkg/client" +) + +var _ = Describe("ByoclusterWebhook", func() { + XContext("When ByoCluster gets a create request", func() { + var ( + byoCluster *ByoCluster + ctx context.Context + k8sClientUncached client.Client + ) + BeforeEach(func() { + ctx = context.Background() + var clientErr error + + k8sClientUncached, clientErr = client.New(cfg, client.Options{Scheme: scheme.Scheme}) + Expect(clientErr).NotTo(HaveOccurred()) + + byoCluster = &ByoCluster{ + TypeMeta: metav1.TypeMeta{ + Kind: "ByoCluster", + APIVersion: clusterv1.GroupVersion.String(), + }, + ObjectMeta: metav1.ObjectMeta{ + Name: "byocluster-", + Namespace: "default", + }, + Spec: ByoClusterSpec{}, + } + Expect(k8sClientUncached.Create(ctx, byoCluster)).Should(Succeed()) + }) + + It("should fill the default value", func() { + byoCluster.Default() + Expect(byoCluster.Spec.BundleLookupTag).Should(Equal("v0.1.0_alpha.2")) + }) + + }) +}) diff --git a/apis/infrastructure/v1beta1/webhook_suite_test.go b/apis/infrastructure/v1beta1/webhook_suite_test.go index e8fc5c83d..3c7b9b059 100644 --- a/apis/infrastructure/v1beta1/webhook_suite_test.go +++ b/apis/infrastructure/v1beta1/webhook_suite_test.go @@ -75,6 +75,9 @@ var _ = BeforeSuite(func() { err = AddToScheme(scheme) Expect(err).NotTo(HaveOccurred()) + err = admissionv1beta1.AddToScheme(scheme) + Expect(err).NotTo(HaveOccurred()) + //+kubebuilder:scaffold:scheme k8sClient, err = client.New(cfg, client.Options{Scheme: scheme}) @@ -96,6 +99,9 @@ var _ = BeforeSuite(func() { err = (&ByoHost{}).SetupWebhookWithManager(mgr) Expect(err).NotTo(HaveOccurred()) + err = (&ByoCluster{}).SetupWebhookWithManager(mgr) + Expect(err).NotTo(HaveOccurred()) + //+kubebuilder:scaffold:webhook go func() { diff --git a/config/crd/kustomization.yaml b/config/crd/kustomization.yaml index 2cfbbdeb9..b800a1bc0 100644 --- a/config/crd/kustomization.yaml +++ b/config/crd/kustomization.yaml @@ -18,7 +18,7 @@ patchesStrategicMerge: #- patches/webhook_in_byomachines.yaml - patches/webhook_in_byohosts.yaml #- patches/webhook_in_byomachinetemplates.yaml -#- patches/webhook_in_byoclusters.yaml +- patches/webhook_in_byoclusters.yaml #- patches/webhook_in_byohosts.yaml #+kubebuilder:scaffold:crdkustomizewebhookpatch @@ -27,7 +27,7 @@ patchesStrategicMerge: #- patches/cainjection_in_byomachines.yaml - patches/cainjection_in_byohosts.yaml #- patches/cainjection_in_byomachinetemplates.yaml -#- patches/cainjection_in_byoclusters.yaml +- patches/cainjection_in_byoclusters.yaml #- patches/cainjection_in_byohosts.yaml #+kubebuilder:scaffold:crdkustomizecainjectionpatch diff --git a/config/default/webhookcainjection_patch.yaml b/config/default/webhookcainjection_patch.yaml index f5e23673e..02ab515d4 100644 --- a/config/default/webhookcainjection_patch.yaml +++ b/config/default/webhookcainjection_patch.yaml @@ -1,5 +1,11 @@ # This patch add annotation to admission webhook config and # the variables $(CERTIFICATE_NAMESPACE) and $(CERTIFICATE_NAME) will be substituted by kustomize. +apiVersion: admissionregistration.k8s.io/v1 +kind: MutatingWebhookConfiguration +metadata: + name: mutating-webhook-configuration + annotations: + cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME) --- apiVersion: admissionregistration.k8s.io/v1 kind: ValidatingWebhookConfiguration diff --git a/config/webhook/manifests.yaml b/config/webhook/manifests.yaml index c39ccf70b..3acb6f693 100644 --- a/config/webhook/manifests.yaml +++ b/config/webhook/manifests.yaml @@ -1,4 +1,32 @@ +--- +apiVersion: admissionregistration.k8s.io/v1 +kind: MutatingWebhookConfiguration +metadata: + creationTimestamp: null + name: mutating-webhook-configuration +webhooks: +- admissionReviewVersions: + - v1 + clientConfig: + service: + name: webhook-service + namespace: system + path: /mutate-infrastructure-cluster-x-k8s-io-v1beta1-byocluster + failurePolicy: Fail + name: mbyocluster.kb.io + rules: + - apiGroups: + - infrastructure.cluster.x-k8s.io + apiVersions: + - v1beta1 + operations: + - CREATE + - UPDATE + resources: + - byoclusters + sideEffects: None + --- apiVersion: admissionregistration.k8s.io/v1 kind: ValidatingWebhookConfiguration @@ -6,6 +34,26 @@ metadata: creationTimestamp: null name: validating-webhook-configuration webhooks: +- admissionReviewVersions: + - v1 + clientConfig: + service: + name: webhook-service + namespace: system + path: /validate-infrastructure-cluster-x-k8s-io-v1beta1-byocluster + failurePolicy: Fail + name: vbyocluster.kb.io + rules: + - apiGroups: + - infrastructure.cluster.x-k8s.io + apiVersions: + - v1beta1 + operations: + - CREATE + - UPDATE + resources: + - byoclusters + sideEffects: None - admissionReviewVersions: - v1 - v1beta1 diff --git a/main.go b/main.go index 56a89415c..d4407740b 100644 --- a/main.go +++ b/main.go @@ -121,6 +121,10 @@ func main() { setupLog.Error(err, "unable to create webhook", "webhook", "ByoHost") os.Exit(1) } + if err = (&infrastructurev1beta1.ByoCluster{}).SetupWebhookWithManager(mgr); err != nil { + setupLog.Error(err, "unable to create webhook", "webhook", "ByoCluster") + os.Exit(1) + } //+kubebuilder:scaffold:builder if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil { diff --git a/test/e2e/data/infrastructure-provider-byoh/v1beta1/cluster-template.yaml b/test/e2e/data/infrastructure-provider-byoh/v1beta1/cluster-template.yaml index 3e3c4a307..07cc2d61d 100644 --- a/test/e2e/data/infrastructure-provider-byoh/v1beta1/cluster-template.yaml +++ b/test/e2e/data/infrastructure-provider-byoh/v1beta1/cluster-template.yaml @@ -184,7 +184,6 @@ metadata: name: ${CLUSTER_NAME} spec: bundleLookupBaseRegistry: projects.registry.vmware.com/cluster_api_provider_bringyourownhost - bundleLookupTag: v0.1.0_alpha.2 controlPlaneEndpoint: host: ${CONTROL_PLANE_ENDPOINT_IP} port: 6443 diff --git a/test/e2e/data/infrastructure-provider-byoh/v1beta1/cluster-with-kcp.yaml b/test/e2e/data/infrastructure-provider-byoh/v1beta1/cluster-with-kcp.yaml index 02e70b7e7..9a6a976f4 100644 --- a/test/e2e/data/infrastructure-provider-byoh/v1beta1/cluster-with-kcp.yaml +++ b/test/e2e/data/infrastructure-provider-byoh/v1beta1/cluster-with-kcp.yaml @@ -28,7 +28,6 @@ metadata: name: ${CLUSTER_NAME} spec: bundleLookupBaseRegistry: projects.registry.vmware.com/cluster_api_provider_bringyourownhost - bundleLookupTag: v0.1.0_alpha.2 controlPlaneEndpoint: host: ${CONTROL_PLANE_ENDPOINT_IP} port: 6443 From e67f99129898a962b15664a87f60074f76742230 Mon Sep 17 00:00:00 2001 From: Hui Chen Date: Wed, 15 Dec 2021 11:01:14 +0800 Subject: [PATCH 02/17] ignore golangci-lint error for the code generated by kubebuilder: Error: ST1016: methods on the same type should have the same receiver name (seen 2x "c", 5x "r") (stylecheck) Signed-off-by: Hui Chen --- apis/infrastructure/v1beta1/byocluster_webhook.go | 1 + 1 file changed, 1 insertion(+) diff --git a/apis/infrastructure/v1beta1/byocluster_webhook.go b/apis/infrastructure/v1beta1/byocluster_webhook.go index 4bfa982dc..e1c2658af 100644 --- a/apis/infrastructure/v1beta1/byocluster_webhook.go +++ b/apis/infrastructure/v1beta1/byocluster_webhook.go @@ -26,6 +26,7 @@ func (r *ByoCluster) SetupWebhookWithManager(mgr ctrl.Manager) error { var _ webhook.Defaulter = &ByoCluster{} // Default implements webhook.Defaulter so a webhook will be registered for the type +// nolint: stylecheck func (r *ByoCluster) Default() { byoclusterlog.Info("default", "name", r.Name) From 5e1936282294255735da382be122268dfcd9e8f1 Mon Sep 17 00:00:00 2001 From: Hui Chen Date: Tue, 4 Jan 2022 14:08:43 +0800 Subject: [PATCH 03/17] comment from anusha Signed-off-by: Hui Chen --- .../v1beta1/byocluster_webhook.go | 20 ++++-- .../v1beta1/byocluster_webhook_test.go | 64 +++++++++++++++---- 2 files changed, 64 insertions(+), 20 deletions(-) diff --git a/apis/infrastructure/v1beta1/byocluster_webhook.go b/apis/infrastructure/v1beta1/byocluster_webhook.go index e1c2658af..eaed5cb25 100644 --- a/apis/infrastructure/v1beta1/byocluster_webhook.go +++ b/apis/infrastructure/v1beta1/byocluster_webhook.go @@ -4,7 +4,11 @@ package v1beta1 import ( + "errors" + + apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" ctrl "sigs.k8s.io/controller-runtime" logf "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/webhook" @@ -29,10 +33,6 @@ var _ webhook.Defaulter = &ByoCluster{} // nolint: stylecheck func (r *ByoCluster) Default() { byoclusterlog.Info("default", "name", r.Name) - - if r.Spec.BundleLookupTag == "" { - r.Spec.BundleLookupTag = "v0.1.0_alpha.2" - } } // TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation. @@ -43,8 +43,12 @@ var _ webhook.Validator = &ByoCluster{} // ValidateCreate implements webhook.Validator so a webhook will be registered for the type func (r *ByoCluster) ValidateCreate() error { byoclusterlog.Info("validate create", "name", r.Name) + groupResource := schema.GroupResource{Group: "infrastructure.cluster.x-k8s.io", Resource: "byocluster"} + + if r.Spec.BundleLookupTag == "" { + return apierrors.NewForbidden(groupResource, r.Name, errors.New("cannot create ByoCluster with Spec.BundleLookupTag")) + } - // TODO(user): fill in your validation logic upon object creation. return nil } @@ -52,7 +56,11 @@ func (r *ByoCluster) ValidateCreate() error { func (r *ByoCluster) ValidateUpdate(old runtime.Object) error { byoclusterlog.Info("validate update", "name", r.Name) - // TODO(user): fill in your validation logic upon object update. + groupResource := schema.GroupResource{Group: "infrastructure.cluster.x-k8s.io", Resource: "byocluster"} + + if r.Spec.BundleLookupTag == "" { + return apierrors.NewForbidden(groupResource, r.Name, errors.New("cannot create ByoCluster with empty Spec.BundleLookupTag")) + } return nil } diff --git a/apis/infrastructure/v1beta1/byocluster_webhook_test.go b/apis/infrastructure/v1beta1/byocluster_webhook_test.go index c7b161340..ba5a9b456 100644 --- a/apis/infrastructure/v1beta1/byocluster_webhook_test.go +++ b/apis/infrastructure/v1beta1/byocluster_webhook_test.go @@ -4,8 +4,6 @@ package v1beta1 import ( - "context" - . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -17,15 +15,10 @@ import ( var _ = Describe("ByoclusterWebhook", func() { XContext("When ByoCluster gets a create request", func() { var ( - byoCluster *ByoCluster - ctx context.Context - k8sClientUncached client.Client + byoCluster *ByoCluster ) BeforeEach(func() { - ctx = context.Background() - var clientErr error - - k8sClientUncached, clientErr = client.New(cfg, client.Options{Scheme: scheme.Scheme}) + _, clientErr := client.New(cfg, client.Options{Scheme: scheme.Scheme}) Expect(clientErr).NotTo(HaveOccurred()) byoCluster = &ByoCluster{ @@ -34,17 +27,60 @@ var _ = Describe("ByoclusterWebhook", func() { APIVersion: clusterv1.GroupVersion.String(), }, ObjectMeta: metav1.ObjectMeta{ - Name: "byocluster-", + Name: "byocluster-create", + Namespace: "default", + }, + Spec: ByoClusterSpec{}, + } + }) + + It("should reject the request when BundleLookupTag is empty", func() { + err := byoCluster.ValidateCreate() + Expect(err).To(HaveOccurred()) + Expect(err).To(MatchError("cSpec.BundleLookupTag of ByoCluster is empty")) + }) + + }) + + XContext("When ByoCluster gets a update request", func() { + var ( + oldbyoCluster *ByoCluster + newbyoCluster *ByoCluster + ) + BeforeEach(func() { + _, clientErr := client.New(cfg, client.Options{Scheme: scheme.Scheme}) + Expect(clientErr).NotTo(HaveOccurred()) + + oldbyoCluster = &ByoCluster{ + TypeMeta: metav1.TypeMeta{ + Kind: "ByoCluster", + APIVersion: clusterv1.GroupVersion.String(), + }, + ObjectMeta: metav1.ObjectMeta{ + Name: "byocluster-update", + Namespace: "default", + }, + Spec: ByoClusterSpec{ + BundleLookupTag: "v0.1.0_alpha.2", + }, + } + newbyoCluster = &ByoCluster{ + TypeMeta: metav1.TypeMeta{ + Kind: "ByoCluster", + APIVersion: clusterv1.GroupVersion.String(), + }, + ObjectMeta: metav1.ObjectMeta{ + Name: "byocluster-update", Namespace: "default", }, Spec: ByoClusterSpec{}, } - Expect(k8sClientUncached.Create(ctx, byoCluster)).Should(Succeed()) }) - It("should fill the default value", func() { - byoCluster.Default() - Expect(byoCluster.Spec.BundleLookupTag).Should(Equal("v0.1.0_alpha.2")) + It("should reject the request when BundleLookupTag is empty", func() { + err := newbyoCluster.ValidateUpdate(oldbyoCluster) + Expect(err).To(HaveOccurred()) + Expect(err).To(MatchError("Spec.BundleLookupTag of ByoCluster is empty")) }) }) From 93666229e09ed8cd56c6ff0230cff1ce2a60d47e Mon Sep 17 00:00:00 2001 From: Hui Chen Date: Tue, 4 Jan 2022 15:54:05 +0800 Subject: [PATCH 04/17] comment from anusha Signed-off-by: Hui Chen --- .../infrastructure-provider-byoh/v1beta1/cluster-template.yaml | 1 + .../infrastructure-provider-byoh/v1beta1/cluster-with-kcp.yaml | 1 + 2 files changed, 2 insertions(+) diff --git a/test/e2e/data/infrastructure-provider-byoh/v1beta1/cluster-template.yaml b/test/e2e/data/infrastructure-provider-byoh/v1beta1/cluster-template.yaml index 07cc2d61d..3e3c4a307 100644 --- a/test/e2e/data/infrastructure-provider-byoh/v1beta1/cluster-template.yaml +++ b/test/e2e/data/infrastructure-provider-byoh/v1beta1/cluster-template.yaml @@ -184,6 +184,7 @@ metadata: name: ${CLUSTER_NAME} spec: bundleLookupBaseRegistry: projects.registry.vmware.com/cluster_api_provider_bringyourownhost + bundleLookupTag: v0.1.0_alpha.2 controlPlaneEndpoint: host: ${CONTROL_PLANE_ENDPOINT_IP} port: 6443 diff --git a/test/e2e/data/infrastructure-provider-byoh/v1beta1/cluster-with-kcp.yaml b/test/e2e/data/infrastructure-provider-byoh/v1beta1/cluster-with-kcp.yaml index 9a6a976f4..02e70b7e7 100644 --- a/test/e2e/data/infrastructure-provider-byoh/v1beta1/cluster-with-kcp.yaml +++ b/test/e2e/data/infrastructure-provider-byoh/v1beta1/cluster-with-kcp.yaml @@ -28,6 +28,7 @@ metadata: name: ${CLUSTER_NAME} spec: bundleLookupBaseRegistry: projects.registry.vmware.com/cluster_api_provider_bringyourownhost + bundleLookupTag: v0.1.0_alpha.2 controlPlaneEndpoint: host: ${CONTROL_PLANE_ENDPOINT_IP} port: 6443 From 30ef2936a971f2c914a574acdf925dbba68c67e5 Mon Sep 17 00:00:00 2001 From: huchen2021 <85480625+huchen2021@users.noreply.github.com> Date: Fri, 7 Jan 2022 10:37:54 +0800 Subject: [PATCH 05/17] Update apis/infrastructure/v1beta1/byocluster_webhook.go Co-authored-by: Dharmjit Singh --- apis/infrastructure/v1beta1/byocluster_webhook.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apis/infrastructure/v1beta1/byocluster_webhook.go b/apis/infrastructure/v1beta1/byocluster_webhook.go index eaed5cb25..4bbc41278 100644 --- a/apis/infrastructure/v1beta1/byocluster_webhook.go +++ b/apis/infrastructure/v1beta1/byocluster_webhook.go @@ -46,7 +46,7 @@ func (r *ByoCluster) ValidateCreate() error { groupResource := schema.GroupResource{Group: "infrastructure.cluster.x-k8s.io", Resource: "byocluster"} if r.Spec.BundleLookupTag == "" { - return apierrors.NewForbidden(groupResource, r.Name, errors.New("cannot create ByoCluster with Spec.BundleLookupTag")) + return apierrors.NewForbidden(groupResource, r.Name, errors.New("cannot create ByoCluster without Spec.BundleLookupTag")) } return nil From ca044dbc827039c71d411a6ee63fd9dc70af6b6c Mon Sep 17 00:00:00 2001 From: Hui Chen Date: Fri, 7 Jan 2022 10:41:29 +0800 Subject: [PATCH 06/17] comment from dharmjit Signed-off-by: Hui Chen --- apis/infrastructure/v1beta1/byocluster_webhook.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/apis/infrastructure/v1beta1/byocluster_webhook.go b/apis/infrastructure/v1beta1/byocluster_webhook.go index eaed5cb25..f8a4ab2fc 100644 --- a/apis/infrastructure/v1beta1/byocluster_webhook.go +++ b/apis/infrastructure/v1beta1/byocluster_webhook.go @@ -23,8 +23,6 @@ func (r *ByoCluster) SetupWebhookWithManager(mgr ctrl.Manager) error { Complete() } -// TODO(user): EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! - //+kubebuilder:webhook:path=/mutate-infrastructure-cluster-x-k8s-io-v1beta1-byocluster,mutating=true,failurePolicy=fail,sideEffects=None,groups=infrastructure.cluster.x-k8s.io,resources=byoclusters,verbs=create;update,versions=v1beta1,name=mbyocluster.kb.io,admissionReviewVersions=v1 var _ webhook.Defaulter = &ByoCluster{} @@ -32,7 +30,6 @@ var _ webhook.Defaulter = &ByoCluster{} // Default implements webhook.Defaulter so a webhook will be registered for the type // nolint: stylecheck func (r *ByoCluster) Default() { - byoclusterlog.Info("default", "name", r.Name) } // TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation. @@ -66,8 +63,6 @@ func (r *ByoCluster) ValidateUpdate(old runtime.Object) error { // ValidateDelete implements webhook.Validator so a webhook will be registered for the type func (r *ByoCluster) ValidateDelete() error { - byoclusterlog.Info("validate delete", "name", r.Name) - // TODO(user): fill in your validation logic upon object deletion. return nil } From f56d98e939dfdd00673338ec8e9c7231d198e5ba Mon Sep 17 00:00:00 2001 From: huchen2021 <85480625+huchen2021@users.noreply.github.com> Date: Fri, 7 Jan 2022 10:46:21 +0800 Subject: [PATCH 07/17] Update apis/infrastructure/v1beta1/byocluster_webhook.go Co-authored-by: Dharmjit Singh --- apis/infrastructure/v1beta1/byocluster_webhook.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apis/infrastructure/v1beta1/byocluster_webhook.go b/apis/infrastructure/v1beta1/byocluster_webhook.go index 4bbc41278..2dd8eb4dc 100644 --- a/apis/infrastructure/v1beta1/byocluster_webhook.go +++ b/apis/infrastructure/v1beta1/byocluster_webhook.go @@ -59,7 +59,7 @@ func (r *ByoCluster) ValidateUpdate(old runtime.Object) error { groupResource := schema.GroupResource{Group: "infrastructure.cluster.x-k8s.io", Resource: "byocluster"} if r.Spec.BundleLookupTag == "" { - return apierrors.NewForbidden(groupResource, r.Name, errors.New("cannot create ByoCluster with empty Spec.BundleLookupTag")) + return apierrors.NewForbidden(groupResource, r.Name, errors.New("cannot update ByoCluster with empty Spec.BundleLookupTag")) } return nil } From 8798b502c220802f8600e0a072c265629319bfc6 Mon Sep 17 00:00:00 2001 From: Hui Chen Date: Fri, 7 Jan 2022 13:43:26 +0800 Subject: [PATCH 08/17] comment from anusha Signed-off-by: Hui Chen --- apis/infrastructure/v1beta1/byocluster_webhook.go | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/apis/infrastructure/v1beta1/byocluster_webhook.go b/apis/infrastructure/v1beta1/byocluster_webhook.go index c145bc411..994403c19 100644 --- a/apis/infrastructure/v1beta1/byocluster_webhook.go +++ b/apis/infrastructure/v1beta1/byocluster_webhook.go @@ -8,7 +8,7 @@ import ( apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/runtime/schema" + "k8s.io/apimachinery/pkg/util/validation/field" ctrl "sigs.k8s.io/controller-runtime" logf "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/webhook" @@ -40,10 +40,10 @@ var _ webhook.Validator = &ByoCluster{} // ValidateCreate implements webhook.Validator so a webhook will be registered for the type func (r *ByoCluster) ValidateCreate() error { byoclusterlog.Info("validate create", "name", r.Name) - groupResource := schema.GroupResource{Group: "infrastructure.cluster.x-k8s.io", Resource: "byocluster"} - if r.Spec.BundleLookupTag == "" { - return apierrors.NewForbidden(groupResource, r.Name, errors.New("cannot create ByoCluster without Spec.BundleLookupTag")) + return apierrors.NewInvalid(r.GroupVersionKind().GroupKind(), r.Name, field.ErrorList{ + field.InternalError(nil, errors.New("cannot create ByoCluster without Spec.BundleLookupTag")), + }) } return nil @@ -52,11 +52,10 @@ func (r *ByoCluster) ValidateCreate() error { // ValidateUpdate implements webhook.Validator so a webhook will be registered for the type func (r *ByoCluster) ValidateUpdate(old runtime.Object) error { byoclusterlog.Info("validate update", "name", r.Name) - - groupResource := schema.GroupResource{Group: "infrastructure.cluster.x-k8s.io", Resource: "byocluster"} - if r.Spec.BundleLookupTag == "" { - return apierrors.NewForbidden(groupResource, r.Name, errors.New("cannot update ByoCluster with empty Spec.BundleLookupTag")) + return apierrors.NewInvalid(r.GroupVersionKind().GroupKind(), r.Name, field.ErrorList{ + field.InternalError(nil, errors.New("cannot update ByoCluster with empty Spec.BundleLookupTag")), + }) } return nil } From 821c0e40e18ffa439c0d1a2d65bb856357fc90e7 Mon Sep 17 00:00:00 2001 From: Hui Chen Date: Tue, 11 Jan 2022 13:09:13 +0800 Subject: [PATCH 09/17] comment from anusha Signed-off-by: Hui Chen --- apis/infrastructure/v1beta1/byocluster_webhook_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apis/infrastructure/v1beta1/byocluster_webhook_test.go b/apis/infrastructure/v1beta1/byocluster_webhook_test.go index ba5a9b456..5d17cd2e5 100644 --- a/apis/infrastructure/v1beta1/byocluster_webhook_test.go +++ b/apis/infrastructure/v1beta1/byocluster_webhook_test.go @@ -13,7 +13,7 @@ import ( ) var _ = Describe("ByoclusterWebhook", func() { - XContext("When ByoCluster gets a create request", func() { + Context("When ByoCluster gets a create request", func() { var ( byoCluster *ByoCluster ) @@ -37,12 +37,12 @@ var _ = Describe("ByoclusterWebhook", func() { It("should reject the request when BundleLookupTag is empty", func() { err := byoCluster.ValidateCreate() Expect(err).To(HaveOccurred()) - Expect(err).To(MatchError("cSpec.BundleLookupTag of ByoCluster is empty")) + Expect(err.Error()).To(ContainSubstring("cannot create ByoCluster without Spec.BundleLookupTag")) }) }) - XContext("When ByoCluster gets a update request", func() { + Context("When ByoCluster gets a update request", func() { var ( oldbyoCluster *ByoCluster newbyoCluster *ByoCluster @@ -80,7 +80,7 @@ var _ = Describe("ByoclusterWebhook", func() { It("should reject the request when BundleLookupTag is empty", func() { err := newbyoCluster.ValidateUpdate(oldbyoCluster) Expect(err).To(HaveOccurred()) - Expect(err).To(MatchError("Spec.BundleLookupTag of ByoCluster is empty")) + Expect(err.Error()).To(ContainSubstring("cannot update ByoCluster with empty Spec.BundleLookupTag")) }) }) From 35806dcb69e116deb84498f8622ab8cc0f2bcd8d Mon Sep 17 00:00:00 2001 From: Hui Chen Date: Tue, 11 Jan 2022 13:50:00 +0800 Subject: [PATCH 10/17] replace unittests with intergration tests Signed-off-by: Hui Chen --- .../v1beta1/byocluster_webhook_test.go | 39 ++++++++++--------- .../v1beta1/webhook_suite_test.go | 17 ++++---- 2 files changed, 29 insertions(+), 27 deletions(-) diff --git a/apis/infrastructure/v1beta1/byocluster_webhook_test.go b/apis/infrastructure/v1beta1/byocluster_webhook_test.go index 5d17cd2e5..f56977d95 100644 --- a/apis/infrastructure/v1beta1/byocluster_webhook_test.go +++ b/apis/infrastructure/v1beta1/byocluster_webhook_test.go @@ -4,6 +4,8 @@ package v1beta1 import ( + "context" + . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -15,10 +17,14 @@ import ( var _ = Describe("ByoclusterWebhook", func() { Context("When ByoCluster gets a create request", func() { var ( - byoCluster *ByoCluster + byoCluster *ByoCluster + ctx context.Context + k8sClientUncached client.Client ) BeforeEach(func() { - _, clientErr := client.New(cfg, client.Options{Scheme: scheme.Scheme}) + ctx = context.Background() + var clientErr error + k8sClientUncached, clientErr = client.New(cfg, client.Options{Scheme: scheme.Scheme}) Expect(clientErr).NotTo(HaveOccurred()) byoCluster = &ByoCluster{ @@ -35,7 +41,7 @@ var _ = Describe("ByoclusterWebhook", func() { }) It("should reject the request when BundleLookupTag is empty", func() { - err := byoCluster.ValidateCreate() + err := k8sClientUncached.Create(ctx, byoCluster) Expect(err).To(HaveOccurred()) Expect(err.Error()).To(ContainSubstring("cannot create ByoCluster without Spec.BundleLookupTag")) }) @@ -44,14 +50,17 @@ var _ = Describe("ByoclusterWebhook", func() { Context("When ByoCluster gets a update request", func() { var ( - oldbyoCluster *ByoCluster - newbyoCluster *ByoCluster + byoCluster *ByoCluster + ctx context.Context + k8sClientUncached client.Client ) BeforeEach(func() { - _, clientErr := client.New(cfg, client.Options{Scheme: scheme.Scheme}) + ctx = context.Background() + var clientErr error + k8sClientUncached, clientErr = client.New(cfg, client.Options{Scheme: scheme.Scheme}) Expect(clientErr).NotTo(HaveOccurred()) - oldbyoCluster = &ByoCluster{ + byoCluster = &ByoCluster{ TypeMeta: metav1.TypeMeta{ Kind: "ByoCluster", APIVersion: clusterv1.GroupVersion.String(), @@ -64,21 +73,13 @@ var _ = Describe("ByoclusterWebhook", func() { BundleLookupTag: "v0.1.0_alpha.2", }, } - newbyoCluster = &ByoCluster{ - TypeMeta: metav1.TypeMeta{ - Kind: "ByoCluster", - APIVersion: clusterv1.GroupVersion.String(), - }, - ObjectMeta: metav1.ObjectMeta{ - Name: "byocluster-update", - Namespace: "default", - }, - Spec: ByoClusterSpec{}, - } + + Expect(k8sClientUncached.Create(ctx, byoCluster)).Should(Succeed()) }) It("should reject the request when BundleLookupTag is empty", func() { - err := newbyoCluster.ValidateUpdate(oldbyoCluster) + byoCluster.Spec.BundleLookupTag = "" + err := k8sClientUncached.Update(ctx, byoCluster) Expect(err).To(HaveOccurred()) Expect(err.Error()).To(ContainSubstring("cannot update ByoCluster with empty Spec.BundleLookupTag")) }) diff --git a/apis/infrastructure/v1beta1/webhook_suite_test.go b/apis/infrastructure/v1beta1/webhook_suite_test.go index 3c7b9b059..4bdc7ec9d 100644 --- a/apis/infrastructure/v1beta1/webhook_suite_test.go +++ b/apis/infrastructure/v1beta1/webhook_suite_test.go @@ -16,8 +16,10 @@ import ( . "github.com/onsi/gomega" admissionv1beta1 "k8s.io/api/admission/v1beta1" + "k8s.io/kubectl/pkg/scheme" + //+kubebuilder:scaffold:imports - "k8s.io/apimachinery/pkg/runtime" + "k8s.io/client-go/rest" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" @@ -65,29 +67,28 @@ var _ = BeforeSuite(func() { Expect(err).NotTo(HaveOccurred()) Expect(cfg).NotTo(BeNil()) - scheme := runtime.NewScheme() - err = AddToScheme(scheme) + err = AddToScheme(scheme.Scheme) Expect(err).NotTo(HaveOccurred()) - err = admissionv1beta1.AddToScheme(scheme) + err = admissionv1beta1.AddToScheme(scheme.Scheme) Expect(err).NotTo(HaveOccurred()) - err = AddToScheme(scheme) + err = AddToScheme(scheme.Scheme) Expect(err).NotTo(HaveOccurred()) - err = admissionv1beta1.AddToScheme(scheme) + err = admissionv1beta1.AddToScheme(scheme.Scheme) Expect(err).NotTo(HaveOccurred()) //+kubebuilder:scaffold:scheme - k8sClient, err = client.New(cfg, client.Options{Scheme: scheme}) + k8sClient, err = client.New(cfg, client.Options{Scheme: scheme.Scheme}) Expect(err).NotTo(HaveOccurred()) Expect(k8sClient).NotTo(BeNil()) // start webhook server using Manager webhookInstallOptions := &testEnv.WebhookInstallOptions mgr, err := ctrl.NewManager(cfg, ctrl.Options{ - Scheme: scheme, + Scheme: scheme.Scheme, Host: webhookInstallOptions.LocalServingHost, Port: webhookInstallOptions.LocalServingPort, CertDir: webhookInstallOptions.LocalServingCertDir, From 7b721d012c1b478a7a23eb2596490e40b8a67aac Mon Sep 17 00:00:00 2001 From: Hui Chen Date: Tue, 11 Jan 2022 15:42:46 +0800 Subject: [PATCH 11/17] commment from anusha Signed-off-by: Hui Chen --- apis/infrastructure/v1beta1/byocluster_webhook_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apis/infrastructure/v1beta1/byocluster_webhook_test.go b/apis/infrastructure/v1beta1/byocluster_webhook_test.go index f56977d95..08e78085b 100644 --- a/apis/infrastructure/v1beta1/byocluster_webhook_test.go +++ b/apis/infrastructure/v1beta1/byocluster_webhook_test.go @@ -43,7 +43,7 @@ var _ = Describe("ByoclusterWebhook", func() { It("should reject the request when BundleLookupTag is empty", func() { err := k8sClientUncached.Create(ctx, byoCluster) Expect(err).To(HaveOccurred()) - Expect(err.Error()).To(ContainSubstring("cannot create ByoCluster without Spec.BundleLookupTag")) + Expect(err).To(MatchError("admission webhook \"vbyocluster.kb.io\" denied the request: ByoCluster.infrastructure.cluster.x-k8s.io \"" + byoCluster.Name + "\" is invalid: : Internal error: cannot create ByoCluster without Spec.BundleLookupTag")) }) }) @@ -81,7 +81,7 @@ var _ = Describe("ByoclusterWebhook", func() { byoCluster.Spec.BundleLookupTag = "" err := k8sClientUncached.Update(ctx, byoCluster) Expect(err).To(HaveOccurred()) - Expect(err.Error()).To(ContainSubstring("cannot update ByoCluster with empty Spec.BundleLookupTag")) + Expect(err).To(MatchError("admission webhook \"vbyocluster.kb.io\" denied the request: ByoCluster.infrastructure.cluster.x-k8s.io \"" + byoCluster.Name + "\" is invalid: : Internal error: cannot update ByoCluster with empty Spec.BundleLookupTag")) }) }) From b897c30f0d90e20cce992c3f82b0b047460983f3 Mon Sep 17 00:00:00 2001 From: huchen2021 <85480625+huchen2021@users.noreply.github.com> Date: Tue, 11 Jan 2022 15:44:41 +0800 Subject: [PATCH 12/17] Update apis/infrastructure/v1beta1/byocluster_webhook_test.go Co-authored-by: Anusha Hegde --- apis/infrastructure/v1beta1/byocluster_webhook_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apis/infrastructure/v1beta1/byocluster_webhook_test.go b/apis/infrastructure/v1beta1/byocluster_webhook_test.go index 08e78085b..7a8049d48 100644 --- a/apis/infrastructure/v1beta1/byocluster_webhook_test.go +++ b/apis/infrastructure/v1beta1/byocluster_webhook_test.go @@ -48,7 +48,7 @@ var _ = Describe("ByoclusterWebhook", func() { }) - Context("When ByoCluster gets a update request", func() { + Context("When ByoCluster gets an update request", func() { var ( byoCluster *ByoCluster ctx context.Context From 035d81b6ef840b4afa8ca747b97bf6af0616c897 Mon Sep 17 00:00:00 2001 From: Hui Chen Date: Tue, 11 Jan 2022 16:18:36 +0800 Subject: [PATCH 13/17] add positive case Signed-off-by: Hui Chen --- .../v1beta1/byocluster_webhook_test.go | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/apis/infrastructure/v1beta1/byocluster_webhook_test.go b/apis/infrastructure/v1beta1/byocluster_webhook_test.go index f56977d95..b13ae513c 100644 --- a/apis/infrastructure/v1beta1/byocluster_webhook_test.go +++ b/apis/infrastructure/v1beta1/byocluster_webhook_test.go @@ -43,7 +43,13 @@ var _ = Describe("ByoclusterWebhook", func() { It("should reject the request when BundleLookupTag is empty", func() { err := k8sClientUncached.Create(ctx, byoCluster) Expect(err).To(HaveOccurred()) - Expect(err.Error()).To(ContainSubstring("cannot create ByoCluster without Spec.BundleLookupTag")) + Expect(err).To(MatchError("admission webhook \"vbyocluster.kb.io\" denied the request: ByoCluster.infrastructure.cluster.x-k8s.io \"" + byoCluster.Name + "\" is invalid: : Internal error: cannot create ByoCluster without Spec.BundleLookupTag")) + }) + + It("should success when BundleLookupTag is not empty", func() { + byoCluster.Spec.BundleLookupTag = "v0.1.0_alpha.2" + err := k8sClientUncached.Create(ctx, byoCluster) + Expect(err).NotTo(HaveOccurred()) }) }) @@ -77,11 +83,21 @@ var _ = Describe("ByoclusterWebhook", func() { Expect(k8sClientUncached.Create(ctx, byoCluster)).Should(Succeed()) }) + AfterEach(func() { + Expect(k8sClientUncached.Delete(ctx, byoCluster)).Should(Succeed()) + }) + It("should reject the request when BundleLookupTag is empty", func() { byoCluster.Spec.BundleLookupTag = "" err := k8sClientUncached.Update(ctx, byoCluster) Expect(err).To(HaveOccurred()) - Expect(err.Error()).To(ContainSubstring("cannot update ByoCluster with empty Spec.BundleLookupTag")) + Expect(err).To(MatchError("admission webhook \"vbyocluster.kb.io\" denied the request: ByoCluster.infrastructure.cluster.x-k8s.io \"" + byoCluster.Name + "\" is invalid: : Internal error: cannot update ByoCluster with empty Spec.BundleLookupTag")) + }) + + It("should success when BundleLookupTag is not empty", func() { + byoCluster.Spec.BundleLookupTag = "fake" + err := k8sClientUncached.Update(ctx, byoCluster) + Expect(err).NotTo(HaveOccurred()) }) }) From 6f714ef3539f5f9ffed6626f876515a378ca95c9 Mon Sep 17 00:00:00 2001 From: huchen2021 <85480625+huchen2021@users.noreply.github.com> Date: Wed, 12 Jan 2022 10:00:17 +0800 Subject: [PATCH 14/17] Update apis/infrastructure/v1beta1/byocluster_webhook_test.go Co-authored-by: Anusha Hegde --- apis/infrastructure/v1beta1/byocluster_webhook_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apis/infrastructure/v1beta1/byocluster_webhook_test.go b/apis/infrastructure/v1beta1/byocluster_webhook_test.go index 7aa8bb54c..e79962be8 100644 --- a/apis/infrastructure/v1beta1/byocluster_webhook_test.go +++ b/apis/infrastructure/v1beta1/byocluster_webhook_test.go @@ -94,7 +94,7 @@ var _ = Describe("ByoclusterWebhook", func() { Expect(err).To(MatchError("admission webhook \"vbyocluster.kb.io\" denied the request: ByoCluster.infrastructure.cluster.x-k8s.io \"" + byoCluster.Name + "\" is invalid: : Internal error: cannot update ByoCluster with empty Spec.BundleLookupTag")) }) - It("should success when BundleLookupTag is not empty", func() { + It("should update the cluster with new BundleLookupTag value", func() { byoCluster.Spec.BundleLookupTag = "fake" err := k8sClientUncached.Update(ctx, byoCluster) Expect(err).NotTo(HaveOccurred()) From f4630fd70d68564b493f3005cb8486d9fe4dabb5 Mon Sep 17 00:00:00 2001 From: Hui Chen Date: Wed, 12 Jan 2022 10:44:36 +0800 Subject: [PATCH 15/17] comment from anusha Signed-off-by: Hui Chen --- .../infrastructure/v1beta1/byocluster_webhook_test.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/apis/infrastructure/v1beta1/byocluster_webhook_test.go b/apis/infrastructure/v1beta1/byocluster_webhook_test.go index e79962be8..b0a4a75d4 100644 --- a/apis/infrastructure/v1beta1/byocluster_webhook_test.go +++ b/apis/infrastructure/v1beta1/byocluster_webhook_test.go @@ -9,6 +9,7 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/types" "k8s.io/kubectl/pkg/scheme" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" "sigs.k8s.io/controller-runtime/pkg/client" @@ -95,9 +96,17 @@ var _ = Describe("ByoclusterWebhook", func() { }) It("should update the cluster with new BundleLookupTag value", func() { - byoCluster.Spec.BundleLookupTag = "fake" + newBundleLookupTag := "new_tag" + + byoCluster.Spec.BundleLookupTag = newBundleLookupTag err := k8sClientUncached.Update(ctx, byoCluster) Expect(err).NotTo(HaveOccurred()) + + updatedByoCluster := &ByoCluster{} + byoCLusterLookupKey := types.NamespacedName{Name: byoCluster.Name, Namespace: byoCluster.Namespace} + Expect(k8sClientUncached.Get(ctx, byoCLusterLookupKey, updatedByoCluster)).Should(Not(HaveOccurred())) + Expect(updatedByoCluster.Spec.BundleLookupTag).To(Equal(newBundleLookupTag)) + }) }) From aca3872b210f6c5969bfb1a3216313718b7899dd Mon Sep 17 00:00:00 2001 From: Hui Chen Date: Wed, 12 Jan 2022 10:53:03 +0800 Subject: [PATCH 16/17] just to trigger github runner Signed-off-by: Hui Chen --- apis/infrastructure/v1beta1/byocluster_webhook_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/apis/infrastructure/v1beta1/byocluster_webhook_test.go b/apis/infrastructure/v1beta1/byocluster_webhook_test.go index b0a4a75d4..62a284ac7 100644 --- a/apis/infrastructure/v1beta1/byocluster_webhook_test.go +++ b/apis/infrastructure/v1beta1/byocluster_webhook_test.go @@ -106,7 +106,6 @@ var _ = Describe("ByoclusterWebhook", func() { byoCLusterLookupKey := types.NamespacedName{Name: byoCluster.Name, Namespace: byoCluster.Namespace} Expect(k8sClientUncached.Get(ctx, byoCLusterLookupKey, updatedByoCluster)).Should(Not(HaveOccurred())) Expect(updatedByoCluster.Spec.BundleLookupTag).To(Equal(newBundleLookupTag)) - }) }) From 23576500a1a9bff30fe7af2f466467b927b8d85d Mon Sep 17 00:00:00 2001 From: Hui Chen Date: Wed, 12 Jan 2022 10:54:47 +0800 Subject: [PATCH 17/17] just to trigger github runner Signed-off-by: Hui Chen --- apis/infrastructure/v1beta1/byocluster_webhook_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/apis/infrastructure/v1beta1/byocluster_webhook_test.go b/apis/infrastructure/v1beta1/byocluster_webhook_test.go index 62a284ac7..c25db3ad3 100644 --- a/apis/infrastructure/v1beta1/byocluster_webhook_test.go +++ b/apis/infrastructure/v1beta1/byocluster_webhook_test.go @@ -107,6 +107,5 @@ var _ = Describe("ByoclusterWebhook", func() { Expect(k8sClientUncached.Get(ctx, byoCLusterLookupKey, updatedByoCluster)).Should(Not(HaveOccurred())) Expect(updatedByoCluster.Spec.BundleLookupTag).To(Equal(newBundleLookupTag)) }) - }) })