Documentation ¶
Index ¶
- Constants
- type AccessDenied
- type AuthTokenError
- type DoNotRetry
- type Fetcher
- type ImageNotFoundError
- type Options
- type RegistryErrorRespBody
- type TagNotFoundError
- type Token
- type URLFetcher
- func (u *URLFetcher) AuthURL() *url.URL
- func (u *URLFetcher) ExtractOAuthURL(hdr string, repository *url.URL) (*url.URL, error)
- func (u *URLFetcher) Fetch(ctx context.Context, url *url.URL, reqHdrs *http.Header, toFile bool, ...) (string, error)
- func (u *URLFetcher) FetchAuthToken(ctx context.Context, url *url.URL) (*Token, error)
- func (u *URLFetcher) Head(ctx context.Context, url *url.URL) (http.Header, error)
- func (u *URLFetcher) IsNonretryableClientError() bool
- func (u *URLFetcher) IsStatusNotFound() bool
- func (u *URLFetcher) IsStatusOK() bool
- func (u *URLFetcher) IsStatusUnauthorized() bool
- func (u *URLFetcher) Ping(ctx context.Context, url *url.URL) (http.Header, error)
Constants ¶
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 ¶
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) IsStatusOK() bool IsStatusNotFound() bool AuthURL() *url.URL }
Fetcher interface
func NewURLFetcher ¶
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 ¶
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 oauth 2.0 token format AccessToken string `json:"access_token"` // 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 ¶
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 (*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