瀏覽代碼

Merge pull request #14559 from Microsoft/10662-todo1

Windows: Move daemon check back centrally
Arnaud Porterie 10 年之前
父節點
當前提交
b0da494aa3
共有 3 個文件被更改,包括 9 次插入18 次删除
  1. 7 3
      daemon/daemon.go
  2. 1 7
      daemon/daemon_unix.go
  3. 1 8
      daemon/daemon_windows.go

+ 7 - 3
daemon/daemon.go

@@ -43,8 +43,7 @@ var (
 	validContainerNameChars   = `[a-zA-Z0-9][a-zA-Z0-9_.-]`
 	validContainerNameChars   = `[a-zA-Z0-9][a-zA-Z0-9_.-]`
 	validContainerNamePattern = regexp.MustCompile(`^/?` + validContainerNameChars + `+$`)
 	validContainerNamePattern = regexp.MustCompile(`^/?` + validContainerNameChars + `+$`)
 
 
-	// TODO Windows. Change this once daemon is up and running.
-	ErrSystemNotSupported = errors.New("The Docker daemon is only supported on linux")
+	ErrSystemNotSupported = errors.New("The Docker daemon is not supported on this platform.")
 )
 )
 
 
 type contStore struct {
 type contStore struct {
@@ -562,7 +561,12 @@ func NewDaemon(config *Config, registryService *registry.Service) (daemon *Daemo
 	// Do we have a disabled network?
 	// Do we have a disabled network?
 	config.DisableBridge = isBridgeNetworkDisabled(config)
 	config.DisableBridge = isBridgeNetworkDisabled(config)
 
 
-	// Check that the system is supported and we have sufficient privileges
+	// Verify the platform is supported as a daemon
+	if runtime.GOOS != "linux" && runtime.GOOS != "windows" {
+		return nil, ErrSystemNotSupported
+	}
+
+	// Validate platform-specific requirements
 	if err := checkSystem(); err != nil {
 	if err := checkSystem(); err != nil {
 		return nil, err
 		return nil, err
 	}
 	}

+ 1 - 7
daemon/daemon_unix.go

@@ -8,7 +8,6 @@ import (
 	"net/http"
 	"net/http"
 	"os"
 	"os"
 	"path/filepath"
 	"path/filepath"
-	"runtime"
 	"strings"
 	"strings"
 	"syscall"
 	"syscall"
 
 
@@ -197,13 +196,8 @@ func checkConfigOptions(config *Config) error {
 	return nil
 	return nil
 }
 }
 
 
-// checkSystem validates the system is supported and we have sufficient privileges
+// checkSystem validates platform-specific requirements
 func checkSystem() error {
 func checkSystem() error {
-	// TODO Windows. Once daemon is running on Windows, move this code back to
-	// NewDaemon() in daemon.go, and extend the check to support Windows.
-	if runtime.GOOS != "linux" {
-		return ErrSystemNotSupported
-	}
 	if os.Geteuid() != 0 {
 	if os.Geteuid() != 0 {
 		return fmt.Errorf("The Docker daemon needs to be run as root")
 		return fmt.Errorf("The Docker daemon needs to be run as root")
 	}
 	}

+ 1 - 8
daemon/daemon_windows.go

@@ -3,7 +3,6 @@ package daemon
 import (
 import (
 	"fmt"
 	"fmt"
 	"os"
 	"os"
-	"runtime"
 	"syscall"
 	"syscall"
 
 
 	"github.com/Sirupsen/logrus"
 	"github.com/Sirupsen/logrus"
@@ -82,16 +81,10 @@ func checkConfigOptions(config *Config) error {
 	return nil
 	return nil
 }
 }
 
 
-// checkSystem validates the system is supported and we have sufficient privileges
+// checkSystem validates platform-specific requirements
 func checkSystem() error {
 func checkSystem() error {
 	var dwVersion uint32
 	var dwVersion uint32
 
 
-	// TODO Windows. Once daemon is running on Windows, move this code back to
-	// NewDaemon() in daemon.go, and extend the check to support Windows.
-	if runtime.GOOS != "linux" && runtime.GOOS != "windows" {
-		return ErrSystemNotSupported
-	}
-
 	// TODO Windows. May need at some point to ensure have elevation and
 	// TODO Windows. May need at some point to ensure have elevation and
 	// possibly LocalSystem.
 	// possibly LocalSystem.