mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #40177 from SamWhited/buildkit_test_options
Add daemon options required by buildkit tests
This commit is contained in:
commit
31abc6c089
2 changed files with 30 additions and 13 deletions
|
@ -39,8 +39,10 @@ type nopLog struct{}
|
||||||
|
|
||||||
func (nopLog) Logf(string, ...interface{}) {}
|
func (nopLog) Logf(string, ...interface{}) {}
|
||||||
|
|
||||||
const defaultDockerdBinary = "dockerd"
|
const (
|
||||||
const containerdSocket = "/var/run/docker/containerd/containerd.sock"
|
defaultDockerdBinary = "dockerd"
|
||||||
|
defaultContainerdSocket = "/var/run/docker/containerd/containerd.sock"
|
||||||
|
)
|
||||||
|
|
||||||
var errDaemonNotStarted = errors.New("daemon not started")
|
var errDaemonNotStarted = errors.New("daemon not started")
|
||||||
|
|
||||||
|
@ -75,6 +77,7 @@ type Daemon struct {
|
||||||
log LogT
|
log LogT
|
||||||
pidFile string
|
pidFile string
|
||||||
args []string
|
args []string
|
||||||
|
containerdSocket string
|
||||||
|
|
||||||
// swarm related field
|
// swarm related field
|
||||||
swarmListenAddr string
|
swarmListenAddr string
|
||||||
|
@ -125,6 +128,7 @@ func NewDaemon(workingDir string, ops ...Option) (*Daemon, error) {
|
||||||
swarmListenAddr: defaultSwarmListenAddr,
|
swarmListenAddr: defaultSwarmListenAddr,
|
||||||
SwarmPort: DefaultSwarmPort,
|
SwarmPort: DefaultSwarmPort,
|
||||||
log: nopLog{},
|
log: nopLog{},
|
||||||
|
containerdSocket: defaultContainerdSocket,
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, op := range ops {
|
for _, op := range ops {
|
||||||
|
@ -252,17 +256,20 @@ func (d *Daemon) StartWithLogFile(out *os.File, providedArgs ...string) error {
|
||||||
d.pidFile = filepath.Join(d.Folder, "docker.pid")
|
d.pidFile = filepath.Join(d.Folder, "docker.pid")
|
||||||
}
|
}
|
||||||
|
|
||||||
d.args = append(d.GlobalFlags,
|
d.args = append(d.GlobalFlags, "--data-root", d.Root)
|
||||||
"--containerd", containerdSocket,
|
if d.containerdSocket != "" {
|
||||||
"--data-root", d.Root,
|
d.args = append(d.args, "--containerd", d.containerdSocket)
|
||||||
|
}
|
||||||
|
d.args = append(d.args,
|
||||||
"--exec-root", d.execRoot,
|
"--exec-root", d.execRoot,
|
||||||
"--pidfile", d.pidFile,
|
"--pidfile", d.pidFile,
|
||||||
fmt.Sprintf("--userland-proxy=%t", d.userlandProxy),
|
fmt.Sprintf("--userland-proxy=%t", d.userlandProxy),
|
||||||
"--containerd-namespace", d.id,
|
"--containerd-namespace", d.id,
|
||||||
"--containerd-plugins-namespace", d.id+"p",
|
"--containerd-plugins-namespace", d.id+"p",
|
||||||
)
|
)
|
||||||
|
|
||||||
if d.defaultCgroupNamespaceMode != "" {
|
if d.defaultCgroupNamespaceMode != "" {
|
||||||
d.args = append(d.args, []string{"--default-cgroupns-mode", d.defaultCgroupNamespaceMode}...)
|
d.args = append(d.args, "--default-cgroupns-mode", d.defaultCgroupNamespaceMode)
|
||||||
}
|
}
|
||||||
if d.experimental {
|
if d.experimental {
|
||||||
d.args = append(d.args, "--experimental")
|
d.args = append(d.args, "--experimental")
|
||||||
|
@ -271,10 +278,10 @@ func (d *Daemon) StartWithLogFile(out *os.File, providedArgs ...string) error {
|
||||||
d.args = append(d.args, "--init")
|
d.args = append(d.args, "--init")
|
||||||
}
|
}
|
||||||
if !(d.UseDefaultHost || d.UseDefaultTLSHost) {
|
if !(d.UseDefaultHost || d.UseDefaultTLSHost) {
|
||||||
d.args = append(d.args, []string{"--host", d.Sock()}...)
|
d.args = append(d.args, "--host", d.Sock())
|
||||||
}
|
}
|
||||||
if root := os.Getenv("DOCKER_REMAP_ROOT"); root != "" {
|
if root := os.Getenv("DOCKER_REMAP_ROOT"); root != "" {
|
||||||
d.args = append(d.args, []string{"--userns-remap", root}...)
|
d.args = append(d.args, "--userns-remap", root)
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we don't explicitly set the log-level or debug flag(-D) then
|
// If we don't explicitly set the log-level or debug flag(-D) then
|
||||||
|
|
|
@ -7,6 +7,16 @@ import (
|
||||||
// Option is used to configure a daemon.
|
// Option is used to configure a daemon.
|
||||||
type Option func(*Daemon)
|
type Option func(*Daemon)
|
||||||
|
|
||||||
|
// WithContainerdSocket sets the --containerd option on the daemon.
|
||||||
|
// Use an empty string to remove the option.
|
||||||
|
//
|
||||||
|
// If unset the --containerd option will be used with a default value.
|
||||||
|
func WithContainerdSocket(socket string) Option {
|
||||||
|
return func(d *Daemon) {
|
||||||
|
d.containerdSocket = socket
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// WithDefaultCgroupNamespaceMode sets the default cgroup namespace mode for the daemon
|
// WithDefaultCgroupNamespaceMode sets the default cgroup namespace mode for the daemon
|
||||||
func WithDefaultCgroupNamespaceMode(mode string) Option {
|
func WithDefaultCgroupNamespaceMode(mode string) Option {
|
||||||
return func(d *Daemon) {
|
return func(d *Daemon) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue