|
@@ -2,8 +2,11 @@ package daemon
|
|
|
|
|
|
import "github.com/docker/docker/testutil/environment"
|
|
import "github.com/docker/docker/testutil/environment"
|
|
|
|
|
|
|
|
+// Option is used to configure a daemon.
|
|
|
|
+type Option func(*Daemon)
|
|
|
|
+
|
|
// WithDefaultCgroupNamespaceMode sets the default cgroup namespace mode for the daemon
|
|
// WithDefaultCgroupNamespaceMode sets the default cgroup namespace mode for the daemon
|
|
-func WithDefaultCgroupNamespaceMode(mode string) func(*Daemon) {
|
|
|
|
|
|
+func WithDefaultCgroupNamespaceMode(mode string) Option {
|
|
return func(d *Daemon) {
|
|
return func(d *Daemon) {
|
|
d.defaultCgroupNamespaceMode = mode
|
|
d.defaultCgroupNamespaceMode = mode
|
|
}
|
|
}
|
|
@@ -21,49 +24,49 @@ func WithInit(d *Daemon) {
|
|
}
|
|
}
|
|
|
|
|
|
// WithDockerdBinary sets the dockerd binary to the specified one
|
|
// WithDockerdBinary sets the dockerd binary to the specified one
|
|
-func WithDockerdBinary(dockerdBinary string) func(*Daemon) {
|
|
|
|
|
|
+func WithDockerdBinary(dockerdBinary string) Option {
|
|
return func(d *Daemon) {
|
|
return func(d *Daemon) {
|
|
d.dockerdBinary = dockerdBinary
|
|
d.dockerdBinary = dockerdBinary
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
// WithSwarmPort sets the swarm port to use for swarm mode
|
|
// WithSwarmPort sets the swarm port to use for swarm mode
|
|
-func WithSwarmPort(port int) func(*Daemon) {
|
|
|
|
|
|
+func WithSwarmPort(port int) Option {
|
|
return func(d *Daemon) {
|
|
return func(d *Daemon) {
|
|
d.SwarmPort = port
|
|
d.SwarmPort = port
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
// WithSwarmListenAddr sets the swarm listen addr to use for swarm mode
|
|
// WithSwarmListenAddr sets the swarm listen addr to use for swarm mode
|
|
-func WithSwarmListenAddr(listenAddr string) func(*Daemon) {
|
|
|
|
|
|
+func WithSwarmListenAddr(listenAddr string) Option {
|
|
return func(d *Daemon) {
|
|
return func(d *Daemon) {
|
|
d.swarmListenAddr = listenAddr
|
|
d.swarmListenAddr = listenAddr
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
// WithSwarmDefaultAddrPool sets the swarm default address pool to use for swarm mode
|
|
// WithSwarmDefaultAddrPool sets the swarm default address pool to use for swarm mode
|
|
-func WithSwarmDefaultAddrPool(defaultAddrPool []string) func(*Daemon) {
|
|
|
|
|
|
+func WithSwarmDefaultAddrPool(defaultAddrPool []string) Option {
|
|
return func(d *Daemon) {
|
|
return func(d *Daemon) {
|
|
d.DefaultAddrPool = defaultAddrPool
|
|
d.DefaultAddrPool = defaultAddrPool
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
// WithSwarmDefaultAddrPoolSubnetSize sets the subnet length mask of swarm default address pool to use for swarm mode
|
|
// WithSwarmDefaultAddrPoolSubnetSize sets the subnet length mask of swarm default address pool to use for swarm mode
|
|
-func WithSwarmDefaultAddrPoolSubnetSize(subnetSize uint32) func(*Daemon) {
|
|
|
|
|
|
+func WithSwarmDefaultAddrPoolSubnetSize(subnetSize uint32) Option {
|
|
return func(d *Daemon) {
|
|
return func(d *Daemon) {
|
|
d.SubnetSize = subnetSize
|
|
d.SubnetSize = subnetSize
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
// WithSwarmDataPathPort sets the swarm datapath port to use for swarm mode
|
|
// WithSwarmDataPathPort sets the swarm datapath port to use for swarm mode
|
|
-func WithSwarmDataPathPort(datapathPort uint32) func(*Daemon) {
|
|
|
|
|
|
+func WithSwarmDataPathPort(datapathPort uint32) Option {
|
|
return func(d *Daemon) {
|
|
return func(d *Daemon) {
|
|
d.DataPathPort = datapathPort
|
|
d.DataPathPort = datapathPort
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
// WithEnvironment sets options from testutil/environment.Execution struct
|
|
// WithEnvironment sets options from testutil/environment.Execution struct
|
|
-func WithEnvironment(e environment.Execution) func(*Daemon) {
|
|
|
|
|
|
+func WithEnvironment(e environment.Execution) Option {
|
|
return func(d *Daemon) {
|
|
return func(d *Daemon) {
|
|
if e.DaemonInfo.ExperimentalBuild {
|
|
if e.DaemonInfo.ExperimentalBuild {
|
|
d.experimental = true
|
|
d.experimental = true
|