download

package
v0.8.0-beta.12 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2023 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DownloadAndExtract

func DownloadAndExtract(extractDir, uri, sha256sum, overrideFile string) error

DownloadAndExtract downloads the specified archive uri (or uses the provided overrideFile, if a non-empty value) while validating its checksum with the provided sha256sum, and extracts its contents to extractDir that must be. created.

Types

type Downloader

type Downloader struct {
	// contains filtered or unexported fields
}

Downloader is responsible for fetching, verifying and extracting a binary.

func NewDownloader

func NewDownloader(v Verifier, f Fetcher) Downloader

NewDownloader builds a new Downloader.

func (Downloader) Get

func (d Downloader) Get(uri, dst string) error

Get pulls the uri and verifies it. On success, the download gets extracted into dst.

type Fetcher

type Fetcher interface {
	// Get gets the file and returns an stream to read the file.
	Get(uri string) (io.ReadCloser, error)
}

func NewFileFetcher

func NewFileFetcher(path string) Fetcher

NewFileFetcher returns a local file reader.

type HTTPFetcher

type HTTPFetcher struct{}

HTTPFetcher is used to get a file from a http:// or https:// schema path.

func (HTTPFetcher) Get

func (HTTPFetcher) Get(uri string) (io.ReadCloser, error)

Get gets the file and returns a stream to read the file.

type Verifier

type Verifier interface {
	io.Writer
	Verify() error
}

func NewSha256Verifier

func NewSha256Verifier(hashed string) Verifier

NewSha256Verifier creates a Verifier that tests against the given hash.

Jump to

Keyboard shortcuts

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