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 ¶
- func ContainerExists(container string) (bool, error)
- func ContainerId(container string) (string, error)
- func ContainsLinks(container string, linkedContainers []string) bool
- func FullImageName(repo, image, tag string) string
- func HasDocker() bool
- func ImageMatches(image, container string) bool
- func MappedVolume(path, container string) (bool, string)
- func OutOfDate(image string) bool
- type CommandResult
- func Pull(image string) CommandResult
- func RunAnalyzer(image, analyzerContainer, workspacePath, logsPath string, port int, dind bool) CommandResult
- func RunKythe(image, container, sourcePath, extractor string, dind bool) CommandResult
- func RunService(image, container, workspacePath, logsPath string, analyzerContainers []string, ...) CommandResult
- func Stop(container string, waitTime time.Duration, remove bool) CommandResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContainerExists ¶
ContainerExists checks if a container with the given name is in the list of running, or old, containers.
func ContainerId ¶
ContainerId returns the id of the requested container
func ContainsLinks ¶
ContainsLinks returns whether the given container has links to the given list of containers.
func FullImageName ¶
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 ¶
ImageMatches returns whether the container is running the current version of image.
func MappedVolume ¶
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.
Types ¶
type CommandResult ¶
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.