Skip to content

Commit 6e680b3

Browse files
committed
Fix EnqueueRequestsFromMapFunc for secretSync
1 parent 5ab2f04 commit 6e680b3

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

pkg/controllers/secretsync/watch_predicates.go

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,28 @@ import (
1919
"context"
2020

2121
corev1 "k8s.io/api/core/v1"
22-
"k8s.io/apimachinery/pkg/runtime"
2322
"sigs.k8s.io/controller-runtime/pkg/client"
2423
"sigs.k8s.io/controller-runtime/pkg/event"
2524
"sigs.k8s.io/controller-runtime/pkg/predicate"
2625
"sigs.k8s.io/controller-runtime/pkg/reconcile"
2726
)
2827

29-
func toUserDataSecret(ctx context.Context, obj client.Object) []reconcile.Request {
30-
secret, ok := obj.(*corev1.Secret)
31-
if !ok {
32-
return nil
33-
}
28+
func toUserDataSecret(namespace string) func(context.Context, client.Object) []reconcile.Request {
29+
return func(ctx context.Context, obj client.Object) []reconcile.Request {
30+
secret, ok := obj.(*corev1.Secret)
31+
if !ok {
32+
return nil
33+
}
3434

35-
// Map the source secret to the target secret with the same name
36-
return []reconcile.Request{{
37-
NamespacedName: client.ObjectKey{Name: secret.GetName(), Namespace: SecretSourceNamespace},
38-
}}
35+
// Map the source secret to the target secret with the same name
36+
return []reconcile.Request{{
37+
NamespacedName: client.ObjectKey{Name: secret.GetName(), Namespace: namespace},
38+
}}
39+
}
3940
}
4041

4142
func userDataSecretPredicate(targetNamespace string) predicate.Funcs {
42-
isOwnedUserDataSecret := func(obj runtime.Object) bool {
43+
isOwnedUserDataSecret := func(obj client.Object) bool {
4344
secret, ok := obj.(*corev1.Secret)
4445
if !ok {
4546
return false

0 commit comments

Comments
 (0)