docker

package
v0.0.0-...-2435b8f Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2019 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package docker contains simple utilities for pulling a docker image, starting a container, and stoping a container. It assumes that docker is installed. If it is not, it will simply throw an error.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContainerExists

func ContainerExists(container string) (bool, error)

ContainerExists checks if a container with the given name is in the list of running, or old, containers.

func ContainerId

func ContainerId(container string) (string, error)

ContainerId returns the id of the requested container

func ContainsLinks(container string, linkedContainers []string) bool

ContainsLinks returns whether the given container has links to the given list of containers.

func FullImageName

func FullImageName(repo, image, tag string) string

FullImageName creates a full image name from a repository URI, an image name, and a tag.

func HasDocker

func HasDocker() bool

HasDocker determines whether docker is installed and included in PATH.

func ImageMatches

func ImageMatches(image, container string) bool

ImageMatches returns whether the container is running the current version of image.

func MappedVolume

func MappedVolume(path, container string) (bool, string)

MappedVolume returns whether path is already mapped into the workspace of the shipshape service running at container. If it is, it returns the relative path of path within the mapped volume.

func OutOfDate

func OutOfDate(image string) bool

OutOfDate returns true if the image specified has not been pulled recently.

Types

type CommandResult

type CommandResult struct {
	Stdout string
	Stderr string
	Err    error
}

TODO(ciera): Consider making these all use channels.

func Pull

func Pull(image string) CommandResult

Pull makes a command line call to docker to pull the specified container. docker pull repository/name:tag. It returns stdout, stderr, and any errors from running. This is a blocking call, and should be wrapped in a go routine for asynchonous use.

func RunAnalyzer

func RunAnalyzer(image, analyzerContainer, workspacePath, logsPath string, port int, dind bool) CommandResult

RunAnalyzer runs the analyzer image with container analyzerContainer. It runs it at port (mapped to internal port 10005), binds the volumes for the workspacePath and logsPath, and gives the privileged if dind (docker-in-docker) is true.

func RunKythe

func RunKythe(image, container, sourcePath, extractor string, dind bool) CommandResult

RunKythe runs the specified kythe docker image at the named container. It uses the source root and extractor specified, and gives the privileged flag if dind (docker-in-docker) is true. It returns stdout, stderr, and any errors from running. This is a blocking call, and should be wrapped in a go routine for asynchonous use.

func RunService

func RunService(image, container, workspacePath, logsPath string, analyzerContainers []string, dind bool) CommandResult

RunService runs the shipshape service at image, as the container named container. It binds the shipshape workspace and logs appropriately. It starts with the third-party analyzers already running at analyzerContainers. The service is started with the privileged flag if dind (docker-in-docker) is true.

func Stop

func Stop(container string, waitTime time.Duration, remove bool) CommandResult

Stop stops a running container. It returns stdout, stderr, and any errors from running. This is a blocking call, and should be wrapped in a go routine for asynchonous use. If requested, also remove the container.

Jump to

Keyboard shortcuts

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