Skip to content

Commit

Permalink
added filtered informer for pingsource service accounts
Browse files Browse the repository at this point in the history
  • Loading branch information
yijie-04 committed Jan 12, 2024
1 parent 7d73360 commit c048610
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
5 changes: 3 additions & 2 deletions pkg/reconciler/pingsource/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ package pingsource
import (
"context"

"knative.dev/eventing/pkg/apis/sources"
sourcesv1 "knative.dev/eventing/pkg/apis/sources/v1"

serviceaccountinformer "knative.dev/pkg/client/injection/kube/informers/core/v1/serviceaccount"
serviceaccountinformer "knative.dev/pkg/client/injection/kube/informers/core/v1/serviceaccount/filtered"

"go.uber.org/zap"

Expand Down Expand Up @@ -77,7 +78,7 @@ func NewController(

deploymentInformer := deploymentinformer.Get(ctx)
pingSourceInformer := pingsourceinformer.Get(ctx)
serviceaccountInformer := serviceaccountinformer.Get(ctx)
serviceaccountInformer := serviceaccountinformer.Get(ctx, sources.OIDCTokenRoleLabelSelector)

r := &Reconciler{
kubeClientSet: kubeclient.Get(ctx),
Expand Down
10 changes: 9 additions & 1 deletion pkg/reconciler/pingsource/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@ limitations under the License.
package pingsource

import (
"context"
"testing"

corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"knative.dev/eventing/pkg/apis/feature"

filteredFactory "knative.dev/pkg/client/injection/kube/informers/factory/filtered"
"knative.dev/eventing/pkg/apis/sources"
"knative.dev/pkg/configmap"
"knative.dev/pkg/logging"
"knative.dev/pkg/metrics"
Expand All @@ -39,7 +42,7 @@ import (
)

func TestNew(t *testing.T) {
ctx, _ := SetupFakeContext(t)
ctx, _ := SetupFakeContext(t, SetUpInformerSelector)
c := NewController(ctx, configmap.NewStaticWatcher(
&corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Expand Down Expand Up @@ -90,3 +93,8 @@ func TestNew(t *testing.T) {
t.Fatal("Expected NewController to return a non-nil value")
}
}

func SetUpInformerSelector(ctx context.Context) context.Context {
ctx = filteredFactory.WithSelectors(ctx, sources.OIDCTokenRoleLabelSelector)
return ctx
}

0 comments on commit c048610

Please sign in to comment.