Documentation ¶
Overview ¶
Package docker assists with creating containers and networks for docker.
Index ¶
- Constants
- func TestingDeadline(t errs.Testing) time.Time
- type MainContext
- func (ctx *MainContext) Cancel()
- func (ctx *MainContext) GetContainer(req testcontainers.ContainerRequest) (tc testcontainers.Container, cleanup func())
- func (ctx *MainContext) GetInternalNet() (*testcontainers.DockerNetwork, func())
- func (ctx *MainContext) GetNet(opts ...network.NetworkCustomizer) (*testcontainers.DockerNetwork, func())
- func (ctx *MainContext) WriteDebugZip()
- type MainContextEntry
- type NamedNetwork
Constants ¶
const ( DockerfileName = "Dockerfile" CaddyfileName = "Caddyfile" LogName = "caddy.log" )
const DefaultTestTimeout = time.Minute * 5
Variables ¶
This section is empty.
Functions ¶
Types ¶
type MainContext ¶
type MainContext struct { context.Context Client MainContextEntry[templates.DotClient] Server MainContextEntry[templates.DotServer] Now time.Time // contains filtered or unexported fields }
MainContext contains the overall context for the application and configs.
func NewMainContext ¶
func NewMainContext(t errs.Testing, clientDirective string) *MainContext
NewMainContext creates a new context. clientDirective is passed to the client's Caddyfile as the handler for the `:80` route.
func (*MainContext) Cancel ¶
func (ctx *MainContext) Cancel()
func (*MainContext) GetContainer ¶
func (ctx *MainContext) GetContainer(req testcontainers.ContainerRequest) (tc testcontainers.Container, cleanup func())
GetContainer creates a new docker container with the given request. The container will be started before returning. Use cleanup to remove all container resources after running.
func (*MainContext) GetInternalNet ¶
func (ctx *MainContext) GetInternalNet() (*testcontainers.DockerNetwork, func())
GetInternalNet gets a docker network with no external connection.
func (*MainContext) GetNet ¶
func (ctx *MainContext) GetNet(opts ...network.NetworkCustomizer) (*testcontainers.DockerNetwork, func())
GetNet gets a network with the given options. Use the returned func to cleanup the container after usage.
func (*MainContext) WriteDebugZip ¶
func (ctx *MainContext) WriteDebugZip()
WriteDebugZip writes information about the caddy processes for debugging. The zip contains the server and client's caddyfile and dockerfile, along with any logs if they exist.
type MainContextEntry ¶
type MainContextEntry[D interface { templates.Dot NamedNetwork }] struct { Dockerfile archive.Entry[[]byte] Caddyfile archive.Entry[[]byte] Config D Logs lockedBuf // contains filtered or unexported fields }
MainContextEntry is either a server or client definition.
func (*MainContextEntry[D]) StartContainer ¶
func (mce *MainContextEntry[D]) StartContainer(networks []string, exposed []string, waitPort ...nat.Port) (testcontainers.Container, func())
StartContainer starts the container specified by this configuration.
type NamedNetwork ¶
type NamedNetwork interface {
GetNetworkName() string
}
NamedNetwork is used to specify the server and client data.