Documentation ¶
Index ¶
- Constants
- func BuildImage(ctx context.Context, api *client.Client, containerfile string, ...) ([]byte, error)
- func NewDockerAPI() (*client.Client, error)
- func RunCmdInBackground(api *client.Client, ctx context.Context, container string, cmd []string, ...) (string, error)
- func RunCmdWithOutput(api *client.Client, ctx context.Context, container string, cmd []string, ...) ([]byte, []byte, int, error)
- type BuildArgs
- type BuildContext
- type BuildForceRemove
- type BuildOpt
- type BuildPullParent
- type BuildRemove
- type BuildTags
- type FileContents
- type LogConsumerWriter
- type PathContents
- type RunCmdOpt
- type RunCmdUser
- type RunOptions
- type Runner
- func (d *Runner) BuildImage(ctx context.Context, containerfile string, containerContext BuildContext, ...) ([]byte, error)
- func (d *Runner) CopyFrom(container string, source string) (BuildContext, *types.ContainerPathStat, error)
- func (d *Runner) CopyTo(container string, destination string, contents BuildContext) error
- func (d *Runner) GetNetworkAndAddresses(container string) (map[string]string, error)
- func (d *Runner) RefreshFiles(ctx context.Context, containerID string) error
- func (d *Runner) Restart(ctx context.Context, containerID string) error
- func (d *Runner) RunCmdInBackground(ctx context.Context, container string, cmd []string, opts ...RunCmdOpt) (string, error)
- func (d *Runner) RunCmdWithOutput(ctx context.Context, container string, cmd []string, opts ...RunCmdOpt) ([]byte, []byte, int, error)
- func (d *Runner) Start(ctx context.Context, addSuffix, forceLocalAddr bool) (*StartResult, error)
- func (d *Runner) StartNewService(ctx context.Context, addSuffix, forceLocalAddr bool, connect ServiceAdapter) (*Service, string, error)
- func (d *Runner) StartService(ctx context.Context, connect ServiceAdapter) (*Service, error)
- func (d *Runner) Stop(ctx context.Context, containerID string) error
- type Service
- type ServiceAdapter
- type ServiceConfig
- type ServiceHostPort
- type ServiceURL
- type StartResult
Constants ¶
const DockerAPIVersion = "1.40"
Variables ¶
This section is empty.
Functions ¶
func BuildImage ¶
func NewDockerAPI ¶
func RunCmdInBackground ¶
Types ¶
type BuildContext ¶
type BuildContext map[string]PathContents
func BuildContextFromTarball ¶
func BuildContextFromTarball(reader io.Reader) (BuildContext, error)
func NewBuildContext ¶
func NewBuildContext() BuildContext
type BuildForceRemove ¶
type BuildForceRemove bool
func (BuildForceRemove) Apply ¶
func (u BuildForceRemove) Apply(cfg *types.ImageBuildOptions) error
type BuildOpt ¶
type BuildOpt interface {
Apply(cfg *types.ImageBuildOptions) error
}
type BuildPullParent ¶
type BuildPullParent bool
func (BuildPullParent) Apply ¶
func (u BuildPullParent) Apply(cfg *types.ImageBuildOptions) error
type BuildRemove ¶
type BuildRemove bool
func (BuildRemove) Apply ¶
func (u BuildRemove) Apply(cfg *types.ImageBuildOptions) error
type FileContents ¶
func (FileContents) Get ¶
func (b FileContents) Get() ([]byte, error)
func (*FileContents) SetMode ¶
func (b *FileContents) SetMode(mode int64)
func (*FileContents) SetOwners ¶
func (b *FileContents) SetOwners(uid int, gid int)
func (FileContents) UpdateHeader ¶
func (b FileContents) UpdateHeader(header *tar.Header) error
type LogConsumerWriter ¶
type LogConsumerWriter struct {
// contains filtered or unexported fields
}
type PathContents ¶
type PathContents interface { UpdateHeader(header *tar.Header) error Get() ([]byte, error) SetMode(mode int64) SetOwners(uid int, gid int) }
Mapping of path->contents
func PathContentsFromBytes ¶
func PathContentsFromBytes(data []byte) PathContents
func PathContentsFromString ¶
func PathContentsFromString(data string) PathContents
type RunCmdOpt ¶
type RunCmdOpt interface {
Apply(cfg *types.ExecConfig) error
}
type RunCmdUser ¶
type RunCmdUser string
func (RunCmdUser) Apply ¶
func (u RunCmdUser) Apply(cfg *types.ExecConfig) error
type RunOptions ¶
type RunOptions struct { ImageRepo string ImageTag string ContainerName string Cmd []string Entrypoint []string Env []string NetworkName string NetworkID string CopyFromTo map[string]string Ports []string DoNotAutoRemove bool AuthUsername string AuthPassword string OmitLogTimestamps bool LogConsumer func(string) Capabilities []string PreDelete bool PostStart func(string, string) error LogStderr io.Writer LogStdout io.Writer VolumeNameToMountPoint map[string]string }
type Runner ¶
type Runner struct { DockerAPI *client.Client RunOptions RunOptions }
func NewServiceRunner ¶
func NewServiceRunner(opts RunOptions) (*Runner, error)
func (*Runner) BuildImage ¶
func (*Runner) CopyFrom ¶
func (d *Runner) CopyFrom(container string, source string) (BuildContext, *types.ContainerPathStat, error)
func (*Runner) CopyTo ¶
func (d *Runner) CopyTo(container string, destination string, contents BuildContext) error
func (*Runner) GetNetworkAndAddresses ¶
func (*Runner) RefreshFiles ¶
func (*Runner) RunCmdInBackground ¶
func (*Runner) RunCmdWithOutput ¶
func (*Runner) StartNewService ¶
func (d *Runner) StartNewService(ctx context.Context, addSuffix, forceLocalAddr bool, connect ServiceAdapter) (*Service, string, error)
StartNewService will start the runner's configured docker container but with the ability to control adding a name suffix or forcing a local address to be returned. 'addSuffix' will add a random UUID to the end of the container name. 'forceLocalAddr' will force the container address returned to be in the form of '127.0.0.1:1234' where 1234 is the mapped container port.
func (*Runner) StartService ¶
StartService will start the runner's configured docker container with a random UUID suffix appended to the name to make it unique and will return either a hostname or local address depending on if a Docker network was given.
Most tests can default to using this.
type Service ¶
type Service struct { Config ServiceConfig Cleanup func() Container *types.ContainerJSON StartResult *StartResult }
type ServiceAdapter ¶
ServiceAdapter verifies connectivity to the service, then returns either the connection string (typically a URL) and nil, or empty string and an error.
type ServiceConfig ¶
type ServiceHostPort ¶
type ServiceHostPort struct {
// contains filtered or unexported fields
}
func NewServiceHostPort ¶
func NewServiceHostPort(host string, port int) *ServiceHostPort
func NewServiceHostPortParse ¶
func NewServiceHostPortParse(s string) (*ServiceHostPort, error)
func (ServiceHostPort) Address ¶
func (s ServiceHostPort) Address() string
func (ServiceHostPort) URL ¶
func (s ServiceHostPort) URL() *url.URL
type ServiceURL ¶
type ServiceURL struct {
// contains filtered or unexported fields
}
func NewServiceURL ¶
func NewServiceURL(u url.URL) *ServiceURL
func NewServiceURLParse ¶
func NewServiceURLParse(s string) (*ServiceURL, error)
func (ServiceURL) Address ¶
func (s ServiceURL) Address() string
func (ServiceURL) URL ¶
func (s ServiceURL) URL() *url.URL
type StartResult ¶
type StartResult struct { Container *types.ContainerJSON Addrs []string RealIP string }