Reinstate Git cloning timeout

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
This commit is contained in:
Stefan Prodan 2021-06-02 14:21:29 +03:00
parent 4087834e8e
commit b8128cf58b
No known key found for this signature in database
GPG Key ID: 3299AEB0E4085BAF
1 changed files with 6 additions and 1 deletions

View File

@ -272,10 +272,15 @@ func (r *GitRepositoryReconciler) reconcile(ctx context.Context, repository sour
if err != nil {
return sourcev1.GitRepositoryNotReady(repository, sourcev1.GitOperationFailedReason, err.Error()), err
}
commit, revision, err := checkoutStrategy.Checkout(ctx, tmpGit, repository.Spec.URL, auth)
gitCtx, cancel := context.WithTimeout(ctx, repository.Spec.Timeout.Duration)
defer cancel()
commit, revision, err := checkoutStrategy.Checkout(gitCtx, tmpGit, repository.Spec.URL, auth)
if err != nil {
return sourcev1.GitRepositoryNotReady(repository, sourcev1.GitOperationFailedReason, err.Error()), err
}
artifact := r.Storage.NewArtifactFor(repository.Kind, repository.GetObjectMeta(), revision, fmt.Sprintf("%s.tar.gz", commit.Hash()))
// copy all included repository into the artifact