From 690a6fddf9564c4947e50302bd18f0005f0e3e94 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Sat, 2 Apr 2022 17:43:50 +0200 Subject: [PATCH] daemon: move default namespaces to daemon/config Keeping the defaults in a single location, which also reduces the list of imports needed. Signed-off-by: Sebastiaan van Stijn --- cmd/dockerd/config.go | 6 ++---- daemon/config/config.go | 4 ++++ daemon/daemon.go | 5 ----- plugin/executor/containerd/containerd.go | 3 --- 4 files changed, 6 insertions(+), 12 deletions(-) diff --git a/cmd/dockerd/config.go b/cmd/dockerd/config.go index 0f1dff4b8e..bc59e92812 100644 --- a/cmd/dockerd/config.go +++ b/cmd/dockerd/config.go @@ -3,10 +3,8 @@ package main import ( "runtime" - "github.com/docker/docker/daemon" "github.com/docker/docker/daemon/config" "github.com/docker/docker/opts" - "github.com/docker/docker/plugin/executor/containerd" "github.com/docker/docker/registry" "github.com/spf13/pflag" ) @@ -96,8 +94,8 @@ func installCommonConfigFlags(conf *config.Config, flags *pflag.FlagSet) error { conf.MaxConcurrentUploads = &maxConcurrentUploads conf.MaxDownloadAttempts = &maxDownloadAttempts - flags.StringVar(&conf.ContainerdNamespace, "containerd-namespace", daemon.ContainersNamespace, "Containerd namespace to use") - flags.StringVar(&conf.ContainerdPluginNamespace, "containerd-plugins-namespace", containerd.PluginNamespace, "Containerd namespace to use for plugins") + flags.StringVar(&conf.ContainerdNamespace, "containerd-namespace", config.DefaultContainersNamespace, "Containerd namespace to use") + flags.StringVar(&conf.ContainerdPluginNamespace, "containerd-plugins-namespace", config.DefaultPluginNamespace, "Containerd namespace to use for plugins") flags.StringVar(&conf.DefaultRuntime, "default-runtime", config.StockRuntimeName, "Default OCI runtime for containers") diff --git a/daemon/config/config.go b/daemon/config/config.go index 0f4db6d15c..81922d48d4 100644 --- a/daemon/config/config.go +++ b/daemon/config/config.go @@ -43,6 +43,10 @@ const ( // DefaultRuntimeBinary is the default runtime to be used by // containerd if none is specified DefaultRuntimeBinary = "runc" + // DefaultContainersNamespace is the name of the default containerd namespace used for users containers. + DefaultContainersNamespace = "moby" + // DefaultPluginNamespace is the name of the default containerd namespace used for plugins. + DefaultPluginNamespace = "plugins.moby" // LinuxV1RuntimeName is the runtime used to specify the containerd v1 shim with the runc binary // Note this is different than io.containerd.runc.v1 which would be the v1 shim using the v2 shim API. diff --git a/daemon/daemon.go b/daemon/daemon.go index cdcb6e555b..2a04e33a13 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -69,11 +69,6 @@ import ( "google.golang.org/grpc/credentials/insecure" ) -// ContainersNamespace is the name of the namespace used for users containers -const ( - ContainersNamespace = "moby" -) - var ( errSystemNotSupported = errors.New("the Docker daemon is not supported on this platform") ) diff --git a/plugin/executor/containerd/containerd.go b/plugin/executor/containerd/containerd.go index 8354745990..0daf8afda6 100644 --- a/plugin/executor/containerd/containerd.go +++ b/plugin/executor/containerd/containerd.go @@ -16,9 +16,6 @@ import ( "github.com/sirupsen/logrus" ) -// PluginNamespace is the name used for the plugins namespace -const PluginNamespace = "plugins.moby" - // ExitHandler represents an object that is called when the exit event is received from containerd type ExitHandler interface { HandleExitEvent(id string) error