From c39ee25c42f53e4024d60511a2edef2065ea7333 Mon Sep 17 00:00:00 2001 From: Nima Kaviani Date: Wed, 11 Sep 2019 15:40:29 +0200 Subject: [PATCH] rename the variable for resource validation webhook (#653) --- webhook/resource_admission_controller.go | 6 +++--- webhook/resource_admission_controller_test.go | 6 +++--- webhook/webhook.go | 4 ++-- webhook/webhook_test.go | 10 +++++----- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/webhook/resource_admission_controller.go b/webhook/resource_admission_controller.go index c6441a24b..167827e0b 100644 --- a/webhook/resource_admission_controller.go +++ b/webhook/resource_admission_controller.go @@ -141,10 +141,10 @@ func (ac *ResourceAdmissionController) Register(ctx context.Context, kubeClient webhook := &admissionregistrationv1beta1.MutatingWebhookConfiguration{ ObjectMeta: metav1.ObjectMeta{ - Name: ac.options.WebhookName, + Name: ac.options.ResourceMutatingWebhookName, }, Webhooks: []admissionregistrationv1beta1.Webhook{{ - Name: ac.options.WebhookName, + Name: ac.options.ResourceMutatingWebhookName, Rules: rules, ClientConfig: admissionregistrationv1beta1.WebhookClientConfig{ Service: &admissionregistrationv1beta1.ServiceReference{ @@ -173,7 +173,7 @@ func (ac *ResourceAdmissionController) Register(ctx context.Context, kubeClient return fmt.Errorf("failed to create a webhook: %v", err) } logger.Info("Webhook already exists") - configuredWebhook, err := client.Get(ac.options.WebhookName, metav1.GetOptions{}) + configuredWebhook, err := client.Get(ac.options.ResourceMutatingWebhookName, metav1.GetOptions{}) if err != nil { return fmt.Errorf("error retrieving webhook: %v", err) } diff --git a/webhook/resource_admission_controller_test.go b/webhook/resource_admission_controller_test.go index 7decff29e..498d3e06b 100644 --- a/webhook/resource_admission_controller_test.go +++ b/webhook/resource_admission_controller_test.go @@ -537,10 +537,10 @@ func TestUpdatingWebhook(t *testing.T) { ac := c.(*ResourceAdmissionController) webhook := &admissionregistrationv1beta1.MutatingWebhookConfiguration{ ObjectMeta: metav1.ObjectMeta{ - Name: ac.options.WebhookName, + Name: ac.options.ResourceMutatingWebhookName, }, Webhooks: []admissionregistrationv1beta1.Webhook{{ - Name: ac.options.WebhookName, + Name: ac.options.ResourceMutatingWebhookName, Rules: []admissionregistrationv1beta1.RuleWithOperations{{}}, ClientConfig: admissionregistrationv1beta1.WebhookClientConfig{}, }}, @@ -553,7 +553,7 @@ func TestUpdatingWebhook(t *testing.T) { t.Fatalf("Failed to create webhook: %s", err) } - currentWebhook, _ := kubeClient.AdmissionregistrationV1beta1().MutatingWebhookConfigurations().Get(ac.options.WebhookName, metav1.GetOptions{}) + currentWebhook, _ := kubeClient.AdmissionregistrationV1beta1().MutatingWebhookConfigurations().Get(ac.options.ResourceMutatingWebhookName, metav1.GetOptions{}) if reflect.DeepEqual(currentWebhook.Webhooks, webhook.Webhooks) { t.Fatalf("Expected webhook to be updated") } diff --git a/webhook/webhook.go b/webhook/webhook.go index b153d2093..817198c2f 100644 --- a/webhook/webhook.go +++ b/webhook/webhook.go @@ -52,9 +52,9 @@ var ( // ControllerOptions contains the configuration for the webhook type ControllerOptions struct { - // WebhookName is the name of the webhook we create to handle + // ResourceMutatingWebhookName is the name of the webhook we create to handle // mutations before they get stored in the storage. - WebhookName string + ResourceMutatingWebhookName string // ServiceName is the service name of the webhook. ServiceName string diff --git a/webhook/webhook_test.go b/webhook/webhook_test.go index b5534dc9d..a61976a43 100644 --- a/webhook/webhook_test.go +++ b/webhook/webhook_test.go @@ -42,7 +42,7 @@ func newDefaultOptions() ControllerOptions { ServiceName: "webhook", Port: 443, SecretName: "webhook-certs", - WebhookName: "webhook.knative.dev", + ResourceMutatingWebhookName: "webhook.knative.dev", ResourceAdmissionControllerPath: "/", } } @@ -73,11 +73,11 @@ func TestRegistrationStopChanFire(t *testing.T) { kubeClient, ac := newNonRunningTestWebhook(t, opts) webhook := &admissionregistrationv1beta1.MutatingWebhookConfiguration{ ObjectMeta: metav1.ObjectMeta{ - Name: ac.Options.WebhookName, + Name: ac.Options.ResourceMutatingWebhookName, }, Webhooks: []admissionregistrationv1beta1.Webhook{ { - Name: ac.Options.WebhookName, + Name: ac.Options.ResourceMutatingWebhookName, Rules: []admissionregistrationv1beta1.RuleWithOperations{{}}, ClientConfig: admissionregistrationv1beta1.WebhookClientConfig{}, }, @@ -108,11 +108,11 @@ func TestRegistrationForAlreadyExistingWebhook(t *testing.T) { kubeClient, ac := newNonRunningTestWebhook(t, newDefaultOptions()) webhook := &admissionregistrationv1beta1.MutatingWebhookConfiguration{ ObjectMeta: metav1.ObjectMeta{ - Name: ac.Options.WebhookName, + Name: ac.Options.ResourceMutatingWebhookName, }, Webhooks: []admissionregistrationv1beta1.Webhook{ { - Name: ac.Options.WebhookName, + Name: ac.Options.ResourceMutatingWebhookName, Rules: []admissionregistrationv1beta1.RuleWithOperations{{}}, ClientConfig: admissionregistrationv1beta1.WebhookClientConfig{}, },