Files
docker-cli/components/engine/cli/internal/test/builders/swarm.go
Vincent Demeester f6ad06ceb6 Add some unit tests to the node and swarm cli code
Start work on adding unit tests to our cli code in order to have to
write less costly integration test.

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
Upstream-commit: f151c297eb268e22dc1eb36ded0e356885f40739
Component: engine
2017-01-09 18:30:15 +01:00

40 lines
835 B
Go

package builders
import (
"time"
"github.com/docker/docker/api/types/swarm"
)
// Swarm creates a swarm with default values.
// Any number of swarm function builder can be pass to augment it.
func Swarm(swarmBuilders ...func(*swarm.Swarm)) *swarm.Swarm {
t1 := time.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC)
swarm := &swarm.Swarm{
ClusterInfo: swarm.ClusterInfo{
ID: "swarm",
Meta: swarm.Meta{
CreatedAt: t1,
},
Spec: swarm.Spec{},
},
JoinTokens: swarm.JoinTokens{
Worker: "worker-join-token",
Manager: "manager-join-token",
},
}
for _, builder := range swarmBuilders {
builder(swarm)
}
return swarm
}
// Autolock set the swarm into autolock mode
func Autolock() func(*swarm.Swarm) {
return func(swarm *swarm.Swarm) {
swarm.Spec.EncryptionConfig.AutoLockManagers = true
}
}