options

package
v0.0.0-...-6f76032 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2024 License: Apache-2.0 Imports: 9 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Archive

type Archive struct {
	ShouldExtract bool          `bson:"should_extract" json:"should_extract" yaml:"should_extract"`
	Format        ArchiveFormat `bson:"format" json:"format" yaml:"format"`
	TargetPath    string        `bson:"target_path" json:"target_path" yaml:"target_path"`
}

Archive encapsulates options related to management of archive files.

func (Archive) Validate

func (opts Archive) Validate() error

Validate checks the archive file options.

type ArchiveFormat

type ArchiveFormat string

ArchiveFormat represents an archive file type.

const (
	// ArchiveAuto is an ArchiveFormat that does not force any particular type of
	// archive format.
	ArchiveAuto ArchiveFormat = "auto"
	// ArchiveTarGz is an ArchiveFormat for gzipped tar archives.
	ArchiveTarGz ArchiveFormat = "targz"
	// ArchiveZip is an ArchiveFormat for Zip archives.
	ArchiveZip ArchiveFormat = "zip"
)

func (ArchiveFormat) Validate

func (f ArchiveFormat) Validate() error

Validate checks that the ArchiveFormat is a recognized format.

type Download

type Download struct {
	URL         string       `json:"url" bson:"url"`
	Path        string       `json:"path" bson:"path"`
	ArchiveOpts Archive      `json:"archive_opts" bson:"archive_opts"`
	HTTPClient  *http.Client `json:"-" bson:"-"`
}

Download represents the options to download a file to a given path and optionally extract its contents.

func (Download) Download

func (opts Download) Download(ctx context.Context) error

Download executes the download operation.

func (Download) Extract

func (opts Download) Extract() error

Extract extracts the download to the path specified, using the archive format specified.

func (Download) Validate

func (opts Download) Validate() error

Validate checks the download options.

Jump to

Keyboard shortcuts

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