docker

package
v0.0.0-...-d850389 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDigest

func GetDigest(ctx context.Context, c Client, registry, repository, tag string) (string, error)

GetDigest retrieves the digest for the given image from the registry. It is a shortcut for Client.GetManifest and Manifest.Digest.

Note: This could instead be part of Client, and we could send a HEAD request to the manifests URL. This would be a little more efficient in that it would send less data over the network.

func SplitImage

func SplitImage(image string) (registry, repository, tagOrDigest string, err error)

SplitImage splits a full Docker image path into registry, repository, and tag or digest components. It is not an error for the tag or digest to be missing.

Types

type Client

type Client interface {
	// GetManifest retrieves the manifest for the given image. The reference may
	// be a tag or a digest.
	GetManifest(ctx context.Context, registry, repository, reference string) (*Manifest, error)
	// GetConfig retrieves an image config based on the config.digest from its
	// Manifest.
	GetConfig(ctx context.Context, registry, repository, configDigest string) (*ImageConfig, error)
	// ListRepositories lists all repositories in the given registry. Because there
	// may be many results, this can be quite slow.
	ListRepositories(ctx context.Context, registry string) ([]string, error)
	// ListInstances lists all image instances for the given repository, keyed by
	// their digests. Because there may be many results, this can be quite slow.
	ListInstances(ctx context.Context, registry, repository string) (map[string]*ImageInstance, error)
	// ListTags lists all known tags for the given repository. Because there may be
	// many results, this can be quite slow.
	ListTags(ctx context.Context, registry, repository string) ([]string, error)
	// SetTag sets the given tag on the image.
	SetTag(ctx context.Context, registry, repository, reference, newTag string) error
}

Client is used for interacting with a Docker registry.

type ClientImpl

type ClientImpl struct {
	// contains filtered or unexported fields
}

ClientImpl implements Client.

func NewClient

func NewClient(ctx context.Context) (*ClientImpl, error)

NewClient returns a Client instance which interacts with the given registry. The passed-in http.Client should handle redirects.

func (*ClientImpl) GetConfig

func (c *ClientImpl) GetConfig(ctx context.Context, registry, repository, configDigest string) (*ImageConfig, error)

GetConfig implements Client.

func (*ClientImpl) GetManifest

func (c *ClientImpl) GetManifest(ctx context.Context, registry, repository, reference string) (*Manifest, error)

GetManifest implements Client.

func (*ClientImpl) ListInstances

func (c *ClientImpl) ListInstances(ctx context.Context, registry, repository string) (map[string]*ImageInstance, error)

ListInstances implements Client.

func (*ClientImpl) ListRepositories

func (c *ClientImpl) ListRepositories(ctx context.Context, registry string) ([]string, error)

ListRepositories implements Client.

func (*ClientImpl) ListTags

func (c *ClientImpl) ListTags(ctx context.Context, registry, repository string) ([]string, error)

ListTags implements Client.

func (*ClientImpl) SetTag

func (c *ClientImpl) SetTag(ctx context.Context, registry, repository, reference, newTag string) error

SetTag implements Client.

type ImageConfig

type ImageConfig struct {
	Architecture  string                `json:"architecture"`
	Author        string                `json:"author"`
	Config        ImageConfig_Config    `json:"config"`
	Container     string                `json:"container"`
	Created       time.Time             `json:"created"`
	DockerVersion string                `json:"docker_version"`
	History       []ImageConfig_History `json:"history"`
	OS            string                `json:"os"`
	RootFS        ImageConfig_RootFS    `json:"rootfs"`
}

ImageConfig is the configuration blob for a Docker image instance.

func GetConfig

func GetConfig(ctx context.Context, c *ClientImpl, registry, repository, reference string) (*ImageConfig, error)

GetConfig retrieves an image config. It is a shortcut for Client.GetManifest and Client.GetConfig.

type ImageConfig_Config

type ImageConfig_Config struct {
	AttachStderr bool     `json:"AttachStderr"`
	AttachStdout bool     `json:"AttachStdout"`
	Cmd          []string `json:"Cmd"`
	Entrypoint   []string `json:"Entrypoint"`
	Env          []string `json:"Env"`
	Hostname     string   `json:"Hostname"`
	Image        string   `json:"Image"`
	User         string   `json:"User"`
}

type ImageConfig_History

type ImageConfig_History struct {
	Author     string    `json:"author"`
	Created    time.Time `json:"created"`
	CreatedBy  string    `json:"created_by"`
	EmptyLayer bool      `json:"empty_layer"`
}

type ImageConfig_RootFS

type ImageConfig_RootFS struct {
	DiffIDs []string `json:"diff_ids"`
	Type    string   `json:"type"`
}

type ImageInstance

type ImageInstance struct {
	Digest    string    `json:"digest"`
	SizeBytes int64     `json:"imageSizeBytes"`
	Tags      []string  `json:"tag"`
	Created   time.Time `json:"timeCreatedMs"`
	Uploaded  time.Time `json:"timeUploadedMs"`
}

ImageInstance describes one instance of an image.

type ImageInstanceSlice

type ImageInstanceSlice []*ImageInstance

ImageInstanceSlice implements sort.Interface.

func (ImageInstanceSlice) Len

func (s ImageInstanceSlice) Len() int

Len implements sort.Interface.

func (ImageInstanceSlice) Less

func (s ImageInstanceSlice) Less(i, j int) bool

Less implements sort.Interface.

func (ImageInstanceSlice) Swap

func (s ImageInstanceSlice) Swap(i, j int)

Swap implements sort.Interface.

type Manifest

type Manifest struct {
	SchemaVersion int           `json:"schemaVersion"`
	MediaType     string        `json:"mediaType"`
	Digest        string        `json:"-"`
	Config        MediaConfig   `json:"config"`
	Layers        []MediaConfig `json:"layers"`
}

Manifest represents a Docker image manifest.

type MediaConfig

type MediaConfig struct {
	MediaType string `json:"mediaType"`
	Size      int    `json:"size"`
	Digest    string `json:"digest"`
}

Directories

Path Synopsis
build

Jump to

Keyboard shortcuts

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