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 https://github.com/fluxcd/source-controller/issues/287. Signed-off-by: Michael Bridgen <michael@weave.works>
This commit is contained in:
parent
c1e0def8db
commit
5d9f0f9958
|
@ -53,8 +53,8 @@ import (
|
|||
"github.com/fluxcd/pkg/runtime/metrics"
|
||||
"github.com/fluxcd/pkg/runtime/predicates"
|
||||
sourcev1 "github.com/fluxcd/source-controller/api/v1beta1"
|
||||
"github.com/fluxcd/source-controller/pkg/git"
|
||||
gitcommon "github.com/fluxcd/source-controller/pkg/git/common"
|
||||
gitstrat "github.com/fluxcd/source-controller/pkg/git"
|
||||
git "github.com/fluxcd/source-controller/pkg/git/common"
|
||||
|
||||
imagev1 "github.com/fluxcd/image-automation-controller/api/v1alpha1"
|
||||
"github.com/fluxcd/image-automation-controller/pkg/update"
|
||||
|
@ -293,15 +293,15 @@ func (r *ImageUpdateAutomationReconciler) automationsForGitRepo(obj client.Objec
|
|||
// --- git ops
|
||||
|
||||
type repoAccess struct {
|
||||
auth *gitcommon.Auth
|
||||
auth *git.Auth
|
||||
url string
|
||||
}
|
||||
|
||||
func (r *ImageUpdateAutomationReconciler) getRepoAccess(ctx context.Context, repository *sourcev1.GitRepository) (repoAccess, error) {
|
||||
var access repoAccess
|
||||
access.auth = &gitcommon.Auth{}
|
||||
access.auth = &git.Auth{}
|
||||
access.url = repository.Spec.URL
|
||||
authStrat, err := git.AuthSecretStrategyForURL(access.url, sourcev1.GoGitImplementation)
|
||||
authStrat, err := gitstrat.AuthSecretStrategyForURL(access.url, repository.Spec.GitImplementation)
|
||||
if err != nil {
|
||||
return access, err
|
||||
}
|
||||
|
@ -333,7 +333,7 @@ func (r *ImageUpdateAutomationReconciler) getRepoAccess(ctx context.Context, rep
|
|||
// `*gogit.Repository` regardless of the git library, since that is
|
||||
// used for committing changes.
|
||||
func cloneInto(ctx context.Context, access repoAccess, branch, path, impl string) (*gogit.Repository, error) {
|
||||
checkoutStrat, err := git.CheckoutStrategyForRef(&sourcev1.GitRepositoryRef{
|
||||
checkoutStrat, err := gitstrat.CheckoutStrategyForRef(&sourcev1.GitRepositoryRef{
|
||||
Branch: branch,
|
||||
}, impl)
|
||||
if err == nil {
|
||||
|
|
Loading…
Reference in New Issue