docker

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 27, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package docker assists with creating containers and networks for docker.

Index

Constants

View Source
const (
	DockerfileName = "Dockerfile"
	CaddyfileName  = "Caddyfile"
	LogName        = "caddy.log"
)
View Source
const DefaultTestTimeout = time.Minute * 5

Variables

This section is empty.

Functions

func TestingDeadline

func TestingDeadline(t errs.Testing) time.Time

TestingDeadline gets the deadline that is passed to testing. If it is not set it returns the current time added to the default timeout.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL