Skip to content

Commit

Permalink
Support multiple webhook configurations in init
Browse files Browse the repository at this point in the history
Signed-off-by: Hasan Turken <turkenh@gmail.com>
  • Loading branch information
turkenh committed Sep 11, 2023
1 parent 221ab17 commit f9aca52
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cluster/webhookconfigurations/usage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingWebhookConfiguration
metadata:
name: usage-webhook-configuration
name: crossplane-no-usages
webhooks:
- admissionReviewVersions:
- v1
Expand Down
8 changes: 6 additions & 2 deletions internal/initializer/webhook_configurations.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ func (c *WebhookConfigurations) Run(ctx context.Context, kube client.Client) err
conf.Webhooks[i].ClientConfig.Service.Port = c.ServiceReference.Port
}
// See https://github.com/kubernetes-sigs/controller-tools/issues/658
conf.SetName("crossplane")
if conf.GetName() == "validating-webhook-configuration" {
conf.SetName("crossplane")
}
case *admv1.MutatingWebhookConfiguration:
for i := range conf.Webhooks {
conf.Webhooks[i].ClientConfig.CABundle = caBundle
Expand All @@ -121,7 +123,9 @@ func (c *WebhookConfigurations) Run(ctx context.Context, kube client.Client) err
conf.Webhooks[i].ClientConfig.Service.Port = c.ServiceReference.Port
}
// See https://github.com/kubernetes-sigs/controller-tools/issues/658
conf.SetName("crossplane")
if conf.GetName() == "mutating-webhook-configuration" {
conf.SetName("crossplane")
}
default:
return errors.Errorf("only MutatingWebhookConfiguration and ValidatingWebhookConfiguration kinds are accepted, got %T", obj)
}
Expand Down

0 comments on commit f9aca52

Please sign in to comment.