From 10829dd2221fdf8c5fe8610ff257f9a910068ba4 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Tue, 12 Jul 2022 12:40:46 +0200 Subject: [PATCH] daemon: NewDaemon(): fail early on non-supported platforms Signed-off-by: Sebastiaan van Stijn --- daemon/daemon.go | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/daemon/daemon.go b/daemon/daemon.go index 2cab235947..470ec60428 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -68,10 +68,6 @@ import ( "google.golang.org/grpc/credentials/insecure" ) -var ( - errSystemNotSupported = errors.New("the Docker daemon is not supported on this platform") -) - // Daemon holds information about the Docker daemon. type Daemon struct { id string @@ -711,6 +707,11 @@ func (daemon *Daemon) IsSwarmCompatible() error { // NewDaemon sets up everything for the daemon to be able to service // requests from the webserver. func NewDaemon(ctx context.Context, config *config.Config, pluginStore *plugin.Store) (daemon *Daemon, err error) { + // Verify the platform is supported as a daemon + if !platformSupported { + return nil, errors.New("the Docker daemon is not supported on this platform") + } + registryService, err := registry.NewService(config.ServiceOptions) if err != nil { return nil, err @@ -732,11 +733,6 @@ func NewDaemon(ctx context.Context, config *config.Config, pluginStore *plugin.S // Setup the resolv.conf setupResolvConf(config) - // Verify the platform is supported as a daemon - if !platformSupported { - return nil, errSystemNotSupported - } - // Validate platform-specific requirements if err := checkSystem(); err != nil { return nil, err