Documentation
¶
Index ¶
- func ClearFiles(fs afero.Fs, root string) error
- func Download(ctx context.Context, timeout time.Duration, baseURL, module, version string) (*storage.Version, error)
- func Dummy(fs afero.Fs, repoRoot string) error
- func MakeZip(fs afero.Fs, dir, module, version string) *io.PipeReader
- func NewErrModuleAlreadyFetched(op errors.Op, mod, ver string) error
- func NewErrModuleExcluded(module string) error
- func PrepareEnv(gopath string) []string
- type Downloader
- type ErrModuleExcluded
- type Fetcher
- type Filter
- type FilterRule
- type Ref
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClearFiles ¶ added in v0.1.0
ClearFiles deletes all data from the given fs at path root This function must be called when zip is closed to cleanup the entire GOPATH created by the diskref
func Download ¶
func Download(ctx context.Context, timeout time.Duration, baseURL, module, version string) (*storage.Version, error)
Download downloads the module/version from url. Returns a storage.Version representing the downloaded module/version or a non-nil error if something went wrong
func MakeZip ¶
func MakeZip(fs afero.Fs, dir, module, version string) *io.PipeReader
MakeZip takes dir and module info and generates vgo valid zip the dir must end with a "/"
func NewErrModuleAlreadyFetched ¶
NewErrModuleAlreadyFetched returns an error indicating that a module has already been fetched
func NewErrModuleExcluded ¶
NewErrModuleExcluded creates new ErrModuleExcluded
func PrepareEnv ¶ added in v0.1.0
PrepareEnv will return all the appropriate environment variables for a Go Command to run successfully (such as GOPATH, GOCACHE, PATH etc)
Types ¶
type Downloader ¶
type Downloader func(ctx context.Context, timeout time.Duration, baseURL, module, version string) (*storage.Version, error)
Downloader downloads a module version from a URL exposing Download Protocol endpoints
type ErrModuleExcluded ¶
type ErrModuleExcluded struct {
// contains filtered or unexported fields
}
ErrModuleExcluded is error returned when processing of error is skipped due to filtering rules
func (*ErrModuleExcluded) Error ¶
func (e *ErrModuleExcluded) Error() string
type Fetcher ¶
type Fetcher interface {
// Fetch fetches the module and puts it somewhere addressable by ModuleRef.
// returns a non-nil error on failure.
//
// The caller should call moduleRef.Clear() after they're done with the module
Fetch(mod, ver string) (Ref, error)
}
Fetcher fetches module from an upstream source
Example ¶
repoURI := "github.com/arschles/assert"
version := "v1.0.0"
goBinaryName := env.GoBinPath()
fetcher, err := NewGoGetFetcher(goBinaryName, afero.NewOsFs())
if err != nil {
log.Fatal(err)
}
ref, err := fetcher.Fetch(repoURI, version)
// handle errors if any
if err != nil {
return
}
versionData, err := ref.Read()
// Close the handle to versionData.Zip once done
// This will also handle cleanup so it's important to call Close
defer versionData.Zip.Close()
if err != nil {
return
}
// Do something with versionData
fmt.Println(string(versionData.Mod))
Output: module github.com/arschles/assert
type Filter ¶
type Filter struct {
// contains filtered or unexported fields
}
Filter is a filter of modules
func NewFilter ¶
func NewFilter() *Filter
NewFilter creates new filter based on rules defined in a configuration file WARNING: this is not concurrently safe Configuration consists of two operations: + for include and - for exclude e.g.
- github.com/a
- github.com/a/b
will communicate all modules except github.com/a and its children, but github.com/a/b will be communicated example 2:
- + github.com/a
will exclude all items from communication except github.com/a
func (*Filter) AddRule ¶
func (f *Filter) AddRule(path string, rule FilterRule)
AddRule adds rule for specified path
func (*Filter) Rule ¶ added in v0.1.0
func (f *Filter) Rule(path string) FilterRule
Rule returns the filter rule to be applied to the given path
type FilterRule ¶
type FilterRule int
FilterRule defines behavior of module communication
const ( // Default filter rule does not alter default behavior Default FilterRule = iota // Include filter rule includes package and its children from communication Include // Exclude filter rule excludes package and its children from communication Exclude // Direct filter rule forces the package to be fetched directly from the vcs Direct )