Documentation ¶
Index ¶
- Variables
- type ArchiveFetcher
- type Option
- func WithFileMode(fileMode fs.FileMode) Option
- func WithFileName(filename string) Option
- func WithHostnameOverwrite(hostnameOverwrite string) Option
- func WithLogger(logger any) Option
- func WithMaxDownloadSize(maxDownloadSize int) Option
- func WithRetries(retries int) Option
- func WithUntar(opts ...tar.TarOption) Option
Constants ¶
This section is empty.
Variables ¶
var ErrFileNotFound = errors.New("file not found")
ErrFileNotFound is an error type used to signal 404 HTTP status code responses.
Functions ¶
This section is empty.
Types ¶
type ArchiveFetcher ¶
type ArchiveFetcher struct {
// contains filtered or unexported fields
}
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 ¶ added in v0.10.0
func New(opts ...Option) *ArchiveFetcher
New creates an *ArchiveFetcher accepting options.
func NewArchiveFetcher
deprecated
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
deprecated
added in
v0.8.0
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.
func (*ArchiveFetcher) Fetch ¶
func (r *ArchiveFetcher) Fetch(archiveURL, digest, dir string) error
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.
func (*ArchiveFetcher) FetchWithContext ¶ added in v0.10.0
func (r *ArchiveFetcher) FetchWithContext(ctx context.Context, archiveURL, digest, dir string) (err error)
FetchWithContext is the same as Fetch but accepts a context.
type Option ¶ added in v0.10.0
type Option func(a *ArchiveFetcher)
Option is an option for constructing the ArchiveFetcher.
func WithFileMode ¶ added in v0.10.0
WithFileMode sets the file mode for the downloaded archive. Applies only if untar is not enabled and the archive is not extracted.
func WithFileName ¶ added in v0.10.0
WithFileName sets the file name for the downloaded archive.
func WithHostnameOverwrite ¶ added in v0.10.0
WithHostnameOverwrite sets an override for the hostname in download URLs.
func WithLogger ¶ added in v0.10.0
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 ¶ added in v0.10.0
WithMaxDownloadSize specifies a limit for the size of the downloaded archive.
func WithRetries ¶ added in v0.10.0
WithRetries sets the maximum amount of retries the HTTP client will be allowed to make.