Documentation
¶
Index ¶
- Constants
- func Cli(n string) *cli
- type CreateResponse
- type DockerClient
- func (c *DockerClient) AddBind(bnd string)
- func (c *DockerClient) AddBinds(bnds []string)
- func (c *DockerClient) AddEnv(key, value string)
- func (c *DockerClient) AddEnvs(envs []string)
- func (c *DockerClient) BindFromGit(cfg *GitCheckoutConfig, noGit func() error) error
- func (c *DockerClient) ContainerExists(name string) bool
- func (c *DockerClient) DeleteContainer(id string) error
- func (c *DockerClient) Git() *Git
- func (c *DockerClient) ImageExists(image string) bool
- func (c *DockerClient) InitDocker() error
- func (c *DockerClient) Privileged(p bool)
- func (c *DockerClient) PullImage(image string) error
- func (c *DockerClient) SetBinds(bnds []string)
- func (c *DockerClient) SetCmd(cmd []string)
- func (c *DockerClient) SetConf(co *container.Config)
- func (c *DockerClient) SetDefaults()
- func (c *DockerClient) SetEnvs(envs []string)
- func (c *DockerClient) SetHostConf(h *container.HostConfig)
- func (c *DockerClient) SetImage(img string)
- func (c *DockerClient) SetNetConf(n *network.NetworkingConfig)
- func (c *DockerClient) SetWorkDir(wd string)
- func (c *DockerClient) StartContainer(rm bool, name string) (string, error)
- type Event
- type Git
- type GitCheckoutConfig
- type ProgressDetail
- type Task
- type TaskFunc
Constants ¶
const ( EXIT_CODE_RUNTIME_ERROR = 1 EXIT_CODE_API_ERROR = 2 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CreateResponse ¶
type CreateResponse struct {
Id string `json:"id"`
Status string `json:"status"`
ProgressDetail ProgressDetail `json:"progressDetail"`
Progress string `json:"progress,omitempty"`
}
CreateResponse is the response from Docker API when pulling an image
type DockerClient ¶
type DockerClient struct {
Cli *client.Client
HostConf *container.HostConfig
NetConf *network.NetworkingConfig
Conf *container.Config
// contains filtered or unexported fields
}
DockerClient is a slimmed down implementation of the docker cli
func NewDockerClient ¶
func NewDockerClient() *DockerClient
NewDockerClient returns a new DockerClient initialised with the API object
func (*DockerClient) AddBind ¶
func (c *DockerClient) AddBind(bnd string)
AddBind adds a bind mount to the HostConfig
func (*DockerClient) AddBinds ¶
func (c *DockerClient) AddBinds(bnds []string)
AddBinds adds multiple bind mounts to the HostConfig
func (*DockerClient) AddEnv ¶
func (c *DockerClient) AddEnv(key, value string)
AddEnvs adds an environment variable to the HostConfig
func (*DockerClient) AddEnvs ¶
func (c *DockerClient) AddEnvs(envs []string)
AddEnvs adds multiple envs to the HostConfig
func (*DockerClient) BindFromGit ¶
func (c *DockerClient) BindFromGit(cfg *GitCheckoutConfig, noGit func() error) error
BindFromGit creates a data container with a git clone inside and mounts its volumes inside your app container If there is no valid Git repo set in config, the noGit callback function will be executed instead
func (*DockerClient) ContainerExists ¶
func (c *DockerClient) ContainerExists(name string) bool
ContainerExists determines if the container with this name exist
func (*DockerClient) DeleteContainer ¶
func (c *DockerClient) DeleteContainer(id string) error
DeleteContainer - Delete a container
func (*DockerClient) ImageExists ¶
func (c *DockerClient) ImageExists(image string) bool
ImageExists determines if an image exist locally
func (*DockerClient) InitDocker ¶
func (c *DockerClient) InitDocker() error
Init initialises the client
func (*DockerClient) Privileged ¶
func (c *DockerClient) Privileged(p bool)
Privileged sets whether the container should run as privileged
func (*DockerClient) PullImage ¶
func (c *DockerClient) PullImage(image string) error
PullImage - Pull an image locally
func (*DockerClient) SetBinds ¶
func (c *DockerClient) SetBinds(bnds []string)
SetBinds sets the bind mounts in the HostConfig
func (*DockerClient) SetCmd ¶
func (c *DockerClient) SetCmd(cmd []string)
SetCmd sets the command to run in the container
func (*DockerClient) SetConf ¶
func (c *DockerClient) SetConf(co *container.Config)
SetConf sets the container.Config struct for the new container
func (*DockerClient) SetDefaults ¶
func (c *DockerClient) SetDefaults()
SetDefaults sets container, host and net configs to defaults. Called when instantiating a new client or can be called manually at any time to reset API configs back to empty defaults
func (*DockerClient) SetEnvs ¶
func (c *DockerClient) SetEnvs(envs []string)
SetEnvs sets the environment variables in the Conf
func (*DockerClient) SetHostConf ¶
func (c *DockerClient) SetHostConf(h *container.HostConfig)
SetHostConf sets the container.HostConfig struct for the new container
func (*DockerClient) SetImage ¶
func (c *DockerClient) SetImage(img string)
SetImage sets the image in Conf
func (*DockerClient) SetNetConf ¶
func (c *DockerClient) SetNetConf(n *network.NetworkingConfig)
SetNetConf sets the network.NetworkingConfig struct for the new container
func (*DockerClient) SetWorkDir ¶
func (c *DockerClient) SetWorkDir(wd string)
SetWorkDir sets the working directory of the container
func (*DockerClient) StartContainer ¶
func (c *DockerClient) StartContainer(rm bool, name string) (string, error)
StartContainer will create and start a container with logs and optional cleanup
type Git ¶
type Git struct {
Image string
// contains filtered or unexported fields
}
Git is used to interact with containerised git
type GitCheckoutConfig ¶
type GitCheckoutConfig struct {
Repo, Branch, RelPath, Image string
}
GitCheckoutConfig is input for Git.Checkout
type ProgressDetail ¶
type ProgressDetail struct {
Current int `json:"current,omitempty"`
Total int `json:"total,omitempty"`
}
ProgressDetail records the progress achieved downloading an image
type Task ¶
type Task struct {
*DockerClient
// contains filtered or unexported fields
}
Task is the action performed when it's parent command is run
func (*Task) Bind ¶
Bind is a utility function which will return the correctly formatted string when given a source and destination directory
The ~ symbol and relative paths will be correctly expanded depending on the host OS
func (*Task) SetDefaults ¶
SetDefaults sets the default host config for a task container Mounts the PWD to /tmp/workspace Mounts your ~/.aws directory to /root - change this if your image runs as a non-root user Sets /tmp/workspace as the workdir Configures git
func (*Task) SetFunc ¶
SetFunc sets the TaskFunc which is run when the parent command is run if this is left unset, the defaultTaskFunc will be executed instead
func (*Task) SetInitFunc ¶
SetInitFunc sets the TaskFunc which is executed before the main TaskFunc. It's pupose is to do any setup of the DockerClient which depends on command line args for example