builders

package
v25.0.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package builders helps you create struct for your unit test while keeping them expressive.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Autolock

func Autolock() func(*swarm.Swarm)

Autolock set the swarm into autolock mode

func Config

func Config(builders ...func(config *swarm.Config)) *swarm.Config

Config creates a config with default values. Any number of config builder functions can be passed to augment it.

func ConfigCreatedAt

func ConfigCreatedAt(t time.Time) func(*swarm.Config)

ConfigCreatedAt sets the creation time for the config

func ConfigData

func ConfigData(data []byte) func(*swarm.Config)

ConfigData sets the config payload.

func ConfigID

func ConfigID(id string) func(config *swarm.Config)

ConfigID sets the config's ID

func ConfigLabels

func ConfigLabels(labels map[string]string) func(config *swarm.Config)

ConfigLabels sets the config's labels

func ConfigName

func ConfigName(name string) func(config *swarm.Config)

ConfigName sets the config's name

func ConfigUpdatedAt

func ConfigUpdatedAt(t time.Time) func(*swarm.Config)

ConfigUpdatedAt sets the update time for the config

func ConfigVersion

func ConfigVersion(v swarm.Version) func(*swarm.Config)

ConfigVersion sets the version for the config

func Container

func Container(name string, builders ...func(container *types.Container)) *types.Container

Container creates a container with default values. Any number of container function builder can be passed to augment it.

func EngineVersion

func EngineVersion(version string) func(*swarm.Node)

EngineVersion sets the node's engine version

func GlobalService

func GlobalService() func(*swarm.Service)

GlobalService sets the service to use "global" mode

func Hostname

func Hostname(hostname string) func(*swarm.Node)

Hostname sets the node hostname

func IP

func IP(ip string) func(*types.Port)

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

func NetworkResource(builders ...func(resource *types.NetworkResource)) *types.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

func NetworkResourceDriver(name string) func(networkResource *types.NetworkResource)

NetworkResourceDriver sets the driver of the resource network

func NetworkResourceID

func NetworkResourceID(id string) func(networkResource *types.NetworkResource)

NetworkResourceID sets the ID of the resource network

func NetworkResourceName

func NetworkResourceName(name string) func(networkResource *types.NetworkResource)

NetworkResourceName sets the name of the resource network

func NetworkResourceScope

func NetworkResourceScope(scope string) func(networkResource *types.NetworkResource)

NetworkResourceScope sets the Scope of the resource network

func Node

func Node(builders ...func(*swarm.Node)) *swarm.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

func NodeID(id string) func(*swarm.Node)

NodeID sets the node id

func NodeLabels

func NodeLabels(labels map[string]string) func(*swarm.Node)

NodeLabels sets the node labels

func NodeName

func NodeName(name string) func(*swarm.Node)

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

func ReplicatedService(replicas uint64) func(*swarm.Service)

ReplicatedService sets the service to use "replicated" mode with the specified number of replicas

func Secret

func Secret(builders ...func(secret *swarm.Secret)) *swarm.Secret

Secret creates a secret with default values. Any number of secret builder functions can be passed to augment it.

func SecretCreatedAt

func SecretCreatedAt(t time.Time) func(*swarm.Secret)

SecretCreatedAt sets the creation time for the secret

func SecretDriver

func SecretDriver(driver string) func(secret *swarm.Secret)

SecretDriver sets the secret's driver name

func SecretID

func SecretID(id string) func(secret *swarm.Secret)

SecretID sets the secret's ID

func SecretLabels

func SecretLabels(labels map[string]string) func(secret *swarm.Secret)

SecretLabels sets the secret's labels

func SecretName

func SecretName(name string) func(secret *swarm.Secret)

SecretName sets the secret's name

func SecretUpdatedAt

func SecretUpdatedAt(t time.Time) func(*swarm.Secret)

SecretUpdatedAt sets the update time for the secret

func SecretVersion

func SecretVersion(v swarm.Version) func(*swarm.Secret)

SecretVersion sets the version for the secret

func Service

func Service(builders ...func(*swarm.Service)) *swarm.Service

Service creates a service with default values. Any number of service builder functions can be passed to augment it.

func ServiceID

func ServiceID(id string) func(*swarm.Service)

ServiceID sets the service ID

func ServiceImage

func ServiceImage(image string) func(*swarm.Service)

ServiceImage sets the service's image

func ServiceLabels

func ServiceLabels(labels map[string]string) func(*swarm.Service)

ServiceLabels sets the service's labels

func ServiceName

func ServiceName(name string) func(*swarm.Service)

ServiceName sets the service name

func ServicePort

func ServicePort(port swarm.PortConfig) func(*swarm.Service)

ServicePort sets the service's port

func ServiceStatus

func ServiceStatus(desired, running uint64) func(*swarm.Service)

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

func Swarm(swarmBuilders ...func(*swarm.Swarm)) *swarm.Swarm

Swarm creates a swarm with default values. Any number of swarm function builder can be pass to augment it.

func TCP

func TCP(p *types.Port)

TCP sets the port to tcp

func Task

func Task(taskBuilders ...func(*swarm.Task)) *swarm.Task

Task creates a task with default values . Any number of task function builder can be pass to augment it.

func TaskDesiredState

func TaskDesiredState(state swarm.TaskState) func(*swarm.Task)

TaskDesiredState sets the task's desired state

func TaskID

func TaskID(id string) func(*swarm.Task)

TaskID sets the task ID

func TaskImage

func TaskImage(image string) func(*swarm.TaskSpec)

TaskImage sets the task's image

func TaskName

func TaskName(name string) func(*swarm.Task)

TaskName sets the task name

func TaskNodeID

func TaskNodeID(id string) func(*swarm.Task)

TaskNodeID sets the task's node id

func TaskServiceID

func TaskServiceID(id string) func(*swarm.Task)

TaskServiceID sets the task service's ID

func TaskSlot

func TaskSlot(slot int) func(*swarm.Task)

TaskSlot sets the task's slot

func TaskSpec

func TaskSpec(specBuilders ...func(*swarm.TaskSpec)) *swarm.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

func UDP(p *types.Port)

UDP sets the port to udp

func Volume

func Volume(builders ...func(vol *volume.Volume)) *volume.Volume

Volume creates a volume with default values. Any number of volume function builder can be passed to augment it.

func VolumeDriver

func VolumeDriver(name string) func(vol *volume.Volume)

VolumeDriver sets the volume driver

func VolumeLabels

func VolumeLabels(labels map[string]string) func(vol *volume.Volume)

VolumeLabels sets the volume labels

func VolumeName

func VolumeName(name string) func(vol *volume.Volume)

VolumeName sets the volume labels

func WithLabel

func WithLabel(key, value string) func(*types.Container)

WithLabel adds a label to the container

func WithName

func WithName(name string) func(*types.Container)

WithName adds a name to the container

func WithPort

func WithPort(privateport, publicport uint16, builders ...func(*types.Port)) func(*types.Container)

WithPort adds a port mapping to the container

func WithSize

func WithSize(size int64) func(*types.Container)

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

func WithTaskSpec(specBuilders ...func(*swarm.TaskSpec)) func(*swarm.Task)

WithTaskSpec sets the task spec

Types

This section is empty.

Jump to

Keyboard shortcuts

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