From 95a6360ba17ab83ae6fb24b0ae69d08725970b8f Mon Sep 17 00:00:00 2001 From: Paulo Gomes Date: Mon, 31 Oct 2022 09:17:50 +0000 Subject: [PATCH] Removes duplicated error handling Signed-off-by: Paulo Gomes --- controllers/gitrepository_controller.go | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/controllers/gitrepository_controller.go b/controllers/gitrepository_controller.go index 9e5490086..cdcf7bbb6 100644 --- a/controllers/gitrepository_controller.go +++ b/controllers/gitrepository_controller.go @@ -442,7 +442,7 @@ func (r *GitRepositoryReconciler) reconcileSource(ctx context.Context, conditions.Delete(obj, sourcev1.SourceVerifiedCondition) } - var data map[string][]byte + var authData map[string][]byte if obj.Spec.SecretRef != nil { // Attempt to retrieve secret name := types.NamespacedName{ @@ -459,7 +459,7 @@ func (r *GitRepositoryReconciler) reconcileSource(ctx context.Context, // Return error as the world as observed may change return sreconcile.ResultEmpty, e } - data = secret.Data + authData = secret.Data } u, err := url.Parse(obj.Spec.URL) @@ -473,8 +473,7 @@ func (r *GitRepositoryReconciler) reconcileSource(ctx context.Context, } // Configure authentication strategy to access the source - authOpts, err := git.NewAuthOptions(*u, data) - + authOpts, err := git.NewAuthOptions(*u, authData) if err != nil { e := serror.NewGeneric( fmt.Errorf("failed to configure authentication options: %w", err), @@ -483,15 +482,6 @@ func (r *GitRepositoryReconciler) reconcileSource(ctx context.Context, conditions.MarkTrue(obj, sourcev1.FetchFailedCondition, e.Reason, e.Err.Error()) return sreconcile.ResultEmpty, e } - if err != nil { - e := serror.NewGeneric( - fmt.Errorf("failed to configure auth strategy for Git implementation '%s': %w", obj.Spec.GitImplementation, err), - sourcev1.AuthenticationFailedReason, - ) - conditions.MarkTrue(obj, sourcev1.FetchFailedCondition, e.Reason, e.Err.Error()) - // Return error as the contents of the secret may change - return sreconcile.ResultEmpty, e - } // Fetch the included artifact metadata. artifacts, err := r.fetchIncludes(ctx, obj)