@@ -134,7 +134,11 @@ func (r *ImageUpdateAutomationReconciler) SetupWithManager(ctx context.Context,
134
134
if err := mgr .GetFieldIndexer ().IndexField (ctx , & imagev1.ImageUpdateAutomation {}, repoRefKey , func (obj client.Object ) []string {
135
135
updater := obj .(* imagev1.ImageUpdateAutomation )
136
136
ref := updater .Spec .SourceRef
137
- return []string {ref .Name }
137
+ ns := ref .Namespace
138
+ if ns == "" {
139
+ ns = obj .GetNamespace ()
140
+ }
141
+ return []string {fmt .Sprintf ("%s/%s" , ns , ref .Name )}
138
142
}); err != nil {
139
143
return err
140
144
}
@@ -162,8 +166,8 @@ func (r *ImageUpdateAutomationReconciler) SetupWithManager(ctx context.Context,
162
166
// particular source.GitRepository object.
163
167
func (r * ImageUpdateAutomationReconciler ) automationsForGitRepo (ctx context.Context , obj client.Object ) []reconcile.Request {
164
168
var autoList imagev1.ImageUpdateAutomationList
165
- if err := r . List ( ctx , & autoList , client . InNamespace ( obj .GetNamespace ()),
166
- client.MatchingFields {repoRefKey : obj . GetName () }); err != nil {
169
+ objKey := fmt . Sprintf ( "%s/%s" , obj . GetNamespace (), obj .GetName ())
170
+ if err := r . List ( ctx , & autoList , client.MatchingFields {repoRefKey : objKey }); err != nil {
167
171
ctrl .LoggerFrom (ctx ).Error (err , "failed to list ImageUpdateAutomations for GitRepository change" )
168
172
return nil
169
173
}
0 commit comments