module

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 30, 2018 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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 Dummy

func Dummy(fs afero.Fs, repoRoot string) error

Dummy Hacky thing makes vgo not to complain

func Fetch

func Fetch(ctx context.Context, s storage.Backend, fetcher Fetcher, mod, version string, mf *Filter) error

Fetch downloads the module@version using the fetcher and stores it in storage

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

func NewErrModuleAlreadyFetched(op errors.Op, mod, ver string) error

NewErrModuleAlreadyFetched returns an error indicating that a module has already been fetched

func NewErrModuleExcluded

func NewErrModuleExcluded(module string) error

NewErrModuleExcluded creates new ErrModuleExcluded

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

func NewGoGetFetcher

func NewGoGetFetcher(goBinaryName string, fs afero.Fs) Fetcher

NewGoGetFetcher creates fetcher which uses go get tool to fetch modules

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 concurrency 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) ShouldProcess

func (f *Filter) ShouldProcess(path string) bool

ShouldProcess evaluates path and determines if module should be communicated or not

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
)

type Ref

type Ref interface {
	// Clear frees the storage & resources that the module uses. Calls to Read after you call
	// this function may fail, regardless of whether this function returns nil or not
	Clear() error
	// Read reads the module into memory and returns it. Notice that the Zip field on the returned
	// storage.Version is an io.ReadCloser, so make sure to call Close on it after you're done
	// with it. ref.Clear won't do it for you!
	Read() (*storage.Version, error)
}

Ref points to a module somewhere

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL