daemon

package
v0.1.3-0...-0b0730e Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

README

daemon

GoDoc

The daemon package enables reading/writing images from/to the docker daemon.

It is not fully fleshed out, but is useful for interoperability, see various issues:

Documentation

Overview

Package daemon provides facilities for reading/writing v1.Image from/to a running daemon.

Index

Constants

This section is empty.

Variables

View Source
var GetImageLoader = func() (ImageLoader, error) {
	cli, err := client.NewClientWithOpts(client.FromEnv)
	if err != nil {
		return nil, err
	}
	cli.NegotiateAPIVersion(context.Background())
	return cli, nil
}

GetImageLoader is a variable so we can override in tests.

Functions

func Image

func Image(ref name.Reference, options ...ImageOption) (v1.Image, error)

Image provides access to an image reference from the Docker daemon, applying functional options to the underlying imageOpener before resolving the reference into a v1.Image.

func Tag

func Tag(src, dest name.Tag) error

Tag adds a tag to an already existent image.

func Write

func Write(tag name.Tag, img v1.Image) (string, error)

Write saves the image into the daemon as the given tag.

Types

type Client

type Client interface {
	NegotiateAPIVersion(ctx context.Context)
	ImageSave(context.Context, []string) (io.ReadCloser, error)
	ImageLoad(context.Context, io.Reader, bool) (types.ImageLoadResponse, error)
	ImageTag(context.Context, string, string) error
}

Client represents the subset of a docker client that the daemon package uses.

type ImageLoader

type ImageLoader interface {
	ImageLoad(context.Context, io.Reader, bool) (types.ImageLoadResponse, error)
	ImageTag(context.Context, string, string) error
}

ImageLoader is an interface for testing.

type ImageOption

type ImageOption func(*imageOpener) error

ImageOption is a functional option for Image.

func WithBufferedOpener

func WithBufferedOpener() ImageOption

WithBufferedOpener buffers the image.

func WithClient

func WithClient(client Client) ImageOption

WithClient is a functional option to allow injecting a docker client.

By default, github.com/docker/docker/client.FromEnv is used.

func WithUnbufferedOpener

func WithUnbufferedOpener() ImageOption

WithUnbufferedOpener streams the image to avoid buffering.

Jump to

Keyboard shortcuts

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