registry

package
v0.0.0-...-e560ebb Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2021 License: BSD-3-Clause Imports: 16 Imported by: 0

Documentation

Overview

Package registry implements very limited Container Registry v2 API client.

It is not universal and primarily targets Google Container Registry implementation. In particular it uses Google OAuth2 tokens for authentication.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnrecognizedRegistry is returned when the registry hostname is unknown to us.
	ErrUnrecognizedRegistry = errors.New("unrecognized registry")
	// ErrBadRegistryResponse is returned if the registry returns unexpected response.
	ErrBadRegistryResponse = errors.New("unrecognized or wrong response from the registry")
)

Functions

func IsManifestUnknown

func IsManifestUnknown(err error) bool

IsManifestUnknown return true if the given error is a MANIFEST_UNKNOWN error from the registry (perhaps wrapped).

func ValidateTag

func ValidateTag(t string) error

ValidateTag checks syntax of a docker tag.

A tag name must be valid ASCII and may contain lowercase and uppercase letters, digits, underscores, periods and dashes. A tag name may not start with a period or a dash and may contain a maximum of 128 characters.

Types

type Client

type Client struct {
	TokenSource oauth2.TokenSource // tokens to use for gcr.io auth
	// contains filtered or unexported fields
}

Client is very limited Container Registry v2 API client.

It can resolve <image>:<tag> into <image>@sha256@... and can tag already uploaded images.

func (*Client) GetImage

func (c *Client) GetImage(ctx context.Context, image string) (*Image, error)

GetImage takes an image reference as it appears in Dockerfile and returns an image manifest, including its sha256 digest.

The image reference has the same format as in Dockerfile.

func (*Client) TagImage

func (c *Client) TagImage(ctx context.Context, img *Image, tag string) error

TagImage sets a tag on the given already uploaded image.

Tagging an image is just pushing its manifest under a new name.

type Error

type Error struct {
	StatusCode int          `json:"-"`      // HTTP status code
	RawError   string       `json:"-"`      // set if failed to unmarshal the response body
	Errors     []InnerError `json:"errors"` // elementary errors
}

Error is returned by Registry API on errors.

See https://docs.docker.com/registry/spec/api/#errors.

func (*Error) Error

func (e *Error) Error() string

Error implements 'error' interface.

type Image

type Image struct {
	Registry    string // the hostname of a registry the image came from
	Repo        string // the name of the repo with the image
	Digest      string // the manifest digest as "sha256:<hex>" string
	MediaType   string // MIME type of the manifest stored there
	RawManifest []byte // the raw manifest body (format depends on the media type)
}

Image points to some concreter docker image manifest.

func (*Image) Reference

func (i *Image) Reference() string

Reference returns identifier of this image as it may appear in Dockerfile.

type InnerError

type InnerError struct {
	Code    string `json:"code"`
	Message string `json:"message"`
}

InnerError is an elementary suberror inside Error.

Jump to

Keyboard shortcuts

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