download

package
v0.5.5 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2024 License: MPL-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Download

func Download(ctx context.Context, req *Request) error

Download takes and context and request and performs the download request and optionally verifies the downloaded file SHA 256 sum.

Types

type Command

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

Command is a cli.Command.

func NewCommand

func NewCommand(ui cli.Ui) (*Command, error)

NewCommand takes a user interface and returns a new cli.Command.

func (*Command) Download

func (c *Command) Download() error

Download downloads the file and writes it to the destination.

func (*Command) Help

func (c *Command) Help() string

Help is the cli.Command help.

func (*Command) Run

func (c *Command) Run(args []string) int

Run is the main cli.Command execution function.

func (*Command) Synopsis

func (c *Command) Synopsis() string

Synopsis is the cli.Command synopsis.

type CommandArgs

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

CommandArgs are the download commands arguments.

func (*CommandArgs) Parse

func (a *CommandArgs) Parse(args []string) error

Parse parses the raw args and maps them to the CommandArgs.

type ErrDownload

type ErrDownload struct {
	Err        error
	StatusCode int
}

ErrDownload is a download error.

func (*ErrDownload) Error

func (e *ErrDownload) Error() string

Error returns the error as a string.

func (*ErrDownload) Unwrap

func (e *ErrDownload) Unwrap() error

Unwrap returns the wrapped error.

type Request

type Request struct {
	URL          *url.URL
	HTTPMethod   string
	Destination  io.WriteCloser
	SHA256       string
	AuthUser     string
	AuthPassword string
	WriteStdout  bool
}

Request is a download request.

func NewRequest

func NewRequest(opts ...RequestOpt) (*Request, error)

NewRequest takes N RequestOpt args and returns a new request.

type RequestOpt

type RequestOpt func(*Request) (*Request, error)

RequestOpt are functional options for a new Request.

func WithRequestAuthPassword

func WithRequestAuthPassword(password string) RequestOpt

WithRequestAuthPassword sets the basic auth password.

func WithRequestAuthUser

func WithRequestAuthUser(user string) RequestOpt

WithRequestAuthUser sets the basic auth user.

func WithRequestDestination

func WithRequestDestination(dst io.WriteCloser) RequestOpt

WithRequestDestination sets the destination.

func WithRequestSHA256

func WithRequestSHA256(sha string) RequestOpt

WithRequestSHA256 sets the required SHA 256 sum.

func WithRequestURL

func WithRequestURL(u string) RequestOpt

WithRequestURL sets the source download URL.

func WithRequestWriteStdout

func WithRequestWriteStdout(enabled bool) RequestOpt

WithRequestWriteStdout sets whether or not we should write the body to STDOUT.

Jump to

Keyboard shortcuts

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