support goproxy for list/download command (#1304)

This commit is contained in:
Yi Tang
2019-07-16 02:07:24 +08:00
committed by Marwan Sulaiman
parent 8e8e886f84
commit 7de77889ad
9 changed files with 36 additions and 17 deletions
+3 -2
View File
@@ -35,8 +35,9 @@ func getDP(t *testing.T) Protocol {
t.Fatalf("Unable to parse config file: %s", err.Error())
}
goBin := conf.GoBinary
goProxy := conf.GoProxy
fs := afero.NewOsFs()
mf, err := module.NewGoGetFetcher(goBin, fs)
mf, err := module.NewGoGetFetcher(goBin, goProxy, fs)
if err != nil {
t.Fatal(err)
}
@@ -45,7 +46,7 @@ func getDP(t *testing.T) Protocol {
t.Fatal(err)
}
st := stash.New(mf, s)
return New(&Opts{s, st, NewVCSLister(goBin, fs), nil})
return New(&Opts{s, st, NewVCSLister(goBin, goProxy, fs), nil})
}
type listTest struct {
+4 -3
View File
@@ -31,6 +31,7 @@ type listResp struct {
type vcsLister struct {
goBinPath string
goProxy string
fs afero.Fs
}
@@ -61,7 +62,7 @@ func (l *vcsLister) List(ctx context.Context, mod string) (*storage.RevInfo, []s
return nil, nil, errors.E(op, err)
}
defer module.ClearFiles(l.fs, gopath)
cmd.Env = module.PrepareEnv(gopath)
cmd.Env = module.PrepareEnv(gopath, l.goProxy)
err = cmd.Run()
if err != nil {
@@ -89,6 +90,6 @@ func (l *vcsLister) List(ctx context.Context, mod string) (*storage.RevInfo, []s
}
// NewVCSLister creates an UpstreamLister which uses VCS to fetch a list of available versions
func NewVCSLister(goBinPath string, fs afero.Fs) UpstreamLister {
return &vcsLister{goBinPath: goBinPath, fs: fs}
func NewVCSLister(goBinPath, goProxy string, fs afero.Fs) UpstreamLister {
return &vcsLister{goBinPath: goBinPath, goProxy: goProxy, fs: fs}
}