Skip to content

Commit 613ccc0

Browse files
committed
gitrepo: set conditions in gitCheckout
Signed-off-by: Sanskar Jaiswal <jaiswalsanskar078@gmail.com>
1 parent 82cd05e commit 613ccc0

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

controllers/gitrepository_controller.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -724,11 +724,12 @@ func (r *GitRepositoryReconciler) gitCheckout(ctx context.Context,
724724
checkoutStrategy, err := strategy.CheckoutStrategyForImplementation(ctx,
725725
git.Implementation(obj.Spec.GitImplementation), checkoutOpts)
726726
if err != nil {
727+
// Do not return err as recovery without changes is impossible.
727728
e := &serror.Stalling{
728729
Err: fmt.Errorf("failed to configure checkout strategy for Git implementation '%s': %w", obj.Spec.GitImplementation, err),
729730
Reason: sourcev1.GitOperationFailedReason,
730731
}
731-
// Do not return err as recovery without changes is impossible.
732+
conditions.MarkTrue(obj, sourcev1.FetchFailedCondition, e.Reason, e.Err.Error())
732733
return nil, e
733734
}
734735

@@ -744,9 +745,10 @@ func (r *GitRepositoryReconciler) gitCheckout(ctx context.Context,
744745
authOpts.TransportOptionsURL = fmt.Sprintf("ssh://%s/%s/%d", obj.Name, obj.UID, obj.Generation)
745746
} else {
746747
e := &serror.Stalling{
747-
Err: fmt.Errorf("git repository URL has invalid transport type: '%s'", obj.Spec.URL),
748+
Err: fmt.Errorf("git repository URL '%s' has invalid transport type, supported types are: http, https, ssh", obj.Spec.URL),
748749
Reason: sourcev1.URLInvalidReason,
749750
}
751+
conditions.MarkTrue(obj, sourcev1.FetchFailedCondition, e.Reason, e.Err.Error())
750752
return nil, e
751753
}
752754
}

0 commit comments

Comments
 (0)