@@ -134,7 +134,11 @@ func (r *ImageUpdateAutomationReconciler) SetupWithManager(ctx context.Context,
134134 if err := mgr .GetFieldIndexer ().IndexField (ctx , & imagev1.ImageUpdateAutomation {}, repoRefKey , func (obj client.Object ) []string {
135135 updater := obj .(* imagev1.ImageUpdateAutomation )
136136 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 )}
138142 }); err != nil {
139143 return err
140144 }
@@ -162,8 +166,9 @@ func (r *ImageUpdateAutomationReconciler) SetupWithManager(ctx context.Context,
162166// particular source.GitRepository object.
163167func (r * ImageUpdateAutomationReconciler ) automationsForGitRepo (ctx context.Context , obj client.Object ) []reconcile.Request {
164168 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 ,
171+ client.MatchingFields {repoRefKey : objKey }); err != nil {
167172 ctrl .LoggerFrom (ctx ).Error (err , "failed to list ImageUpdateAutomations for GitRepository change" )
168173 return nil
169174 }
0 commit comments