Skip to content

Commit 22e712b

Browse files
aryan9600Paulo Gomes
authored andcommitted
gitrepo: match against api types when creating git client
Signed-off-by: Sanskar Jaiswal <[email protected]>
1 parent d25ed0c commit 22e712b

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

controllers/gitrepository_controller.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -768,10 +768,13 @@ func (r *GitRepositoryReconciler) gitCheckout(ctx context.Context,
768768
var gitReader git.RepositoryReader
769769
var err error
770770

771-
if obj.Spec.GitImplementation == libgit2.ClientName {
771+
switch obj.Spec.GitImplementation {
772+
case sourcev1.LibGit2Implementation:
772773
gitReader, err = libgit2.NewClient(dir, authOpts)
773-
} else {
774+
case sourcev1.GoGitImplementation, "":
774775
gitReader, err = gogit.NewClient(dir, authOpts)
776+
default:
777+
err = fmt.Errorf("invalid Git implementation: %s", obj.Spec.GitImplementation)
775778
}
776779
if err != nil {
777780
// Do not return err as recovery without changes is impossible.

0 commit comments

Comments
 (0)