Browse Source

Add platformSupported flag to enable daemon mode by platform.

Signed-off-by: David Calavera <david.calavera@gmail.com>
David Calavera 10 years ago
parent
commit
10d30c6457
4 changed files with 12 additions and 3 deletions
  1. 1 1
      daemon/daemon.go
  2. 2 1
      daemon/daemon_unix.go
  3. 5 0
      daemon/daemon_unsupported.go
  4. 4 1
      daemon/daemon_windows.go

+ 1 - 1
daemon/daemon.go

@@ -557,7 +557,7 @@ func NewDaemon(config *Config, registryService *registry.Service) (daemon *Daemo
 	config.DisableBridge = isBridgeNetworkDisabled(config)
 
 	// Verify the platform is supported as a daemon
-	if runtime.GOOS != "linux" && runtime.GOOS != "windows" {
+	if !platformSupported {
 		return nil, ErrSystemNotSupported
 	}
 

+ 2 - 1
daemon/daemon_unix.go

@@ -1,4 +1,4 @@
-// +build !windows
+// +build linux freebsd
 
 package daemon
 
@@ -36,6 +36,7 @@ const (
 	// See https://git.kernel.org/cgit/linux/kernel/git/tip/tip.git/tree/kernel/sched/sched.h?id=8cd9234c64c584432f6992fe944ca9e46ca8ea76#n269
 	linuxMinCPUShares = 2
 	linuxMaxCPUShares = 262144
+	platformSupported = true
 )
 
 func (daemon *Daemon) Changes(container *Container) ([]archive.Change, error) {

+ 5 - 0
daemon/daemon_unsupported.go

@@ -0,0 +1,5 @@
+// +build !linux,!freebsd,!windows
+
+package daemon
+
+const platformSupported = false

+ 4 - 1
daemon/daemon_windows.go

@@ -15,7 +15,10 @@ import (
 	"github.com/microsoft/hcsshim"
 )
 
-const DefaultVirtualSwitch = "Virtual Switch"
+const (
+	DefaultVirtualSwitch = "Virtual Switch"
+	platformSupported    = true
+)
 
 func (daemon *Daemon) Changes(container *Container) ([]archive.Change, error) {
 	return daemon.driver.Changes(container.ID, container.ImageID)