dockerfake

package
v1.0.0-rc.7 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package dockerfake models the small Docker daemon contract used by tests. It is a recording daemon, not a deployment driver or AppTown fixture.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsDiskRead

func IsDiskRead(args []string) bool

IsDiskRead says args is the disk read's throwaway container, which changes nothing on the host.

func RoomyDisk

func RoomyDisk(args []string) ([]byte, bool)

RoomyDisk answers the disk admission's reads (docker.AdmitDisk: docker info's data folder, and df of it in a docker.DiskImage container) as a daemon with room does; ok is false for any other command. A test's own scripted client asks it first.

Types

type Daemon

type Daemon struct {
	// contains filtered or unexported fields
}

func New

func New() *Daemon

func (*Daemon) Close

func (d *Daemon) Close()

Close stops every published port's relay.

func (*Daemon) Commands

func (d *Daemon) Commands() [][]string

func (*Daemon) Configs

func (d *Daemon) Configs() []string

Configs are the client configuration each command named, in order ("" is the ambient one).

func (*Daemon) Limits

func (d *Daemon) Limits(name string) (memory, nanoCPUs int64)

Limits is the memory and NanoCPUs the daemon holds a container to, as its runs and updates set them (0: no limit).

func (*Daemon) Matching

func (d *Daemon) Matching(prefix string) [][]string

func (*Daemon) PublishPorts

func (d *Daemon) PublishPorts()

PublishPorts makes the daemon publish a container's port as Docker does: a container run with `-p addr:N:inner` answers at N from every start, and one run with `-p addr::inner` answers at a port Docker picks at each start (run, start, restart), so the port it had before goes dead. Each published port relays to the port SetPort names. Without it every running container answers at that port. Close stops the relays.

func (*Daemon) ResetCommands

func (d *Daemon) ResetCommands()

func (*Daemon) Run

func (d *Daemon) Run(_ context.Context, _ string, req docker.Command) ([]byte, error)

func (*Daemon) Running

func (d *Daemon) Running(name string) bool

Running says whether the daemon holds the container running now.

func (*Daemon) SetCommandReply

func (d *Daemon) SetCommandReply(reply func(docker.Command) ([]byte, error, bool))

SetCommandReply scripts stream-bearing commands such as backup copies. The callback must not call methods on this daemon while Run holds its lock.

func (*Daemon) SetDisk

func (d *Daemon) SetDisk(totalBytes, freeBytes int64)

SetDisk scripts what df says of the data folder's filesystem (100 GiB with 90 GiB free unless set).

func (*Daemon) SetExitCode

func (d *Daemon) SetExitCode(name string, code int)

SetExitCode scripts the container's last exit code.

func (*Daemon) SetHostInfo

func (d *Daemon) SetHostInfo(memoryBytes int64, cpus int, dataRoot string)

SetHostInfo scripts what docker info says the daemon can give containers (8 GiB and 8 CPUs unless set).

func (*Daemon) SetOOMKilled

func (d *Daemon) SetOOMKilled(name string, killed bool)

SetOOMKilled scripts whether the container's last exit was an out-of-memory kill, what its inspected state says.

func (*Daemon) SetPort

func (d *Daemon) SetPort(port int)

func (*Daemon) SetReply

func (d *Daemon) SetReply(reply func([]string) ([]byte, error, bool))

SetReply scripts a daemon response after recording the command. Returning false lets the daemon answer from its ordinary container state.

func (*Daemon) SetRestartCount

func (d *Daemon) SetRestartCount(name string, count int)

SetRestartCount scripts Docker's restart-policy counter for a container, what `inspect -f {{.RestartCount}}` answers.

func (*Daemon) SetRunning

func (d *Daemon) SetRunning(name string, running bool)

Jump to

Keyboard shortcuts

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