download

package
v1.4.6 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2023 License: MPL-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package download provides a download with retries for machine configuration and userdata.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Download

func Download(ctx context.Context, endpoint string, opts ...Option) (b []byte, err error)

Download downloads a config.

func NewTFTPTransport

func NewTFTPTransport() http.RoundTripper

NewTFTPTransport returns an http.RoundTripper capable of handling the TFTP protocol.

Types

type Option

type Option func(*downloadOptions)

Option configures the download options.

func WithEndpointFunc

func WithEndpointFunc(endpointFunc func(context.Context) (string, error)) Option

WithEndpointFunc provides a function that sets the endpoint of the download options.

func WithErrorOnEmptyResponse

func WithErrorOnEmptyResponse(e error) Option

WithErrorOnEmptyResponse provides specific error to return when response is empty.

func WithErrorOnNotFound

func WithErrorOnNotFound(e error) Option

WithErrorOnNotFound provides specific error to return when response has HTTP 404 error.

func WithFormat

func WithFormat(format string) Option

WithFormat specifies the source format. This ultimately will be a yaml but may be represented in different formats. For example, the config may be base64 encoded.

func WithHeaders

func WithHeaders(headers map[string]string) Option

WithHeaders specifies any http headers that are needed for downloading the config.

func WithLowSrcPort

func WithLowSrcPort() Option

WithLowSrcPort sets low source port to download the config.

func WithRetryOptions added in v1.4.0

func WithRetryOptions(opts ...retry.Option) Option

WithRetryOptions sets the retry options for the download.

func WithTimeout added in v1.4.0

func WithTimeout(timeout time.Duration) Option

WithTimeout sets the timeout for the download.

Jump to

Keyboard shortcuts

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