goproxy

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: May 17, 2020 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotDirectory returned by ReadDir if we try to read non-directory path
	ErrNotDirectory = fmt.Errorf("not a directory")

	// ErrNotFile returned by ReadFile if we try to read non-file path
	ErrNotFile = fmt.Errorf("not a file")
)

Functions

This section is empty.

Types

type Client

type Client struct {
	ClientParams
	// contains filtered or unexported fields
}

func NewClient

func NewClient(logger *zap.Logger, params ClientParams) *Client

func (*Client) Check added in v0.0.8

func (c *Client) Check(ctx context.Context) error

func (*Client) ResolveLicense

func (c *Client) ResolveLicense(ctx context.Context, m validation.Module) (validation.License, error)

ResolveLicense attempts to resolve license using project zip file. Content-Type must be application/zip otherwise InvalidContentTypeErr error returned. It uses http range requests to not fully download file when server supports it.

type ClientParams

type ClientParams struct {
	HTTPClient *http.Client

	// BaseURL is a proxy base url (i.e. https://proxy.golang.org)
	BaseURL string

	// StoreMemLimit is a limit for in-memory zip storage when server not supports http range requests
	// By default it's 1MiB
	StoreMemLimit int64

	// StoreFileLimit is a limit for file-based zip storage when server not supports http range requests
	// By default it's 1GiB
	StoreFileLimit int64

	// ConfidenceThreshold is a lower bound threshold of license matching confidence
	ConfidenceThreshold float64
}

type InvalidContentTypeErr

type InvalidContentTypeErr string

func (InvalidContentTypeErr) Error

func (e InvalidContentTypeErr) Error() string

type ZipFiler

type ZipFiler struct {
	*zip.Reader
	// Module archives contains project root inside path "<module name>@<module version>"
	// So for correct license recognition we should trim this prefix from all paths
	validation.Module
	// contains filtered or unexported fields
}

ZipFiler is an implementation of filesystem for src-d license scanner based on zip archive

func (*ZipFiler) Close

func (zf *ZipFiler) Close()

func (*ZipFiler) PathsAreAlwaysSlash

func (zf *ZipFiler) PathsAreAlwaysSlash() bool

func (*ZipFiler) ReadDir

func (zf *ZipFiler) ReadDir(path string) ([]filer.File, error)

func (*ZipFiler) ReadFile

func (zf *ZipFiler) ReadFile(path string) ([]byte, error)

Jump to

Keyboard shortcuts

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