@@ -23,8 +23,8 @@ import (
23
23
"strings"
24
24
25
25
"go.uber.org/zap"
26
+ "k8s.io/client-go/kubernetes"
26
27
corev1listers "k8s.io/client-go/listers/core/v1"
27
- kubeclient "knative.dev/pkg/client/injection/kube/client"
28
28
29
29
corev1 "k8s.io/api/core/v1"
30
30
"k8s.io/apimachinery/pkg/runtime/schema"
@@ -202,7 +202,7 @@ func (sb *SinkBinding) Do(ctx context.Context, ps *duckv1.WithPod) {
202
202
Version : SchemeGroupVersion .Version ,
203
203
Kind : "SinkBinding" ,
204
204
}
205
- bundles , err := eventingtls .PropagateTrustBundles (ctx , kubeclient . Get (ctx ), GetTrustBundleConfigMapLister (ctx ), gvk , sb )
205
+ bundles , err := eventingtls .PropagateTrustBundles (ctx , getKubeClient (ctx ), GetTrustBundleConfigMapLister (ctx ), gvk , sb )
206
206
if err != nil {
207
207
logging .FromContext (ctx ).Errorw ("Failed to propagate trust bundles" , zap .Error (err ))
208
208
}
@@ -328,6 +328,20 @@ func (sb *SinkBinding) Undo(ctx context.Context, ps *duckv1.WithPod) {
328
328
}
329
329
}
330
330
331
+ type kubeClientKey struct {}
332
+
333
+ func WithKubeClient (ctx context.Context , k kubernetes.Interface ) context.Context {
334
+ return context .WithValue (ctx , kubeClientKey {}, k )
335
+ }
336
+
337
+ func getKubeClient (ctx context.Context ) kubernetes.Interface {
338
+ k := ctx .Value (kubeClientKey {})
339
+ if k == nil {
340
+ return nil
341
+ }
342
+ return k .(kubernetes.Interface )
343
+ }
344
+
331
345
type configMapListerKey struct {}
332
346
333
347
func WithTrustBundleConfigMapLister (ctx context.Context , lister corev1listers.ConfigMapLister ) context.Context {
0 commit comments