Merge pull request #945 from fluxcd/fix-source-index
Fix GitRepository namespace not used in watch index key
This commit is contained in:
commit
3bff81a4e0
|
@ -134,7 +134,11 @@ func (r *ImageUpdateAutomationReconciler) SetupWithManager(ctx context.Context,
|
||||||
if err := mgr.GetFieldIndexer().IndexField(ctx, &imagev1.ImageUpdateAutomation{}, repoRefKey, func(obj client.Object) []string {
|
if err := mgr.GetFieldIndexer().IndexField(ctx, &imagev1.ImageUpdateAutomation{}, repoRefKey, func(obj client.Object) []string {
|
||||||
updater := obj.(*imagev1.ImageUpdateAutomation)
|
updater := obj.(*imagev1.ImageUpdateAutomation)
|
||||||
ref := updater.Spec.SourceRef
|
ref := updater.Spec.SourceRef
|
||||||
return []string{ref.Name}
|
ns := ref.Namespace
|
||||||
|
if ns == "" {
|
||||||
|
ns = obj.GetNamespace()
|
||||||
|
}
|
||||||
|
return []string{fmt.Sprintf("%s/%s", ns, ref.Name)}
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -162,8 +166,8 @@ func (r *ImageUpdateAutomationReconciler) SetupWithManager(ctx context.Context,
|
||||||
// particular source.GitRepository object.
|
// particular source.GitRepository object.
|
||||||
func (r *ImageUpdateAutomationReconciler) automationsForGitRepo(ctx context.Context, obj client.Object) []reconcile.Request {
|
func (r *ImageUpdateAutomationReconciler) automationsForGitRepo(ctx context.Context, obj client.Object) []reconcile.Request {
|
||||||
var autoList imagev1.ImageUpdateAutomationList
|
var autoList imagev1.ImageUpdateAutomationList
|
||||||
if err := r.List(ctx, &autoList, client.InNamespace(obj.GetNamespace()),
|
objKey := fmt.Sprintf("%s/%s", obj.GetNamespace(), obj.GetName())
|
||||||
client.MatchingFields{repoRefKey: obj.GetName()}); err != nil {
|
if err := r.List(ctx, &autoList, client.MatchingFields{repoRefKey: objKey}); err != nil {
|
||||||
ctrl.LoggerFrom(ctx).Error(err, "failed to list ImageUpdateAutomations for GitRepository change")
|
ctrl.LoggerFrom(ctx).Error(err, "failed to list ImageUpdateAutomations for GitRepository change")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue