@@ -62,7 +62,7 @@ import (
62
62
olmerrors "github.com/operator-framework/operator-lifecycle-manager/pkg/controller/errors"
63
63
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/install"
64
64
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/operators/catalog/subscription"
65
- "github.com/operator-framework/operator-lifecycle-manager/pkg/controller/operators/internal/pruning "
65
+ "github.com/operator-framework/operator-lifecycle-manager/pkg/controller/operators/internal/listerwatcher "
66
66
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/registry"
67
67
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/registry/grpc"
68
68
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/registry/reconciler"
@@ -228,38 +228,53 @@ func NewOperator(ctx context.Context, kubeconfigPath string, clock utilclock.Clo
228
228
229
229
// Fields are pruned from local copies of the objects managed
230
230
// by this informer in order to reduce cached size.
231
- prunedCSVInformer := cache .NewSharedIndexInformer (
232
- pruning .NewListerWatcher (op .client , metav1 .NamespaceAll ,
231
+ prunedCSVInformer := cache .NewSharedIndexInformerWithOptions (
232
+ listerwatcher .NewListerWatcher (
233
+ op .client ,
234
+ metav1 .NamespaceAll ,
233
235
func (options * metav1.ListOptions ) {
234
236
options .LabelSelector = fmt .Sprintf ("!%s" , v1alpha1 .CopiedLabelKey )
235
237
},
236
- pruning .PrunerFunc (func (csv * v1alpha1.ClusterServiceVersion ) {
237
- * csv = v1alpha1.ClusterServiceVersion {
238
- TypeMeta : csv .TypeMeta ,
239
- ObjectMeta : metav1.ObjectMeta {
240
- Name : csv .Name ,
241
- Namespace : csv .Namespace ,
242
- Labels : csv .Labels ,
243
- Annotations : csv .Annotations ,
244
- },
245
- Spec : v1alpha1.ClusterServiceVersionSpec {
246
- CustomResourceDefinitions : csv .Spec .CustomResourceDefinitions ,
247
- APIServiceDefinitions : csv .Spec .APIServiceDefinitions ,
248
- Replaces : csv .Spec .Replaces ,
249
- Version : csv .Spec .Version ,
250
- },
251
- Status : v1alpha1.ClusterServiceVersionStatus {
252
- Phase : csv .Status .Phase ,
253
- Reason : csv .Status .Reason ,
254
- },
255
- }
256
- })),
238
+ ),
257
239
& v1alpha1.ClusterServiceVersion {},
258
- resyncPeriod (),
259
- cache.Indexers {
260
- cache .NamespaceIndex : cache .MetaNamespaceIndexFunc ,
240
+ cache.SharedIndexInformerOptions {
241
+ ResyncPeriod : resyncPeriod (),
242
+ Indexers : cache.Indexers {
243
+ cache .NamespaceIndex : cache .MetaNamespaceIndexFunc ,
244
+ },
261
245
},
262
246
)
247
+
248
+ // Transformed the CSV to be just the necessary data
249
+ prunedCSVTransformFunc := func (i interface {}) (interface {}, error ) {
250
+ if csv , ok := i .(* v1alpha1.ClusterServiceVersion ); ok {
251
+ * csv = v1alpha1.ClusterServiceVersion {
252
+ TypeMeta : csv .TypeMeta ,
253
+ ObjectMeta : metav1.ObjectMeta {
254
+ Name : csv .Name ,
255
+ Namespace : csv .Namespace ,
256
+ Labels : csv .Labels ,
257
+ Annotations : csv .Annotations ,
258
+ },
259
+ Spec : v1alpha1.ClusterServiceVersionSpec {
260
+ CustomResourceDefinitions : csv .Spec .CustomResourceDefinitions ,
261
+ APIServiceDefinitions : csv .Spec .APIServiceDefinitions ,
262
+ Replaces : csv .Spec .Replaces ,
263
+ Version : csv .Spec .Version ,
264
+ },
265
+ Status : v1alpha1.ClusterServiceVersionStatus {
266
+ Phase : csv .Status .Phase ,
267
+ Reason : csv .Status .Reason ,
268
+ },
269
+ }
270
+ return csv , nil
271
+ }
272
+ return nil , fmt .Errorf ("unable to convert input to CSV" )
273
+ }
274
+
275
+ if err := prunedCSVInformer .SetTransform (prunedCSVTransformFunc ); err != nil {
276
+ return nil , err
277
+ }
263
278
csvLister := operatorsv1alpha1listers .NewClusterServiceVersionLister (prunedCSVInformer .GetIndexer ())
264
279
op .lister .OperatorsV1alpha1 ().RegisterClusterServiceVersionLister (metav1 .NamespaceAll , csvLister )
265
280
if err := op .RegisterInformer (prunedCSVInformer ); err != nil {
0 commit comments