// requestsForApplicationChange returns a reconcile request when an Application changes
requestsForApplicationChange returns a reconcile request when an Application changes
// requestsForApplicationChange returns a reconcile request when an Application changes
func (r *ProgressiveSyncReconciler) requestsForApplicationChange(o client.Object) []reconcile.Request {
	var requests []reconcile.Request
	var list syncv1alpha1.ProgressiveSyncList
	ctx := context.Background()
	app, ok := o.(*argov1alpha1.Application)
	if !ok {
		err := fmt.Errorf("expected application, got %T", o)
		r.Log.Error(err, "failed to convert object to application")
		return nil
	}
	if err := r.List(ctx, &list); err != nil {
		r.Log.Error(err, "failed to list ProgressiveSync")
		return nil
	}
	for _, pr := range list.Items {
		if pr.Owns(app.GetOwnerReferences()) {
			requests = append(requests, reconcile.Request{NamespacedName: types.NamespacedName{
				Namespace: pr.Namespace,
				Name:      pr.Name,
			}})
			r.Log.Info("application changed", "app", fmt.Sprintf("%s/%s", app.Namespace, app.Name), "sync.status", app.Status.Sync.Status, "health.status", app.Status.Health.Status)
		}
	}
	return requests
}
func ( r * ProgressiveSyncReconciler ) requestsForApplicationChange ( o client . Object ) [ ] reconcile . Request { var requests [ ] reconcile . Request var list syncv1alpha1 . ProgressiveSyncList ctx := context . Background ( ) app , ok := o . ( * argov1alpha1 . Application ) if ! ok { err := fmt . Errorf ( " " , o ) r . Log . Error ( err , " " ) return nil } if err := r . List ( ctx , & list ) ; err != nil { r . Log . Error ( err , " " ) return nil } for _ , pr := range list . Items { if pr . Owns ( app . GetOwnerReferences ( ) ) { requests = append ( requests , reconcile . Request { NamespacedName : types . NamespacedName { Namespace : pr . Namespace , Name : pr . Name , } } ) r . Log . Info ( " " , " " , fmt . Sprintf ( " " , app . Namespace , app . Name ) , " " , app . Status . Sync . Status , " " , app . Status . Health . Status ) } } return requests }
requestsForApplicationChange returns a reconcile request when an Application changes
requestsForApplicationChange returns a reconcile request when an Application changes
/*
		We trigger a reconciliation loop on an Application event if:
		- the Application owner is referenced by a ProgressiveSync object
	*/