@@ -30,10 +30,8 @@ import (
30
30
31
31
"github.com/containers/image/v5/types"
32
32
"github.com/spf13/cobra"
33
- corev1 "k8s.io/api/core/v1"
34
33
rbacv1 "k8s.io/api/rbac/v1"
35
34
apiextensionsv1client "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1"
36
- "k8s.io/apimachinery/pkg/fields"
37
35
k8slabels "k8s.io/apimachinery/pkg/labels"
38
36
k8stypes "k8s.io/apimachinery/pkg/types"
39
37
apimachineryrand "k8s.io/apimachinery/pkg/util/rand"
@@ -75,6 +73,7 @@ import (
75
73
fsutil "github.com/operator-framework/operator-controller/internal/shared/util/fs"
76
74
httputil "github.com/operator-framework/operator-controller/internal/shared/util/http"
77
75
imageutil "github.com/operator-framework/operator-controller/internal/shared/util/image"
76
+ "github.com/operator-framework/operator-controller/internal/shared/util/pullsecretcache"
78
77
sautil "github.com/operator-framework/operator-controller/internal/shared/util/sa"
79
78
"github.com/operator-framework/operator-controller/internal/shared/version"
80
79
)
@@ -222,37 +221,17 @@ func run() error {
222
221
223
222
saKey , err := sautil .GetServiceAccount ()
224
223
if err != nil {
225
- setupLog .Error (err , "Unable to get pod namesapce and serviceaccount " )
224
+ setupLog .Error (err , "Failed to extract serviceaccount from JWT " )
226
225
return err
227
226
}
227
+ setupLog .Info ("Successfully extracted serviceaccount from JWT" , "serviceaccount" ,
228
+ fmt .Sprintf ("%s/%s" , saKey .Namespace , saKey .Name ))
228
229
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
254
234
}
255
- cacheOptions .ByObject [& corev1.Secret {}] = secretCache
256
235
257
236
metricsServerOptions := server.Options {}
258
237
if len (cfg .certFile ) > 0 && len (cfg .keyFile ) > 0 {
0 commit comments