Skip to content

Commit

Permalink
Fix WEBHOOK_DISABLE_NAMESPACE_OWNERSHIP env-var (#3107)
Browse files Browse the repository at this point in the history
Signed-off-by: Mathew Wicks <5735406+thesuperzapper@users.noreply.github.com>
  • Loading branch information
thesuperzapper authored Oct 21, 2024
1 parent 6d10851 commit 76cfa12
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 @@ -46,6 +46,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 @@ -84,6 +84,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 @@ -70,6 +70,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 @@ -166,12 +166,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 76cfa12

Please sign in to comment.