From ae5e8772ce0e7202b8a64d1c0d5545cb92646755 Mon Sep 17 00:00:00 2001 From: Tony Worm Date: Mon, 13 Sep 2021 18:35:25 -0400 Subject: [PATCH] fix var name with sshkey auth Signed-off-by: Tony Worm --- lib/mod/cache/fetch.go | 1 + lib/mod/testdata/authd/sshkey/vendor__priv_all.txt | 8 ++++---- lib/yagu/repos/bbc/fetch.go | 1 + lib/yagu/repos/github/fetch.go | 1 + lib/yagu/repos/gitlab/fetch.go | 7 +++++++ 5 files changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/mod/cache/fetch.go b/lib/mod/cache/fetch.go index cf9110a3c..ae1fa0eaf 100644 --- a/lib/mod/cache/fetch.go +++ b/lib/mod/cache/fetch.go @@ -37,6 +37,7 @@ func Fetch(lang, mod, ver, pev string) (err error) { } func fetch(lang, mod, ver string, private bool) error { + fmt.Println("fetch: ", lang, mod, ver, private) FS := memfs.New() remote, owner, repo := parseModURL(mod) diff --git a/lib/mod/testdata/authd/sshkey/vendor__priv_all.txt b/lib/mod/testdata/authd/sshkey/vendor__priv_all.txt index 8e3d29d2d..c05942df5 100644 --- a/lib/mod/testdata/authd/sshkey/vendor__priv_all.txt +++ b/lib/mod/testdata/authd/sshkey/vendor__priv_all.txt @@ -1,6 +1,6 @@ # hof mod vendor - with deps -env CUEPRIVATE="github.com,gitlab.com,bitbucket.org" +env CUEPRIVATE=github.com,gitlab.com,bitbucket.org ## blankout token vars for this test env GITHUB_TOKEN="" @@ -10,13 +10,13 @@ env BITBUCKET_PASSWORD="" ## setup default sshkey auth mkdir $HOME/.ssh -exec bash -c 'echo $HOFGIT_SSHKEY > $HOME/.ssh/id_rsa' +exec bash -c 'echo $HOFMOD_SSHKEY > $HOME/.ssh/id_rsa' ## run cmd exec hof mod vendor -- cue.mods -- -module github.com/test/priv-github +module github.com/test/priv-all cue v0.4.0 @@ -26,6 +26,6 @@ require ( gitlab.com/_hofstadter/hofmod-test-priv-gitlab v0.0.1 ) -- cue.mod/module.cue -- -module: "github.com/test/priv-github" +module: "github.com/test/priv-all" -- dummy_end -- diff --git a/lib/yagu/repos/bbc/fetch.go b/lib/yagu/repos/bbc/fetch.go index b62e489ec..ba184f9c6 100644 --- a/lib/yagu/repos/bbc/fetch.go +++ b/lib/yagu/repos/bbc/fetch.go @@ -20,6 +20,7 @@ func Fetch(FS billy.Filesystem, owner, repo, tag string, private bool) (error) { // If private, and no token auth, try git protocol // need to catch auth errors and suggest how to setup if private && os.Getenv(TokenEnv) == "" { + fmt.Println("bitbucket git fallback") return git.Fetch(FS, "bitbucket.org", owner, repo, tag, private) } diff --git a/lib/yagu/repos/github/fetch.go b/lib/yagu/repos/github/fetch.go index 47ff413d4..1598158f2 100644 --- a/lib/yagu/repos/github/fetch.go +++ b/lib/yagu/repos/github/fetch.go @@ -20,6 +20,7 @@ func Fetch(FS billy.Filesystem, owner, repo, tag string, private bool) (error) { // If private, and no token auth, try git protocol // need to catch auth errors and suggest how to setup if private && os.Getenv(TokenEnv) == "" { + fmt.Println("github git fallback") return git.Fetch(FS, "github.com", owner, repo, tag, private) } diff --git a/lib/yagu/repos/gitlab/fetch.go b/lib/yagu/repos/gitlab/fetch.go index 7a0da9bfb..78b8add41 100644 --- a/lib/yagu/repos/gitlab/fetch.go +++ b/lib/yagu/repos/gitlab/fetch.go @@ -4,15 +4,22 @@ import ( "archive/zip" "bytes" "fmt" + "os" "path" "github.com/go-git/go-billy/v5" "github.com/xanzy/go-gitlab" "github.com/hofstadter-io/hof/lib/yagu" + "github.com/hofstadter-io/hof/lib/yagu/repos/git" ) func Fetch(FS billy.Filesystem, owner, repo, tag string, private bool) (error) { + if private && os.Getenv(TokenEnv) == "" { + fmt.Println("gitlab git fallback") + return git.Fetch(FS, "gitlab.com", owner, repo, tag, private) + } + client, err := NewClient(private) if err != nil { return err