Skip to content

Commit

Permalink
fix var name with sshkey auth
Browse files Browse the repository at this point in the history
Signed-off-by: Tony Worm <tony@hofstadter.io>
  • Loading branch information
verdverm committed Sep 13, 2021
1 parent 75dff8e commit ae5e877
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
1 change: 1 addition & 0 deletions lib/mod/cache/fetch.go
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions 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=""
Expand All @@ -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

Expand All @@ -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 --
1 change: 1 addition & 0 deletions lib/yagu/repos/bbc/fetch.go
Expand Up @@ -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)
}

Expand Down
1 change: 1 addition & 0 deletions lib/yagu/repos/github/fetch.go
Expand Up @@ -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)
}

Expand Down
7 changes: 7 additions & 0 deletions lib/yagu/repos/gitlab/fetch.go
Expand Up @@ -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
Expand Down

0 comments on commit ae5e877

Please sign in to comment.