Documentation
¶
Index ¶
- Constants
- func BindsForTask(taskInfo *mesos.TaskInfo) []string
- func CapAddForTask(taskInfo *mesos.TaskInfo) []string
- func CapDropForTask(taskInfo *mesos.TaskInfo) []string
- func CheckImage(client DockerClient, taskInfo *mesos.TaskInfo) bool
- func ConfigForTask(taskInfo *mesos.TaskInfo, forceCpuLimit bool, forceMemoryLimit bool) *docker.CreateContainerOptions
- func EnvForTask(taskInfo *mesos.TaskInfo) []string
- func GetContainerName(taskId *mesos.TaskID) string
- func GetExitCode(client DockerClient, containerId string) (int, error)
- func GetLogs(client DockerClient, containerId string, since int64, stdout io.Writer, ...)
- func LabelsForTask(taskInfo *mesos.TaskInfo) map[string]string
- func NetworkForTask(taskInfo *mesos.TaskInfo) string
- func PortBindingsForTask(taskInfo *mesos.TaskInfo) map[docker.Port][]docker.PortBinding
- func PortsForTask(taskInfo *mesos.TaskInfo) map[docker.Port]struct{}
- func PullImage(client DockerClient, taskInfo *mesos.TaskInfo, ...) error
- func StopContainer(client DockerClient, containerId string, timeout uint) error
- type DockerClient
- type MockDockerClient
- func (m *MockDockerClient) CreateContainer(opts docker.CreateContainerOptions) (*docker.Container, error)
- func (m *MockDockerClient) InspectContainer(id string) (*docker.Container, error)
- func (m *MockDockerClient) ListContainers(opts docker.ListContainersOptions) ([]docker.APIContainers, error)
- func (m *MockDockerClient) ListImages(opts docker.ListImagesOptions) ([]docker.APIImages, error)
- func (m *MockDockerClient) Logs(opts docker.LogsOptions) error
- func (m *MockDockerClient) PullImage(opts docker.PullImageOptions, auth docker.AuthConfiguration) error
- func (m *MockDockerClient) StartContainer(id string, hostConfig *docker.HostConfig) error
- func (m *MockDockerClient) StopContainer(id string, timeout uint) error
Constants ¶
const DockerNamePrefix = "mesos-"
Prefix used to name Docker containers in order to distinguish those created by Mesos from those created manually.
Variables ¶
This section is empty.
Functions ¶
func BindsForTask ¶
Mesos volume information to Docker volume binds at runtime (equivalent to -v)
func CapAddForTask ¶
Scan for cap-adds and generate string slice
func CapDropForTask ¶
Scan for cap-drops and generate string slice
func CheckImage ¶
func CheckImage(client DockerClient, taskInfo *mesos.TaskInfo) bool
Loop through all the images and see if we have one with a match on this repo image:tag combination.
func ConfigForTask ¶
func ConfigForTask(taskInfo *mesos.TaskInfo, forceCpuLimit bool, forceMemoryLimit bool) *docker.CreateContainerOptions
Generate a complete config with both Config and HostConfig. Does not attempt to be exhaustive in support for Docker options. Supports the most commonly used options. Others are not complex to add.
func EnvForTask ¶
Map Mesos environment settings to Docker environment (-e FOO=BAR)
func GetContainerName ¶ added in v0.6.1
func GetExitCode ¶ added in v0.6.3
func GetExitCode(client DockerClient, containerId string) (int, error)
func GetLogs ¶
func GetLogs(client DockerClient, containerId string, since int64, stdout io.Writer, stderr io.Writer)
Fetch the Docker logs from a task and return two Readers that let us fetch the contents.
func LabelsForTask ¶
Map Mesos parameter lables to Docker labels
func NetworkForTask ¶
Map Mesos enum to strings for Docker
func PortBindingsForTask ¶
The actual ports bound to this container, nost just EXPOSEd (equivalent to -P)
func PortsForTask ¶
Translate Mesos TaskInfo port records in Docker ports map. These show up as EXPOSE
func PullImage ¶
func PullImage(client DockerClient, taskInfo *mesos.TaskInfo, authConfig *docker.AuthConfiguration) error
Pull the Docker image refered to in the taskInfo. Uses the Docker credentials passed in.
func StopContainer ¶
func StopContainer(client DockerClient, containerId string, timeout uint) error
Tries very hard to stop a container. Has to take a containerId instead of a mesos.TaskInfo because we don't have the TaskInfo in the KillTask callback from the executor driver.
Types ¶
type DockerClient ¶
type DockerClient interface { CreateContainer(opts docker.CreateContainerOptions) (*docker.Container, error) InspectContainer(id string) (*docker.Container, error) ListContainers(opts docker.ListContainersOptions) ([]docker.APIContainers, error) ListImages(docker.ListImagesOptions) ([]docker.APIImages, error) Logs(opts docker.LogsOptions) error PullImage(docker.PullImageOptions, docker.AuthConfiguration) error StartContainer(id string, hostConfig *docker.HostConfig) error StopContainer(id string, timeout uint) error }
Our own narrowly-scoped interface for Docker client
type MockDockerClient ¶
type MockDockerClient struct { PullImageShouldError bool Images []docker.APIImages ListImagesShouldError bool StopContainerShouldError bool StopContainerMaxFails int InspectContainerShouldError bool Container *docker.Container LogOutputString string LogErrorString string ListContainersShouldError bool ListContainersContainers []docker.APIContainers // contains filtered or unexported fields }
func (*MockDockerClient) CreateContainer ¶
func (m *MockDockerClient) CreateContainer(opts docker.CreateContainerOptions) (*docker.Container, error)
func (*MockDockerClient) InspectContainer ¶
func (m *MockDockerClient) InspectContainer(id string) (*docker.Container, error)
func (*MockDockerClient) ListContainers ¶
func (m *MockDockerClient) ListContainers(opts docker.ListContainersOptions) ([]docker.APIContainers, error)
func (*MockDockerClient) ListImages ¶
func (m *MockDockerClient) ListImages(opts docker.ListImagesOptions) ([]docker.APIImages, error)
func (*MockDockerClient) Logs ¶
func (m *MockDockerClient) Logs(opts docker.LogsOptions) error
func (*MockDockerClient) PullImage ¶
func (m *MockDockerClient) PullImage(opts docker.PullImageOptions, auth docker.AuthConfiguration) error
func (*MockDockerClient) StartContainer ¶
func (m *MockDockerClient) StartContainer(id string, hostConfig *docker.HostConfig) error
func (*MockDockerClient) StopContainer ¶
func (m *MockDockerClient) StopContainer(id string, timeout uint) error