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 ¶
- func ContainerID(name string) string
- func ImageID(ref string) string
- func StorageContainer(args []string) map[string]any
- type Daemon
- func (d *Daemon) Close()
- func (d *Daemon) Commands() [][]string
- func (d *Daemon) Configs() []string
- func (d *Daemon) IsDiskRead(args []string) bool
- func (d *Daemon) Limits(name string) (memory, nanoCPUs int64)
- func (d *Daemon) Matching(prefix string) [][]string
- func (d *Daemon) PublishPorts()
- func (d *Daemon) ResetCommands()
- func (d *Daemon) Run(_ context.Context, _ string, req docker.Command) ([]byte, error)
- func (d *Daemon) Running(name string) bool
- func (d *Daemon) SetCommandReply(reply func(docker.Command) ([]byte, error, bool))
- func (d *Daemon) SetDisk(totalBytes, freeBytes int64)
- func (d *Daemon) SetExitCode(name string, code int)
- func (d *Daemon) SetHostInfo(memoryBytes int64, cpus int, dataRoot string)
- func (d *Daemon) SetOOMKilled(name string, killed bool)
- func (d *Daemon) SetPort(port int)
- func (d *Daemon) SetReply(reply func([]string) ([]byte, error, bool))
- func (d *Daemon) SetRestartCount(name string, count int)
- func (d *Daemon) SetResults(answers func(containerresulttest.Command) (containerresulttest.Answer, bool))
- func (d *Daemon) SetRunning(name string, running bool)
- func (d *Daemon) SetStorageContainer(name, image, volume, path string)
- func (d *Daemon) SetVolume(name string, exists bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContainerID ¶
ContainerID is the ID the fake printed for the container it made under name.
func StorageContainer ¶
StorageContainer is the image/mount observation of a recorded docker run.
Types ¶
type Daemon ¶
type Daemon struct {
// contains filtered or unexported fields
}
func (*Daemon) Configs ¶
Configs are the client configuration each command named, in order ("" is the ambient one).
func (*Daemon) IsDiskRead ¶
IsDiskRead identifies this daemon's disk commands, including completed reads.
func (*Daemon) Limits ¶
Limits is the memory and NanoCPUs the daemon holds a container to, as its runs and updates set them (0: no limit).
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) SetCommandReply ¶
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 ¶
SetDisk scripts what df says of the data folder's filesystem (100 GiB with 90 GiB free unless set).
func (*Daemon) SetExitCode ¶
SetExitCode scripts the container's last exit code.
func (*Daemon) SetHostInfo ¶
SetHostInfo scripts what docker info says the daemon can give containers (8 GiB and 8 CPUs unless set).
func (*Daemon) SetOOMKilled ¶
SetOOMKilled scripts whether the container's last exit was an out-of-memory kill, what its inspected state says.
func (*Daemon) SetRestartCount ¶
SetRestartCount scripts Docker's restart-policy counter for a container, what `inspect -f {{.RestartCount}}` answers.
func (*Daemon) SetResults ¶
func (d *Daemon) SetResults(answers func(containerresulttest.Command) (containerresulttest.Answer, bool))
SetReply scripts a daemon response after recording the command. Returning false lets the daemon answer from its ordinary container state. SetResults answers result reads (containerresult.Run and Exec) as answers says, before anything else this daemon does; ok false leaves a call to the rest. The containers keep their stdout to themselves, as a daemon that lost it would.
func (*Daemon) SetRunning ¶
func (*Daemon) SetStorageContainer ¶
SetStorageContainer supplies a fixture's observed engine and named data mount. SetRunning alone does not invent compatibility evidence for retained data.