controllers: check GitRepository reference != nil

To prevent the reconciler from panicing when no reference is
configured for the GitRepository.
This commit is contained in:
Hidde Beydals 2020-04-29 16:45:25 +02:00
parent af77de193b
commit 2c0b175807
1 changed files with 1 additions and 1 deletions

View File

@ -321,7 +321,7 @@ func (r *GitRepositoryReconciler) sync(ctx context.Context, repository sourcev1.
if revision == "" {
revision = fmt.Sprintf("%s/%s", branch, ref.Hash().String())
if repository.Spec.Reference.Tag != "" {
if repository.Spec.Reference != nil && repository.Spec.Reference.Tag != "" {
revision = fmt.Sprintf("%s/%s", repository.Spec.Reference.Tag, ref.Hash().String())
}
}