Skip to content

Commit

Permalink
set the controller options
Browse files Browse the repository at this point in the history
Signed-off-by: Hector Fernandez <[email protected]>
  • Loading branch information
hectorj2f committed Jun 14, 2023
1 parent 7744cad commit 21f631a
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 186 deletions.
183 changes: 0 additions & 183 deletions cmd/policy_webhook/main.go

This file was deleted.

32 changes: 32 additions & 0 deletions cmd/webhook/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package main
import (
"context"
"flag"
"fmt"
"log"
"os"
"time"
Expand Down Expand Up @@ -223,6 +224,14 @@ func NewValidatingAdmissionController(ctx context.Context, cmw configmap.Watcher
policyControllerConfigStore := policycontrollerconfig.NewStore(logging.FromContext(ctx).Named("config-policy-controller"))
policyControllerConfigStore.WatchConfigs(cmw)

logger := logging.FromContext(ctx)
woptions := webhook.GetOptions(ctx)
woptions.ControllerOptions = &controller.ControllerOptions{
WorkQueueName: fmt.Sprintf("%s-%s", *webhookName, "validating"),
Logger: logger.Named(*webhookName),
}
ctx = webhook.WithOptions(ctx, *woptions)

kc := kubeclient.Get(ctx)
validator := cwebhook.NewValidator(ctx)

Expand Down Expand Up @@ -259,6 +268,13 @@ func NewValidatingAdmissionController(ctx context.Context, cmw configmap.Watcher

func NewMutatingAdmissionController(ctx context.Context, _ configmap.Watcher) *controller.Impl {
kc := kubeclient.Get(ctx)
logger := logging.FromContext(ctx)
woptions := webhook.GetOptions(ctx)
woptions.ControllerOptions = &controller.ControllerOptions{
WorkQueueName: fmt.Sprintf("%s-%s", *webhookName, "mutating"),
Logger: logger.Named(*webhookName),
}
ctx = webhook.WithOptions(ctx, *woptions)
validator := cwebhook.NewValidator(ctx)

return defaulting.NewAdmissionController(ctx,
Expand Down Expand Up @@ -292,6 +308,14 @@ func NewPolicyValidatingAdmissionController(ctx context.Context, cmw configmap.W
store.WatchConfigs(cmw)
policyControllerConfigStore := config.NewStore(logging.FromContext(ctx).Named("config-policy-controller"))
policyControllerConfigStore.WatchConfigs(cmw)
logger := logging.FromContext(ctx)

woptions := webhook.GetOptions(ctx)
woptions.ControllerOptions = &controller.ControllerOptions{
WorkQueueName: *validatingCIPWebhookName,
Logger: logger.Named(*validatingCIPWebhookName),
}
ctx = webhook.WithOptions(ctx, *woptions)

return validation.NewAdmissionController(
ctx,
Expand All @@ -307,6 +331,14 @@ func NewPolicyValidatingAdmissionController(ctx context.Context, cmw configmap.W
}

func NewPolicyMutatingAdmissionController(ctx context.Context, cmw configmap.Watcher) *controller.Impl {
woptions := webhook.GetOptions(ctx)
logger := logging.FromContext(ctx)
woptions.ControllerOptions = &controller.ControllerOptions{
WorkQueueName: *mutatingCIPWebhookName,
Logger: logger.Named(*mutatingCIPWebhookName),
}
ctx = webhook.WithOptions(ctx, *woptions)

return defaulting.NewAdmissionController(
ctx,
*mutatingCIPWebhookName,
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ require (
k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280
knative.dev/hack v0.0.0-20230417170854-f591fea109b3
knative.dev/hack/schema v0.0.0-20221024013916-9d2ae47c16b2
knative.dev/pkg v0.0.0-20230525143525-9bda38b21643
knative.dev/pkg v0.0.0-20230612083802-15605c78a270
sigs.k8s.io/release-utils v0.7.4
sigs.k8s.io/yaml v1.3.0
)
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1399,8 +1399,8 @@ knative.dev/hack v0.0.0-20230417170854-f591fea109b3 h1:+W4WBOq83tfGXKhtv8OB/uJeY
knative.dev/hack v0.0.0-20230417170854-f591fea109b3/go.mod h1:yk2OjGDsbEnQjfxdm0/HJKS2WqTLEFg/N6nUs6Rqx3Q=
knative.dev/hack/schema v0.0.0-20221024013916-9d2ae47c16b2 h1:X3EYiEmuqxiVSOPG1CsuRO+QUA956BvUw79A6oXrrs0=
knative.dev/hack/schema v0.0.0-20221024013916-9d2ae47c16b2/go.mod h1:GeIb+PLd5mllawcpHEGF5J5fYTQrvgEO5liao8lUKUs=
knative.dev/pkg v0.0.0-20230525143525-9bda38b21643 h1:DoGHeW3ckr509v87NcYSSuRHEnxKIxyJxWrrDO/71CY=
knative.dev/pkg v0.0.0-20230525143525-9bda38b21643/go.mod h1:dqC6IrvyBE7E+oZocs5PkVhq1G59pDTA7r8U17EAKMk=
knative.dev/pkg v0.0.0-20230612083802-15605c78a270 h1:lJkZy+MQA1zPRuBUWabkiCwWE/dqxf8WFwqMxz6ePfE=
knative.dev/pkg v0.0.0-20230612083802-15605c78a270/go.mod h1:dqC6IrvyBE7E+oZocs5PkVhq1G59pDTA7r8U17EAKMk=
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
Expand Down

0 comments on commit 21f631a

Please sign in to comment.