mirror of https://github.com/knative/pkg.git
rename the variable for resource validation webhook (#653)
This commit is contained in:
parent
7b67118970
commit
c39ee25c42
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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")
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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{},
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue