Documentation ¶
Index ¶
- Variables
- type FetchOptions
- type Fetcher
- func (f *Fetcher) Fetch(u url.URL, dest *os.File, opts FetchOptions) error
- func (f *Fetcher) FetchFromDataURL(u url.URL, dest *os.File, opts FetchOptions) error
- func (f *Fetcher) FetchFromHTTP(u url.URL, dest *os.File, opts FetchOptions) error
- func (f *Fetcher) FetchFromOEM(u url.URL, dest *os.File, opts FetchOptions) error
- func (f *Fetcher) FetchFromS3(u url.URL, dest *os.File, opts FetchOptions) error
- func (f *Fetcher) FetchFromTFTP(u url.URL, dest *os.File, opts FetchOptions) error
- func (f *Fetcher) FetchToBuffer(u url.URL, opts FetchOptions) ([]byte, error)
- func (f *Fetcher) RewriteCAsWithDataUrls(cas []types.CaReference) error
- func (f *Fetcher) UpdateHttpTimeoutsAndCAs(timeouts types.Timeouts, cas []types.CaReference) error
- type HttpClient
Constants ¶
This section is empty.
Variables ¶
var ( ErrTimeout = errors.New("unable to fetch resource in time") ErrPEMDecodeFailed = errors.New("unable to decode PEM block") )
var ( ErrSchemeUnsupported = errors.New("unsupported source scheme") ErrPathNotAbsolute = errors.New("path is not absolute") ErrNotFound = errors.New("resource not found") ErrFailed = errors.New("failed to fetch resource") ErrCompressionUnsupported = errors.New("compression is not supported with that scheme") // ConfigHeaders are the HTTP headers that should be used when the Ignition // config is being fetched ConfigHeaders = http.Header{ "Accept-Encoding": []string{"identity"}, "Accept": []string{"application/vnd.coreos.ignition+json; version=2.2.0, application/vnd.coreos.ignition+json; version=1; q=0.5, */*; q=0.1"}, } )
Functions ¶
This section is empty.
Types ¶
type FetchOptions ¶ added in v0.17.0
type FetchOptions struct { // Headers are the http headers that will be used when fetching http(s) // resources. They have no effect on other fetching schemes. Headers http.Header // Hash is the hash to use when calculating a fetched resource's hash. If // left as nil, no hash will be calculated. Hash hash.Hash // The expected sum to be produced by the given hasher. If the Hash field is // nil, this field is ignored. ExpectedSum []byte // Compression specifies the type of compression to use when decompressing // the fetched object. If left empty, no decompression will be used. Compression string }
type Fetcher ¶ added in v0.17.0
type Fetcher struct { // The logger object to use when logging information. Logger *log.Logger // The AWS Session to use when fetching resources from S3. If left nil, the // first S3 object that is fetched will initialize the field. This can be // used to set credentials. AWSSession *session.Session // The region where the EC2 machine trying to fetch is. // This is used as a hint to fetch the S3 bucket from the right partition and region. S3RegionHint string // contains filtered or unexported fields }
Fetcher holds settings for fetching resources from URLs
func (*Fetcher) Fetch ¶ added in v0.17.0
Fetch calls the appropriate FetchFrom* function based on the scheme of the given URL. The results will be decompressed if compression is set in opts, and written into dest. If opts.Hash is set the data stream will also be hashed and compared against opts.ExpectedSum, and any match failures will result in an error being returned.
func (*Fetcher) FetchFromDataURL ¶ added in v0.17.0
FetchFromDataURL writes the data stored in the dataurl u into dest, returning an error if one is encountered.
func (*Fetcher) FetchFromHTTP ¶ added in v0.17.0
FetchFromHTTP fetches a resource from u via HTTP(S) into dest, returning an error if one is encountered.
func (*Fetcher) FetchFromOEM ¶ added in v0.17.0
FetchFromOEM gets data off the oem partition as described by u and writes it into dest, returning an error if one is encountered.
func (*Fetcher) FetchFromS3 ¶ added in v0.17.0
FetchFromS3 gets data from an S3 bucket as described by u and writes it into dest, returning an error if one is encountered. It will attempt to acquire IAM credentials from the EC2 metadata service, and if this fails will attempt to fetch the object with anonymous credentials.
func (*Fetcher) FetchFromTFTP ¶ added in v0.17.0
FetchFromTFTP fetches a resource from u via TFTP into dest, returning an error if one is encountered.
func (*Fetcher) FetchToBuffer ¶ added in v0.17.0
FetchToBuffer will fetch the given url into a temporrary file, and then read in the contents of the file and delete it. It will return the downloaded contents, or an error if one was encountered.
func (*Fetcher) RewriteCAsWithDataUrls ¶ added in v0.21.0
func (f *Fetcher) RewriteCAsWithDataUrls(cas []types.CaReference) error
RewriteCAsWithDataUrls will modify the passed in slice of CA references to contain the actual CA file via a dataurl in their source field.
func (*Fetcher) UpdateHttpTimeoutsAndCAs ¶ added in v0.21.0
type HttpClient ¶
type HttpClient struct {
// contains filtered or unexported fields
}
HttpClient is a simple wrapper around the Go HTTP client that standardizes the process and logging of fetching payloads.