Documentation ¶
Overview ¶
Package docker contains Docker-related helpers for component tests.
Index ¶
- Constants
- Variables
- func CleanupResources() error
- func CleanupSessionResources(session *Session) error
- func CleanupSessionResourcesFromFile(fname string) error
- func GetEnv() (string, string, error)
- func GetFreePort() (string, error)
- func InDocker() bool
- func Retry(op func() error) error
- type BuildOptions
- type Component
- type RunOptions
- type Session
- func (s *Session) AutoServiceAddress(serviceName string) (string, error)
- func (s *Session) DockerToDockerServiceAddress(serviceName string) (string, error)
- func (s *Session) HostToDockerServiceAddress(serviceName string) (string, error)
- func (s *Session) ID() string
- func (s *Session) InDocker() bool
- func (s *Session) NetworkID() string
- func (s *Session) Persist() error
- func (s *Session) PersistToFile(fpath string) error
- func (s *Session) RegisterHostMappedDockerService(serviceName, endpoint string) error
- func (s *Session) RegisterInternalDockerService(serviceName, endpoint string) error
- func (s *Session) ServiceNames() []string
- func (s *Session) StartComponents(cs ...Component) error
- type SimpleComponent
- type SimpleContainerConfig
- type SimpleContainerOptionFunc
Constants ¶
const DefaultSessionFile = ".bakesession"
DefaultSessionFile is the file name used for storing sessions.
Variables ¶
var RetryMaxTimeout = 5 * time.Minute
RetryMaxTimeout is the timeout for the default retry func.
Functions ¶
func CleanupResources ¶
func CleanupResources() error
CleanupResources finds all session files and prunes Docker resources associated with them.
func CleanupSessionResources ¶
CleanupSessionResources cleans up Docker resources for a Session.
func CleanupSessionResourcesFromFile ¶
CleanupSessionResourcesFromFile cleans up docker resources for a Session from a session file.
func GetFreePort ¶
GetFreePort tries to find a free port on the current machine.
Types ¶
type BuildOptions ¶
BuildOptions contains simple docker build options.
type RunOptions ¶
RunOptions contains docker container run options.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session is the docker session, used to manage the lifecycle of components.
func LoadSession ¶
LoadSession attempts to load a Session from the default file location.
func LoadSessionFromFile ¶
LoadSessionFromFile attempts to load a session from a file.
func NewSession ¶
NewSession prepares a new Docker session.
func (*Session) AutoServiceAddress ¶
AutoServiceAddress retrieves an endpoint for a service name, appropriate for the running code.
func (*Session) DockerToDockerServiceAddress ¶
DockerToDockerServiceAddress retrieves an internal endpoint for a service name.
func (*Session) HostToDockerServiceAddress ¶
HostToDockerServiceAddress retrieves a host mapped endpoint for a service name.
func (*Session) InDocker ¶
InDocker indicates whether this session was started from inside a Docker container.
func (*Session) PersistToFile ¶
PersistToFile serializes a session and writes it to a file.
func (*Session) RegisterHostMappedDockerService ¶
RegisterHostMappedDockerService registers a host mapped endpoint against the service name.
func (*Session) RegisterInternalDockerService ¶
RegisterInternalDockerService registers an internal endpoint against the service name.
func (*Session) ServiceNames ¶
ServiceNames list of registered service names.
func (*Session) StartComponents ¶
StartComponents starts the provided components.
type SimpleComponent ¶
type SimpleComponent struct { Name string Containers []SimpleContainerConfig }
SimpleComponent groups together several containers.
func (*SimpleComponent) Start ¶
func (c *SimpleComponent) Start(session *Session) error
Start all containers sequentially.
type SimpleContainerConfig ¶
type SimpleContainerConfig struct { Name string Repository string Tag string Env []string BuildOpts *BuildOptions ServicePorts map[string]string StaticServicePorts map[string]string ReadyFunc func(*Session) error RunOpts *RunOptions }
SimpleContainerConfig defines a Docker container with associated service ports.
type SimpleContainerOptionFunc ¶
type SimpleContainerOptionFunc func(*SimpleContainerConfig)
SimpleContainerOptionFunc allows for customization of SimpleContainerConfigs.
func WithTag ¶
func WithTag(tag string) SimpleContainerOptionFunc
WithTag sets a Docker tag in a SimpleContainerConfig.
Directories ¶
Path | Synopsis |
---|---|
Package component contains components for component tests.
|
Package component contains components for component tests. |
consul
Package consul exposes a Consul service and client.
|
Package consul exposes a Consul service and client. |
jaeger
Package jaeger exposes a Jaeger service.
|
Package jaeger exposes a Jaeger service. |
kafka
Package kafka exposes Kafka and Zookeeper containers.
|
Package kafka exposes Kafka and Zookeeper containers. |
localstack
Package localstack exposes a Localstack service.
|
Package localstack exposes a Localstack service. |
mockserver
Package mockserver exposes a Mockserver services.
|
Package mockserver exposes a Mockserver services. |
mongodb
Package mongodb exposes a Mongo DB service.
|
Package mongodb exposes a Mongo DB service. |
redis
Package redis exposes a Redis service.
|
Package redis exposes a Redis service. |
testservice
Package testservice exposes a simple test service.
|
Package testservice exposes a simple test service. |
testservice/cmd/testservice
Package main of the test service.
|
Package main of the test service. |
Package env contains helpers to export a service's env vars with some substitution in order to replace docker-to-docker to host-to-docker addresses.
|
Package env contains helpers to export a service's env vars with some substitution in order to replace docker-to-docker to host-to-docker addresses. |