1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
package builders
import (
"time"
"github.com/docker/docker/api/types/swarm"
)
// Config creates a config with default values.
// Any number of config builder functions can be passed to augment it.
func Config(builders ...func(config *swarm.Config)) *swarm.Config {
config := &swarm.Config{}
for _, builder := range builders {
builder(config)
}
return config
}
// ConfigLabels sets the config's labels
func ConfigLabels(labels map[string]string) func(config *swarm.Config) {
return func(config *swarm.Config) {
config.Spec.Labels = labels
}
}
// ConfigName sets the config's name
func ConfigName(name string) func(config *swarm.Config) {
return func(config *swarm.Config) {
config.Spec.Name = name
}
}
// ConfigID sets the config's ID
func ConfigID(ID string) func(config *swarm.Config) {
return func(config *swarm.Config) {
config.ID = ID
}
}
// ConfigVersion sets the version for the config
func ConfigVersion(v swarm.Version) func(*swarm.Config) {
return func(config *swarm.Config) {
config.Version = v
}
}
// ConfigCreatedAt sets the creation time for the config
func ConfigCreatedAt(t time.Time) func(*swarm.Config) {
return func(config *swarm.Config) {
config.CreatedAt = t
}
}
// ConfigUpdatedAt sets the update time for the config
func ConfigUpdatedAt(t time.Time) func(*swarm.Config) {
return func(config *swarm.Config) {
config.UpdatedAt = t
}
}
// ConfigData sets the config payload.
func ConfigData(data []byte) func(*swarm.Config) {
return func(config *swarm.Config) {
config.Spec.Data = data
}
}
|