Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package validatingadmissionpolicy

import (
"context"
"fmt"
"io"
"sync"

Expand Down Expand Up @@ -272,7 +273,7 @@ func (k *KubeValidatingAdmissionPolicy) getOrCreateDelegate(policyClusterName, t
validating.NewValidatingAdmissionPolicyAccessor,
validating.NewValidatingAdmissionPolicyBindingAccessor,
validating.CompilePolicy,
nil,
&deferredInformerFactory{},
dynamicClient,
restMapper,
cn,
Expand Down Expand Up @@ -315,3 +316,15 @@ type stoppableValidatingAdmissionPolicy struct {
*validating.Plugin
stop func()
}

// deferredInformerFactory is a helper object to minimize changes in our upstream kubernetes fork.
// By returning an error on ForResource, we trigger a fallback to dynamic informers in the generic policy source.
// We need dynamic informer creation to correctly scope the informer based on the target cluster, which can either
// be the policy cluster or the cluster where the APIExport resides.
type deferredInformerFactory struct {
informers.SharedInformerFactory
}

func (d *deferredInformerFactory) ForResource(resource schema.GroupVersionResource) (informers.GenericInformer, error) {
return nil, fmt.Errorf("deferring creation to dynamic informer. This is expected")
}
Loading