docker

package
v0.0.0-...-5a1c513 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2019 License: Apache-2.0 Imports: 14 Imported by: 6

Documentation

Index

Constants

View Source
const (
	// ContainerInPath is the input path for fissile
	ContainerInPath = "/fissile-in"
	// ContainerOutPath is the output path for fissile
	ContainerOutPath = "/fissile-out"
)

Variables

View Source
var (
	// ErrImageNotFound is the error returned when an image is not found.
	ErrImageNotFound = fmt.Errorf("Image not found")
)

Functions

This section is empty.

Types

type FormattingWriter

type FormattingWriter struct {
	io.Writer
	io.Closer
	// contains filtered or unexported fields
}

FormattingWriter wraps an io.WriteCloser so lines can be individually formatted.

func NewFormattingWriter

func NewFormattingWriter(writer io.Writer, aColorizer StringFormatter) *FormattingWriter

NewFormattingWriter - Get a FormattingWriter here. aColorizer can be nil

func (*FormattingWriter) Close

func (w *FormattingWriter) Close() error

Close ensures the remaining data is written to the io.Writer

func (*FormattingWriter) Write

func (w *FormattingWriter) Write(data []byte) (int, error)

type ImageManager

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

ImageManager handles Docker images

func NewImageManager

func NewImageManager() (*ImageManager, error)

NewImageManager creates an instance of ImageManager

func (*ImageManager) BuildImage

func (d *ImageManager) BuildImage(dockerfileDirPath, name string, stdoutWriter io.WriteCloser) error

BuildImage builds a docker image using a directory that contains a Dockerfile

func (*ImageManager) BuildImageFromCallback

func (d *ImageManager) BuildImageFromCallback(name string, stdoutWriter io.Writer, callback func(*tar.Writer) error) error

BuildImageFromCallback builds a docker image by letting a callback popuplate a tar.Writer; the callback must write a Dockerfile into the tar stream (as well as any additional build context). If stdoutWriter implements io.Closer, it will be closed when done.

func (*ImageManager) CreateImage

func (d *ImageManager) CreateImage(containerID string, repository string, tag string, message string, cmd []string) (*dockerclient.Image, error)

CreateImage will create a Docker image

func (*ImageManager) FindBestImageWithLabels

func (d *ImageManager) FindBestImageWithLabels(baseImageName string, labels []string) (string, map[string]string, error)

FindBestImageWithLabels finds the best image that has a given base image, and has as many of the given labels as possible. Returns the best matching image name, and all of the matched labels (and their values).

func (*ImageManager) FindImage

func (d *ImageManager) FindImage(imageName string) (*dockerclient.Image, error)

FindImage will lookup an image in Docker

func (*ImageManager) HasImage

func (d *ImageManager) HasImage(imageName string) (bool, error)

HasImage determines if the given image already exists in Docker

func (*ImageManager) RemoveContainer

func (d *ImageManager) RemoveContainer(containerID string) error

RemoveContainer will remove a container from Docker

func (*ImageManager) RemoveImage

func (d *ImageManager) RemoveImage(imageName string) error

RemoveImage will remove an image from Docker's internal registry

func (*ImageManager) RemoveVolumes

func (d *ImageManager) RemoveVolumes(container *dockerclient.Container) error

RemoveVolumes removes any temporary volumes assoicated with a container

func (*ImageManager) RunInContainer

func (d *ImageManager) RunInContainer(opts RunInContainerOpts) (exitCode int, container *dockerclient.Container, err error)

RunInContainer will execute a set of commands within a running Docker container

type RunInContainerOpts

type RunInContainerOpts struct {
	ContainerName string
	ImageName     string
	Cmd           []string
	// Mount points, src -> dest
	// dest may be special values ContainerInPath, ContainerOutPath
	Mounts map[string]string
	// Create local volumes.  Volumes are destroyed unless KeepContainer is true
	Volumes       map[string]map[string]string
	KeepContainer bool
	StdoutWriter  io.Writer
	StderrWriter  io.Writer
}

RunInContainerOpts encapsulates the options to RunInContainer()

type StringFormatter

type StringFormatter func(line string) string

StringFormatter is a formatting string function

func ColoredBuildStringFunc

func ColoredBuildStringFunc(buildName string) StringFormatter

ColoredBuildStringFunc returns a formatting function for colorizing strings.

Jump to

Keyboard shortcuts

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