Skip to content

Commit

Permalink
review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
chrischdi committed May 31, 2024
1 parent c9f427d commit 1dd1d9e
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"github.com/spf13/pflag"
corev1 "k8s.io/api/core/v1"
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/selection"
Expand Down Expand Up @@ -446,6 +447,18 @@ func setupReconcilers(ctx context.Context, mgr ctrl.Manager, watchNamespaces map
HTTPClient: mgr.GetHTTPClient(),
SyncPeriod: syncPeriod,
DefaultNamespaces: watchNamespaces,
DefaultTransform: func(in interface{}) (interface{}, error) {
// Use DefaultTransform to drop objects we don't expect to get into this cache.
obj, ok := in.(*metav1.PartialObjectMetadata)
if !ok {
return nil, fmt.Errorf("cache expected to only get PartialObjectMetadata, got %T", in)
}
if obj.GetObjectKind().GroupVersionKind() != corev1.SchemeGroupVersion.WithKind("Secret") {
return nil, fmt.Errorf("cache expected to only get Secrets, got %s", obj.GetObjectKind())
}
// Additionally strip managed fields.
return cache.TransformStripManagedFields()(obj)
},
})
if err != nil {
setupLog.Error(err, "Failed to create cache for metadata only Secret watches")
Expand Down

0 comments on commit 1dd1d9e

Please sign in to comment.