package builders
import "github.com/docker/cli/internal/test/builders"
Package builders helps you create struct for your unit test while keeping them expressive.
Index ¶
- func Autolock() func(*swarm.Swarm)
- func Config(builders ...func(config *swarm.Config)) *swarm.Config
- func ConfigCreatedAt(t time.Time) func(*swarm.Config)
- func ConfigData(data []byte) func(*swarm.Config)
- func ConfigID(id string) func(config *swarm.Config)
- func ConfigLabels(labels map[string]string) func(config *swarm.Config)
- func ConfigName(name string) func(config *swarm.Config)
- func ConfigUpdatedAt(t time.Time) func(*swarm.Config)
- func ConfigVersion(v swarm.Version) func(*swarm.Config)
- func Container(name string, builders ...func(c *container.Summary)) *container.Summary
- func EngineVersion(version string) func(*swarm.Node)
- func GlobalService() func(*swarm.Service)
- func Hostname(hostname string) func(*swarm.Node)
- func IP(ip string) func(*container.Port)
- func Leader() func(*swarm.ManagerStatus)
- func Manager(managerStatusBuilders ...func(*swarm.ManagerStatus)) func(*swarm.Node)
- func ManagerStatus(managerStatusBuilders ...func(*swarm.ManagerStatus)) *swarm.ManagerStatus
- func NetworkResource(builders ...func(resource *network.Summary)) *network.Summary
- func NetworkResourceDriver(name string) func(networkResource *network.Summary)
- func NetworkResourceID(id string) func(networkResource *network.Summary)
- func NetworkResourceName(name string) func(networkResource *network.Summary)
- func NetworkResourceScope(scope string) func(networkResource *network.Summary)
- func Node(builders ...func(*swarm.Node)) *swarm.Node
- func NodeID(id string) func(*swarm.Node)
- func NodeLabels(labels map[string]string) func(*swarm.Node)
- func NodeName(name string) func(*swarm.Node)
- func PortStatus(portConfigs []swarm.PortConfig) func(*swarm.TaskStatus)
- func ReplicatedService(replicas uint64) func(*swarm.Service)
- func Secret(builders ...func(secret *swarm.Secret)) *swarm.Secret
- func SecretCreatedAt(t time.Time) func(*swarm.Secret)
- func SecretDriver(driver string) func(secret *swarm.Secret)
- func SecretID(id string) func(secret *swarm.Secret)
- func SecretLabels(labels map[string]string) func(secret *swarm.Secret)
- func SecretName(name string) func(secret *swarm.Secret)
- func SecretUpdatedAt(t time.Time) func(*swarm.Secret)
- func SecretVersion(v swarm.Version) func(*swarm.Secret)
- func Service(builders ...func(*swarm.Service)) *swarm.Service
- func ServiceID(id string) func(*swarm.Service)
- func ServiceImage(image string) func(*swarm.Service)
- func ServiceLabels(labels map[string]string) func(*swarm.Service)
- func ServiceName(name string) func(*swarm.Service)
- func ServicePort(port swarm.PortConfig) func(*swarm.Service)
- func ServiceStatus(desired, running uint64) func(*swarm.Service)
- func StatusErr(err string) func(*swarm.TaskStatus)
- func Swarm(swarmBuilders ...func(*swarm.Swarm)) *swarm.Swarm
- func TCP(p *container.Port)
- func Task(taskBuilders ...func(*swarm.Task)) *swarm.Task
- func TaskDesiredState(state swarm.TaskState) func(*swarm.Task)
- func TaskID(id string) func(*swarm.Task)
- func TaskImage(image string) func(*swarm.TaskSpec)
- func TaskName(name string) func(*swarm.Task)
- func TaskNodeID(id string) func(*swarm.Task)
- func TaskServiceID(id string) func(*swarm.Task)
- func TaskSlot(slot int) func(*swarm.Task)
- func TaskSpec(specBuilders ...func(*swarm.TaskSpec)) *swarm.TaskSpec
- func TaskState(state swarm.TaskState) func(*swarm.TaskStatus)
- func TaskStatus(statusBuilders ...func(*swarm.TaskStatus)) *swarm.TaskStatus
- func Timestamp(t time.Time) func(*swarm.TaskStatus)
- func UDP(p *container.Port)
- func Volume(builders ...func(vol *volume.Volume)) *volume.Volume
- func VolumeDriver(name string) func(vol *volume.Volume)
- func VolumeLabels(labels map[string]string) func(vol *volume.Volume)
- func VolumeName(name string) func(vol *volume.Volume)
- func WithLabel(key, value string) func(*container.Summary)
- func WithName(name string) func(*container.Summary)
- func WithPort(privatePort, publicPort uint16, builders ...func(*container.Port)) func(*container.Summary)
- func WithSize(size int64) func(*container.Summary)
- func WithStatus(statusBuilders ...func(*swarm.TaskStatus)) func(*swarm.Task)
- func WithTaskSpec(specBuilders ...func(*swarm.TaskSpec)) func(*swarm.Task)
Functions ¶
func Autolock ¶
Autolock set the swarm into autolock mode
func Config ¶
Config creates a config with default values. Any number of config builder functions can be passed to augment it.
func ConfigCreatedAt ¶
ConfigCreatedAt sets the creation time for the config
func ConfigData ¶
ConfigData sets the config payload.
func ConfigID ¶
ConfigID sets the config's ID
func ConfigLabels ¶
ConfigLabels sets the config's labels
func ConfigName ¶
ConfigName sets the config's name
func ConfigUpdatedAt ¶
ConfigUpdatedAt sets the update time for the config
func ConfigVersion ¶
ConfigVersion sets the version for the config
func Container ¶
Container creates a container with default values. Any number of container function builder can be passed to augment it.
func EngineVersion ¶
EngineVersion sets the node's engine version
func GlobalService ¶
GlobalService sets the service to use "global" mode
func Hostname ¶
Hostname sets the node hostname
func IP ¶
IP sets the ip of the port
func Leader ¶
func Leader() func(*swarm.ManagerStatus)
Leader sets the current node as a leader
func Manager ¶
func Manager(managerStatusBuilders ...func(*swarm.ManagerStatus)) func(*swarm.Node)
Manager set the current node as a manager
func ManagerStatus ¶
func ManagerStatus(managerStatusBuilders ...func(*swarm.ManagerStatus)) *swarm.ManagerStatus
ManagerStatus create a ManageStatus with default values.
func NetworkResource ¶
NetworkResource creates a network resource with default values. Any number of networkResource function builder can be pass to modify the existing value. feel free to add another builder func if you need to override another value
func NetworkResourceDriver ¶
NetworkResourceDriver sets the driver of the resource network
func NetworkResourceID ¶
NetworkResourceID sets the ID of the resource network
func NetworkResourceName ¶
NetworkResourceName sets the name of the resource network
func NetworkResourceScope ¶
NetworkResourceScope sets the Scope of the resource network
func Node ¶
Node creates a node with default values. Any number of node function builder can be pass to augment it.
n1 := Node() // Returns a default node n2 := Node(NodeID("foo"), NodeHostname("bar"), Leader())
func NodeID ¶
NodeID sets the node id
func NodeLabels ¶
NodeLabels sets the node labels
func NodeName ¶
NodeName sets the node name
func PortStatus ¶
func PortStatus(portConfigs []swarm.PortConfig) func(*swarm.TaskStatus)
PortStatus sets the tasks port config status FIXME(vdemeester) should be a sub builder 👼
func ReplicatedService ¶
ReplicatedService sets the service to use "replicated" mode with the specified number of replicas
func Secret ¶
Secret creates a secret with default values. Any number of secret builder functions can be passed to augment it.
func SecretCreatedAt ¶
SecretCreatedAt sets the creation time for the secret
func SecretDriver ¶
SecretDriver sets the secret's driver name
func SecretID ¶
SecretID sets the secret's ID
func SecretLabels ¶
SecretLabels sets the secret's labels
func SecretName ¶
SecretName sets the secret's name
func SecretUpdatedAt ¶
SecretUpdatedAt sets the update time for the secret
func SecretVersion ¶
SecretVersion sets the version for the secret
func Service ¶
Service creates a service with default values. Any number of service builder functions can be passed to augment it.
func ServiceID ¶
ServiceID sets the service ID
func ServiceImage ¶
ServiceImage sets the service's image
func ServiceLabels ¶
ServiceLabels sets the service's labels
func ServiceName ¶
ServiceName sets the service name
func ServicePort ¶
func ServicePort(port swarm.PortConfig) func(*swarm.Service)
ServicePort sets the service's port
func ServiceStatus ¶
ServiceStatus sets the services' ServiceStatus (API v1.41 and above)
func StatusErr ¶
func StatusErr(err string) func(*swarm.TaskStatus)
StatusErr sets the tasks status error
func Swarm ¶
Swarm creates a swarm with default values. Any number of swarm function builder can be pass to augment it.
func TCP ¶
TCP sets the port to tcp
func Task ¶
Task creates a task with default values . Any number of task function builder can be pass to augment it.
func TaskDesiredState ¶
TaskDesiredState sets the task's desired state
func TaskID ¶
TaskID sets the task ID
func TaskImage ¶
TaskImage sets the task's image
func TaskName ¶
TaskName sets the task name
func TaskNodeID ¶
TaskNodeID sets the task's node id
func TaskServiceID ¶
TaskServiceID sets the task service's ID
func TaskSlot ¶
TaskSlot sets the task's slot
func TaskSpec ¶
TaskSpec creates a task spec with default values . Any number of taskSpec function builder can be pass to augment it.
func TaskState ¶
func TaskState(state swarm.TaskState) func(*swarm.TaskStatus)
TaskState sets the task's current state
func TaskStatus ¶
func TaskStatus(statusBuilders ...func(*swarm.TaskStatus)) *swarm.TaskStatus
TaskStatus creates a task status with default values . Any number of taskStatus function builder can be pass to augment it.
func Timestamp ¶
func Timestamp(t time.Time) func(*swarm.TaskStatus)
Timestamp sets the task status timestamp
func UDP ¶
UDP sets the port to udp
func Volume ¶
Volume creates a volume with default values. Any number of volume function builder can be passed to augment it.
func VolumeDriver ¶
VolumeDriver sets the volume driver
func VolumeLabels ¶
VolumeLabels sets the volume labels
func VolumeName ¶
VolumeName sets the volume labels
func WithLabel ¶
WithLabel adds a label to the container
func WithName ¶
WithName adds a name to the container
func WithPort ¶
func WithPort(privatePort, publicPort uint16, builders ...func(*container.Port)) func(*container.Summary)
WithPort adds a port mapping to the container
func WithSize ¶
WithSize adds size in bytes to the container
func WithStatus ¶
func WithStatus(statusBuilders ...func(*swarm.TaskStatus)) func(*swarm.Task)
WithStatus sets the task status
func WithTaskSpec ¶
WithTaskSpec sets the task spec
Source Files ¶
config.go container.go doc.go network.go node.go secret.go service.go swarm.go task.go volume.go
- Version
- v28.1.1+incompatible (latest)
- Published
- Apr 18, 2025
- Platform
- linux/amd64
- Imports
- 5 packages
- Last checked
- 4 hours ago –
Tools for package owners.