fetch package - github.com/fluxcd/pkg/http/fetch - Go Packages

This section is empty.

ErrFileNotFound is an error type used to signal 404 HTTP status code responses.

This section is empty.

type ArchiveFetcher struct {
	
}

ArchiveFetcher is a flexible API for downloading an archive from an HTTP server, verifying its digest and extracting its contents to a given path in the Filesystem.

func New(opts ...Option) *ArchiveFetcher

New creates an *ArchiveFetcher accepting options.

func NewArchiveFetcher(retries, maxDownloadSize, maxUntarSize int, hostnameOverwrite string) *ArchiveFetcher

NewArchiveFetcher configures the retryable HTTP client used for fetching archives.

Deprecated: Use New() instead.

func NewArchiveFetcherWithLogger(retries, maxDownloadSize, maxUntarSize int, hostnameOverwrite string, logger any) *ArchiveFetcher

NewArchiveFetcherWithLogger configures the retryable HTTP client used for fetching archives and sets the logger to use.

The logger can be any type that implements the retryablehttp.Logger or retryablehttp.LeveledLogger interface. If the logger is of type logr.Logger, it will be wrapped in a retryablehttp.LeveledLogger that only logs errors.

Deprecated: Use New() instead.

Fetch downloads, verifies and extracts the tarball content to the specified directory. If the file server responds with 5xx errors, the download operation is retried. If the file server responds with 404, the returned error is of type ErrFileNotFound. If the file server is unavailable for more than 3 minutes, the returned error contains the original status code.

FetchWithContext is the same as Fetch but accepts a context.

type Option func(a *ArchiveFetcher)

Option is an option for constructing the ArchiveFetcher.

WithFileMode sets the file mode for the downloaded archive. Applies only if untar is not enabled and the archive is not extracted.

func WithFileName(filename string) Option

WithFileName sets the file name for the downloaded archive.

func WithHostnameOverwrite(hostnameOverwrite string) Option

WithHostnameOverwrite sets an override for the hostname in download URLs.

func WithLogger(logger any) Option

WithLogger sets a logger for the HTTP client. The logger can be any type that implements the retryablehttp.Logger or retryablehttp.LeveledLogger interface. If the logger is of type logr.Logger, it will be wrapped in a retryablehttp.LeveledLogger that only logs errors.

func WithMaxDownloadSize(maxDownloadSize int) Option

WithMaxDownloadSize specifies a limit for the size of the downloaded archive.

func WithRetries(retries int) Option

WithRetries sets the maximum amount of retries the HTTP client will be allowed to make.

WithUntar tells the ArchiveFetcher to untar the archive expecting it to be a tarball.