Skip to content

Commit 5d9f0f9

Browse files
committed
Replace hard-wired GitImpl'n to that from spec
The "auth strategy", which depends on the GitImplementation, was hard-wired to the "gogit" constant, but it should come from the GitRepository spec. When the implementation is "libgit2" and the git URL entails SSH, the result would normally include a callback for checking the host key against known_hosts; but since it was hard-wired, it was missing that callback. This explains at least some instances of the error `user cancelled hostkey check` from #106. The error, or a close relative, might also arise if the callback rejects the host key because the host as it appears in the known_hosts doesn't match that host as passed to the callback -- see fluxcd/source-controller#287. Signed-off-by: Michael Bridgen <[email protected]>
1 parent c1e0def commit 5d9f0f9

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

controllers/imageupdateautomation_controller.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ import (
5353
"github.com/fluxcd/pkg/runtime/metrics"
5454
"github.com/fluxcd/pkg/runtime/predicates"
5555
sourcev1 "github.com/fluxcd/source-controller/api/v1beta1"
56-
"github.com/fluxcd/source-controller/pkg/git"
57-
gitcommon "github.com/fluxcd/source-controller/pkg/git/common"
56+
gitstrat "github.com/fluxcd/source-controller/pkg/git"
57+
git "github.com/fluxcd/source-controller/pkg/git/common"
5858

5959
imagev1 "github.com/fluxcd/image-automation-controller/api/v1alpha1"
6060
"github.com/fluxcd/image-automation-controller/pkg/update"
@@ -293,15 +293,15 @@ func (r *ImageUpdateAutomationReconciler) automationsForGitRepo(obj client.Objec
293293
// --- git ops
294294

295295
type repoAccess struct {
296-
auth *gitcommon.Auth
296+
auth *git.Auth
297297
url string
298298
}
299299

300300
func (r *ImageUpdateAutomationReconciler) getRepoAccess(ctx context.Context, repository *sourcev1.GitRepository) (repoAccess, error) {
301301
var access repoAccess
302-
access.auth = &gitcommon.Auth{}
302+
access.auth = &git.Auth{}
303303
access.url = repository.Spec.URL
304-
authStrat, err := git.AuthSecretStrategyForURL(access.url, sourcev1.GoGitImplementation)
304+
authStrat, err := gitstrat.AuthSecretStrategyForURL(access.url, repository.Spec.GitImplementation)
305305
if err != nil {
306306
return access, err
307307
}
@@ -333,7 +333,7 @@ func (r *ImageUpdateAutomationReconciler) getRepoAccess(ctx context.Context, rep
333333
// `*gogit.Repository` regardless of the git library, since that is
334334
// used for committing changes.
335335
func cloneInto(ctx context.Context, access repoAccess, branch, path, impl string) (*gogit.Repository, error) {
336-
checkoutStrat, err := git.CheckoutStrategyForRef(&sourcev1.GitRepositoryRef{
336+
checkoutStrat, err := gitstrat.CheckoutStrategyForRef(&sourcev1.GitRepositoryRef{
337337
Branch: branch,
338338
}, impl)
339339
if err == nil {

0 commit comments

Comments
 (0)