dockeradapter

package
v0.0.0-...-7f4d65f Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2018 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Stdin represents standard input stream type.
	Stdin = iota
	// Stdout represents standard output stream type.
	Stdout
	// Stderr represents standard error stream type.
	Stderr
	// Systemerr represents errors originating from the system that make it
	// into the the multiplexed stream.
	Systemerr
)
View Source
const MinSupportedAPIVersion = "1.21"

MinSupportedAPIVersion is the lowest Docker API version that Lumogon supports Docker API Version 1.21 - Docker Engine 1.10.x - for support < 1.21 need to be able to identify the scheduler container so it can be excluded from results - for support < 1.20 need to use an alternative to copy when detecting the target containers OS

Variables

This section is empty.

Functions

func DockerConfig

func DockerConfig() (string, string, bool)

DockerConfig returns values for the following environment variables, setting a default if no variable is set: DOCKER_HOST, DOCKER_CERT_PATH, DOCKER_TLS_VERIFY **NOTE** DOCKER_CERT_PATH, DOCKER_TLS_VERIFY are not currently used.

func FilterDockerStream

func FilterDockerStream(reader io.Reader, streamType int) ([]string, error)

FilterDockerStream reads the requested stream from *bufio.Reader, strips the frameHeader added by Dockers stdWriter.Write(p []byte) and returns a slice of strings for each line received (splitting on '/n').

If the stream processes without error but no lines are found then it will return an empty slice of strings.

The following streamTypes are supported (from the Docker stdcopy package):

  • Stdin - 0
  • Stdout - 1
  • Stderr - 2
  • Systemerr - 3

The function works by walking the supplied stream alternating between reading the prefix header bytes followed by the number of bytes specified in the prefix size bytes.

func ImageExists

func ImageExists(ctx context.Context, client ImageInspector, imageName string) bool

ImageExists returns true if the imageName exists

func NormaliseTargets

func NormaliseTargets(ctx context.Context, args *[]string, client Client) ([]*types.TargetContainer, error)

NormaliseTargets takes a slice of strings which can be Container IDs or Names, and returns a slice of types.TargetContainers.

func ServerInfo

func ServerInfo(host string) (string, string, error)

ServerInfo returns the Server APIVersion and the servers ID

Types

type Client

Client is a Docker (currently local) ContainerRuntime

func New

func New() (Client, error)

New returns a client connected with the highest API version supported by both the Lumogon client and the Docker runtime

type CopyFrom

type CopyFrom interface {
	CopyFromContainer(ctx context.Context, container, srcPath string, followSymlink bool) (io.ReadCloser, dockertypes.ContainerPathStat, error)
}

CopyFrom interface exposes methods required to copy file data from a container

type Creator

type Creator interface {
	ContainerCreate(ctx context.Context, command []string, envvars []string, image string, binds []string, links []string, kernelCapabilities []string, pidMode string, containerName string, autoRemove bool, labels map[string]string) (dockercontainer.ContainerCreateCreatedBody, error)
}

Creator interface exposes methods required to create an attached container

type Diff

type Diff interface {
	ContainerDiff(ctx context.Context, containerID string) ([]types.ChangedFile, error)
}

Diff interface exposes methods required to determine files in running container that have been changed/added/removed relative to the containers image

type DockerAPICapability

type DockerAPICapability struct {
	types.Capability
	Harvest func(*DockerAPICapability, Harvester, string, types.TargetContainer) `json:"-"`
}

DockerAPICapability embedded type adds a Docker specific Harvest function field which passes a client satisfying the dockeradapter.Harvester interface. This function is responsible for populating the Payload field.

type Executor

type Executor interface {
	ContainerExecCreate(ctx context.Context, execID string, cmd []string, attachStdout bool, attachStderr bool) (dockertypes.IDResponse, error)
	ContainerExecStart(ctx context.Context, execID string) error
	ContainerExecAttach(ctx context.Context, execID string) (dockertypes.HijackedResponse, error)
	ContainerExecInspect(ctx context.Context, execID string) (dockertypes.ContainerExecInspect, error)
}

Executor TODO

type Harvester

type Harvester interface {
	Inspector
	Executor
	Diff
	HostInspector
}

Harvester interface exposes methods used by Capabilties Harvest functions

type HostInspector

type HostInspector interface {
	HostID(ctx context.Context) string
	ServerVersion(ctx context.Context) (dockertypes.Version, error)
}

HostInspector interface exposes methods required to inspect a docker host

type ImageInspector

type ImageInspector interface {
	ImageInspect(ctx context.Context, imageName string) (dockertypes.ImageInspect, error)
}

ImageInspector interface exposes methods required to inspect an image

type ImageInspectorPuller

type ImageInspectorPuller interface {
	ImageInspector
	ImagePuller
}

ImageInspectorPuller interface exposes methods required to both pull and and inspect an image

type ImagePuller

type ImagePuller interface {
	ImagePull(ctx context.Context, imageName string) error
}

ImagePuller interface exposes methods required to pull an image

type Inspector

type Inspector interface {
	ContainerInspect(ctx context.Context, containerID string) (dockertypes.ContainerJSON, error)
}

Inspector interface exposes methods required to inspect a container

type Lister

type Lister interface {
	ContainerList(ctx context.Context) ([]string, error)
}

Lister interface exposes methods required to list containers

type LogGetter

type LogGetter interface {
	ContainerLogs(ctx context.Context, containerID string) (string, error)
}

LogGetter interface exposes methods required to get logs from a container

type Remover

type Remover interface {
	ContainerRemove(ctx context.Context, containerID string, force bool) error
	CleanupHarvesters(ctx context.Context, key string) error
}

Remover interface exposes methods required to remove a container

type Starter

type Starter interface {
	ContainerStart(ctx context.Context, containerID string) error
}

Starter interface exposes methods required to start a container

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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