Skip to content

Commit b8128cf

Browse files
committed
Reinstate Git cloning timeout
Signed-off-by: Stefan Prodan <[email protected]>
1 parent 4087834 commit b8128cf

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

controllers/gitrepository_controller.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,10 +272,15 @@ func (r *GitRepositoryReconciler) reconcile(ctx context.Context, repository sour
272272
if err != nil {
273273
return sourcev1.GitRepositoryNotReady(repository, sourcev1.GitOperationFailedReason, err.Error()), err
274274
}
275-
commit, revision, err := checkoutStrategy.Checkout(ctx, tmpGit, repository.Spec.URL, auth)
275+
276+
gitCtx, cancel := context.WithTimeout(ctx, repository.Spec.Timeout.Duration)
277+
defer cancel()
278+
279+
commit, revision, err := checkoutStrategy.Checkout(gitCtx, tmpGit, repository.Spec.URL, auth)
276280
if err != nil {
277281
return sourcev1.GitRepositoryNotReady(repository, sourcev1.GitOperationFailedReason, err.Error()), err
278282
}
283+
279284
artifact := r.Storage.NewArtifactFor(repository.Kind, repository.GetObjectMeta(), revision, fmt.Sprintf("%s.tar.gz", commit.Hash()))
280285

281286
// copy all included repository into the artifact

0 commit comments

Comments
 (0)