container

package
v0.0.0-...-ec97c03 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2017 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TugbotService     = "tugbot-service"
	TugbotTest        = "tugbot-test"
	TugbotEventDocker = "tugbot-event-docker"
	TugbotEventTimer  = "tugbot-event-timer"
	TugbotCreatedFrom = "tugbot-created-from"
	SwarmTaskID       = "com.docker.swarm.task.id"
)

Docker container labels

View Source
const (
	// type filter: tugbot-event-docker-filter-type=container|image|daemon|network|volume|plugin
	TypeFilter = "tugbot-event-docker-filter-type"
	// action filter (depends on type), for 'container' type:
	//  - attach, commit, copy, create, destroy, detach, die, exec_create, exec_detach, exec_start, export,
	//  - health_status, kill, oom, pause, rename, resize, restart, start, stop, top, unpause, update
	ActionFilter = "tugbot-event-docker-filter-action"
	// container filter: use name, comma separated name list or RE2 regexp
	ContainerFilter = "tugbot-event-docker-filter-container"
	// image filter: use name, comma separated name list or RE2 regexp
	ImageFilter = "tugbot-event-docker-filter-image"
	// label filter: use key=value comma separated pairs
	LabelFilter = "tugbot-event-docker-filter-label"
)

Docker Event Filter

Variables

This section is empty.

Functions

func IsCreatedByTugbot

func IsCreatedByTugbot(e *dockerclient.Event) bool

IsCreatedByTugbot - true if created by tugbot

func IsSwarmTask

func IsSwarmTask(e *dockerclient.Event) bool

IsSwarmTask - true if container is a swarm task

Types

type Client

type Client interface {
	ListContainers(Filter) ([]Container, error)
	StartContainerFrom(Container) error
	StartMonitorEvents(dockerclient.Callback)
	StopAllMonitorEvents()
	Inspect(containerID string) (*Container, error)
}

A Client is the interface through which tugbot interacts with the Docker API.

func NewClient

func NewClient(dockerHost string, tlsConfig *tls.Config, pullImages bool) Client

NewClient returns a new Client instance which can be used to interact with the Docker API.

type Container

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

Container represents a running Docker container.

func NewContainer

func NewContainer(containerInfo *dockerclient.ContainerInfo, imageInfo *dockerclient.ImageInfo) *Container

NewContainer returns a new Container instance instantiated with the specified ContainerInfo and ImageInfo structs.

func (Container) GetEventListenerInterval

func (c Container) GetEventListenerInterval() (time.Duration, bool)

GetEventListenerTimer returns interval duration between a test container run and true if docker label exist and label value parsed into Duration, Otherwise false.

func (Container) ID

func (c Container) ID() string

ID returns the Docker container ID.

func (Container) ImageID

func (c Container) ImageID() string

ImageID returns the ID of the Docker image that was used to start the container.

func (Container) ImageName

func (c Container) ImageName() string

ImageName returns the name of the Docker image that was used to start the container. If the original image was specified without a particular tag, the "latest" tag is assumed.

func (Container) IsCreatedByTugbot

func (c Container) IsCreatedByTugbot() bool

IsCreatedByTugbot returns whether or not a container created by tugbot.

func (Container) IsEventListener

func (c Container) IsEventListener(e *dockerclient.Event) bool

IsEventListener returns whether or not a container should run when an event e is occurred.

func (Container) IsTugbot

func (c Container) IsTugbot() bool

IsTugbot returns whether or not the current container is the tugbot container itself. The tugbot container is identified by the presence of the "tugbot.service" label in the container metadata.

func (Container) IsTugbotCandidate

func (c Container) IsTugbotCandidate() bool

IsTugbotCandidate returns whether or not a container is a candidate to run by tugbot. A candidate container is identified by the presence of "tugbot-test", it doesn't contain "tugbot.created.from" in the container metadata and it state is "Exited".

func (Container) Name

func (c Container) Name() string

Name returns the Docker container name.

type Filter

type Filter func(Container) bool

A Filter is a prototype for a function that can be used to filter the results from a call to the ListContainers() method on the Client.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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