fetcher

package
v1.5.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2019 License: Apache-2.0 Imports: 20 Imported by: 21

Documentation

Index

Constants

View Source
const (

	// DefaultTokenExpirationDuration specifies the default token expiration
	DefaultTokenExpirationDuration = 60 * time.Second
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessDenied added in v1.4.3

type AccessDenied struct {
	Err error
	// contains filtered or unexported fields
}

AccessDenied is returned when the resource requested

func (AccessDenied) Error added in v1.4.3

func (e AccessDenied) Error() string

type AuthTokenError

type AuthTokenError struct {
	TokenServer url.URL
	Err         error
}

AuthTokenError is returned when authentication with a registry fails

func (AuthTokenError) Error

func (e AuthTokenError) Error() string

type DoNotRetry

type DoNotRetry struct {
	Err error
}

DoNotRetry is an error wrapper indicating that the error cannot be resolved with a retry.

func (DoNotRetry) Error

func (e DoNotRetry) Error() string

Error returns the stringified representation of the encapsulated error.

type Fetcher

type Fetcher interface {
	Fetch(ctx context.Context, url *url.URL, reqHdrs *http.Header, toFile bool, po progress.Output, id ...string) (string, error)
	FetchAuthToken(ctx context.Context, url *url.URL) (*Token, error)

	Ping(ctx context.Context, url *url.URL) (http.Header, error)
	Head(ctx context.Context, url *url.URL) (http.Header, error)

	ExtractOAuthURL(hdr string, repository *url.URL) (*url.URL, error)

	IsStatusUnauthorized() bool
	IsStatusOK() bool
	IsStatusNotFound() bool

	AuthURL() *url.URL
}

Fetcher interface

func NewURLFetcher

func NewURLFetcher(options Options) Fetcher

NewURLFetcher creates a new URLFetcher

type ImageNotFoundError

type ImageNotFoundError struct {
	Err error
}

ImageNotFoundError is returned when an image is not found.

func (ImageNotFoundError) Error

func (e ImageNotFoundError) Error() string

type Options

type Options struct {
	Timeout time.Duration

	Username string
	Password string

	InsecureSkipVerify bool

	Token *Token

	// RootCAs will not be modified by fetcher.
	RootCAs *x509.CertPool
}

Options struct

type RegistryErrorRespBody

type RegistryErrorRespBody struct {
	Errors []struct {
		Code    string
		Message string
	}
}

RegistryErrorRespBody is used for unmarshaling json error response body from image registries. Error response json is assumed to follow Docker API convention (field `details` is dropped). See: https://docs.docker.com/registry/spec/api/#errors

type TagNotFoundError

type TagNotFoundError struct {
	Err error
}

TagNotFoundError is returned when an image's tag doesn't exist.

func (TagNotFoundError) Error

func (e TagNotFoundError) Error() string

type Token

type Token struct {
	// An opaque Bearer token that clients should supply to subsequent requests in the Authorization header.
	Token string `json:"token"`
	// (Optional) The duration in seconds since the token was issued that it will remain valid. When omitted, this defaults to 60 seconds.
	Expires   time.Time
	ExpiresIn int       `json:"expires_in"`
	IssueAt   time.Time `json:"issued_at"`
}

Token represents https://docs.docker.com/registry/spec/auth/token/

type URLFetcher

type URLFetcher struct {
	OAuthEndpoint *url.URL

	StatusCode int
	// contains filtered or unexported fields
}

URLFetcher struct

func (*URLFetcher) AuthURL

func (u *URLFetcher) AuthURL() *url.URL

AuthURL returns the Oauth endpoint URL

func (*URLFetcher) ExtractOAuthURL

func (u *URLFetcher) ExtractOAuthURL(hdr string, repository *url.URL) (*url.URL, error)

ExtractOAuthURL extracts the OAuth url from the www-authenticate header

func (*URLFetcher) Fetch

func (u *URLFetcher) Fetch(ctx context.Context, url *url.URL, reqHdrs *http.Header, toFile bool, po progress.Output, ids ...string) (string, error)

Fetch fetches from a url and stores its content in a temporary file.

hdrs is optional.

func (*URLFetcher) FetchAuthToken

func (u *URLFetcher) FetchAuthToken(ctx context.Context, url *url.URL) (*Token, error)

func (*URLFetcher) Head

func (u *URLFetcher) Head(ctx context.Context, url *url.URL) (http.Header, error)

Head sends a HEAD request to url

func (*URLFetcher) IsNonretryableClientError

func (u *URLFetcher) IsNonretryableClientError() bool

IsNonretryableClientError returns true if status code is a nonretryable 4XX error. This includes all 4XX errors except 'locked', and 'too many requests'.

func (*URLFetcher) IsStatusNotFound

func (u *URLFetcher) IsStatusNotFound() bool

IsStatusNotFound returns true if status code is StatusNotFound

func (*URLFetcher) IsStatusOK

func (u *URLFetcher) IsStatusOK() bool

IsStatusOK returns true if status code is StatusOK

func (*URLFetcher) IsStatusUnauthorized

func (u *URLFetcher) IsStatusUnauthorized() bool

IsStatusUnauthorized returns true if status code is StatusUnauthorized

func (*URLFetcher) Ping

func (u *URLFetcher) Ping(ctx context.Context, url *url.URL) (http.Header, error)

Ping sends a GET request to an url and returns the header if successful

Jump to

Keyboard shortcuts

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