@@ -30,10 +30,8 @@ import (
3030
3131 "github.com/containers/image/v5/types"
3232 "github.com/spf13/cobra"
33- corev1 "k8s.io/api/core/v1"
3433 rbacv1 "k8s.io/api/rbac/v1"
3534 apiextensionsv1client "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1"
36- "k8s.io/apimachinery/pkg/fields"
3735 k8slabels "k8s.io/apimachinery/pkg/labels"
3836 k8stypes "k8s.io/apimachinery/pkg/types"
3937 apimachineryrand "k8s.io/apimachinery/pkg/util/rand"
@@ -75,6 +73,7 @@ import (
7573 fsutil "github.com/operator-framework/operator-controller/internal/shared/util/fs"
7674 httputil "github.com/operator-framework/operator-controller/internal/shared/util/http"
7775 imageutil "github.com/operator-framework/operator-controller/internal/shared/util/image"
76+ "github.com/operator-framework/operator-controller/internal/shared/util/pullsecretcache"
7877 sautil "github.com/operator-framework/operator-controller/internal/shared/util/sa"
7978 "github.com/operator-framework/operator-controller/internal/shared/version"
8079)
@@ -222,37 +221,17 @@ func run() error {
222221
223222 saKey , err := sautil .GetServiceAccount ()
224223 if err != nil {
225- setupLog .Error (err , "Unable to get pod namesapce and serviceaccount " )
224+ setupLog .Error (err , "Failed to extract serviceaccount from JWT " )
226225 return err
227226 }
227+ setupLog .Info ("Successfully extracted serviceaccount from JWT" , "serviceaccount" ,
228+ fmt .Sprintf ("%s/%s" , saKey .Namespace , saKey .Name ))
228229
229- setupLog .Info ("Read token" , "serviceaccount" , saKey )
230- cacheOptions .ByObject [& corev1.ServiceAccount {}] = crcache.ByObject {
231- Namespaces : map [string ]crcache.Config {
232- saKey .Namespace : {
233- LabelSelector : k8slabels .Everything (),
234- FieldSelector : fields .SelectorFromSet (map [string ]string {
235- "metadata.name" : saKey .Name ,
236- }),
237- },
238- },
239- }
240-
241- secretCache := crcache.ByObject {}
242- secretCache .Namespaces = make (map [string ]crcache.Config , 2 )
243- secretCache .Namespaces [saKey .Namespace ] = crcache.Config {
244- LabelSelector : k8slabels .Everything (),
245- FieldSelector : fields .Everything (),
246- }
247- if globalPullSecretKey != nil {
248- secretCache .Namespaces [globalPullSecretKey .Namespace ] = crcache.Config {
249- LabelSelector : k8slabels .Everything (),
250- FieldSelector : fields .SelectorFromSet (map [string ]string {
251- "metadata.name" : globalPullSecretKey .Name ,
252- }),
253- }
230+ err = pullsecretcache .SetupPullSecretCache (& cacheOptions , globalPullSecretKey , saKey )
231+ if err != nil {
232+ setupLog .Error (err , "Unable to setup pull-secret cache" )
233+ return err
254234 }
255- cacheOptions .ByObject [& corev1.Secret {}] = secretCache
256235
257236 metricsServerOptions := server.Options {}
258237 if len (cfg .certFile ) > 0 && len (cfg .keyFile ) > 0 {
0 commit comments