mirror of
https://github.com/gomods/athens
synced 2026-02-03 12:10:32 +00:00
support goproxy for list/download command (#1304)
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user