Skip to content

Commit

Permalink
FORK: Fix WEBHOOK_DISABLE_NAMESPACE_OWNERSHIP env-var (knative#3107)
Browse files Browse the repository at this point in the history
Signed-off-by: Mathew Wicks <[email protected]>
  • Loading branch information
thesuperzapper committed Oct 17, 2024
1 parent aeefea6 commit 3db6060
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
6 changes: 6 additions & 0 deletions webhook/configmaps/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ func NewAdmissionController(
secretInformer := secretinformer.Get(ctx)
options := webhook.GetOptions(ctx)

// if this environment variable is set, it overrides the value in the Options
disableNamespaceOwnership := webhook.DisableNamespaceOwnershipFromEnv()
if disableNamespaceOwnership != nil {
options.DisableNamespaceOwnership = *disableNamespaceOwnership
}

key := types.NamespacedName{Name: name}

wh := &reconciler{
Expand Down
6 changes: 6 additions & 0 deletions webhook/resourcesemantics/defaulting/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ func newController(ctx context.Context, name string, optsFunc ...OptionFunc) *co
f(opts)
}

// if this environment variable is set, it overrides the value in the Options
disableNamespaceOwnership := webhook.DisableNamespaceOwnershipFromEnv()
if disableNamespaceOwnership != nil {
wopts.DisableNamespaceOwnership = *disableNamespaceOwnership
}

key := types.NamespacedName{Name: name}

wh := &reconciler{
Expand Down
6 changes: 6 additions & 0 deletions webhook/resourcesemantics/validation/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ func newController(ctx context.Context, name string, optsFunc ...OptionFunc) *co
f(opts)
}

// if this environment variable is set, it overrides the value in the Options
disableNamespaceOwnership := webhook.DisableNamespaceOwnershipFromEnv()
if disableNamespaceOwnership != nil {
woptions.DisableNamespaceOwnership = *disableNamespaceOwnership
}

wh := &reconciler{
LeaderAwareFuncs: pkgreconciler.LeaderAwareFuncs{
// Have this reconciler enqueue our singleton whenever it becomes leader.
Expand Down
6 changes: 0 additions & 6 deletions webhook/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,6 @@ func New(
return nil, fmt.Errorf("unsupported TLS version: %d", opts.TLSMinVersion)
}

// if the environment variable is set, it overrides the value in the Options
disableNamespaceOwnership := DisableNamespaceOwnershipFromEnv()
if disableNamespaceOwnership != nil {
opts.DisableNamespaceOwnership = *disableNamespaceOwnership
}

syncCtx, cancel := context.WithCancel(context.Background())

webhook = &Webhook{
Expand Down

0 comments on commit 3db6060

Please sign in to comment.