2016-12-25 16:23:35 -05:00
|
|
|
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)
|
2023-11-20 11:38:50 -05:00
|
|
|
s := &swarm.Swarm{
|
2016-12-25 16:23:35 -05:00
|
|
|
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 {
|
2023-11-20 11:38:50 -05:00
|
|
|
builder(s)
|
2016-12-25 16:23:35 -05:00
|
|
|
}
|
|
|
|
|
2023-11-20 11:38:50 -05:00
|
|
|
return s
|
2016-12-25 16:23:35 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// Autolock set the swarm into autolock mode
|
|
|
|
func Autolock() func(*swarm.Swarm) {
|
2023-11-20 11:38:50 -05:00
|
|
|
return func(s *swarm.Swarm) {
|
|
|
|
s.Spec.EncryptionConfig.AutoLockManagers = true
|
2016-12-25 16:23:35 -05:00
|
|
|
}
|
|
|
|
}
|