소스 검색

pkg/system: move IsWindowsClient to pkg/parsers/operatingsystem

This function was only used in a single place, and pkg/parsers/operatingsystem
already copied the `verNTWorkstation` const, so we might as well move this function
there as well to "unclutter" pkg/system.

The function had no external users, so not adding an alias / stub.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Sebastiaan van Stijn 3 년 전
부모
커밋
9bf40d7edd
3개의 변경된 파일8개의 추가작업 그리고 15개의 파일을 삭제
  1. 2 1
      daemon/daemon_windows.go
  2. 6 0
      pkg/parsers/operatingsystem/operatingsystem_windows.go
  3. 0 14
      pkg/system/syscall_windows.go

+ 2 - 1
daemon/daemon_windows.go

@@ -25,6 +25,7 @@ import (
 	"github.com/docker/docker/pkg/containerfs"
 	"github.com/docker/docker/pkg/containerfs"
 	"github.com/docker/docker/pkg/idtools"
 	"github.com/docker/docker/pkg/idtools"
 	"github.com/docker/docker/pkg/parsers"
 	"github.com/docker/docker/pkg/parsers"
+	"github.com/docker/docker/pkg/parsers/operatingsystem"
 	"github.com/docker/docker/pkg/platform"
 	"github.com/docker/docker/pkg/platform"
 	"github.com/docker/docker/pkg/sysinfo"
 	"github.com/docker/docker/pkg/sysinfo"
 	"github.com/docker/docker/pkg/system"
 	"github.com/docker/docker/pkg/system"
@@ -553,7 +554,7 @@ func (daemon *Daemon) setDefaultIsolation() error {
 	// On client SKUs, default to Hyper-V. @engine maintainers. This
 	// On client SKUs, default to Hyper-V. @engine maintainers. This
 	// should not be removed. Ping Microsoft folks is there are PRs to
 	// should not be removed. Ping Microsoft folks is there are PRs to
 	// to change this.
 	// to change this.
-	if system.IsWindowsClient() {
+	if operatingsystem.IsWindowsClient() {
 		daemon.defaultIsolation = containertypes.IsolationHyperV
 		daemon.defaultIsolation = containertypes.IsolationHyperV
 	} else {
 	} else {
 		daemon.defaultIsolation = containertypes.IsolationProcess
 		daemon.defaultIsolation = containertypes.IsolationProcess

+ 6 - 0
pkg/parsers/operatingsystem/operatingsystem_windows.go

@@ -62,3 +62,9 @@ func GetOperatingSystemVersion() (string, error) {
 func IsContainerized() (bool, error) {
 func IsContainerized() (bool, error) {
 	return false, nil
 	return false, nil
 }
 }
+
+// IsWindowsClient returns true if the SKU is client. It returns false on
+// Windows server.
+func IsWindowsClient() bool {
+	return windows.RtlGetVersion().ProductType == verNTWorkstation
+}

+ 0 - 14
pkg/system/syscall_windows.go

@@ -1,14 +0,0 @@
-package system // import "github.com/docker/docker/pkg/system"
-
-import "golang.org/x/sys/windows"
-
-// VER_NT_WORKSTATION, see https://docs.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-osversioninfoexa
-const verNTWorkstation = 0x00000001 // VER_NT_WORKSTATION
-
-// IsWindowsClient returns true if the SKU is client. It returns false on
-// Windows server, or if an error occurred when making the GetVersionExW
-// syscall.
-func IsWindowsClient() bool {
-	ver := windows.RtlGetVersion()
-	return ver != nil && ver.ProductType == verNTWorkstation
-}