-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request moby#40766 from thaJeztah/lcow_build_tag
LCOW: add "no_lcow" build tag to allow disabling lcow
- Loading branch information
Showing
7 changed files
with
63 additions
and
50 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,48 @@ | ||
// +build windows,!no_lcow | ||
|
||
package system // import "github.com/docker/docker/pkg/system" | ||
|
||
import ( | ||
"runtime" | ||
"strings" | ||
|
||
"github.com/Microsoft/hcsshim/osversion" | ||
specs "github.com/opencontainers/image-spec/specs-go/v1" | ||
"github.com/pkg/errors" | ||
) | ||
|
||
// IsOSSupported determines if an operating system is supported by the host | ||
func IsOSSupported(os string) bool { | ||
if strings.EqualFold(runtime.GOOS, os) { | ||
return true | ||
} | ||
if LCOWSupported() && strings.EqualFold(os, "linux") { | ||
return true | ||
var ( | ||
// lcowSupported determines if Linux Containers on Windows are supported. | ||
lcowSupported = false | ||
) | ||
|
||
// InitLCOW sets whether LCOW is supported or not. Requires RS5+ | ||
func InitLCOW(experimental bool) { | ||
if experimental && osversion.Build() >= osversion.RS5 { | ||
lcowSupported = true | ||
} | ||
return false | ||
} | ||
|
||
func LCOWSupported() bool { | ||
return lcowSupported | ||
} | ||
|
||
// ValidatePlatform determines if a platform structure is valid. | ||
// TODO This is a temporary windows-only function, should be replaced by | ||
// comparison of worker capabilities | ||
func ValidatePlatform(platform specs.Platform) error { | ||
if runtime.GOOS == "windows" { | ||
if !(platform.OS == runtime.GOOS || (LCOWSupported() && platform.OS == "linux")) { | ||
return errors.Errorf("unsupported os %s", platform.OS) | ||
} | ||
if !IsOSSupported(platform.OS) { | ||
return errors.Errorf("unsupported os %s", platform.OS) | ||
} | ||
return nil | ||
} | ||
|
||
// IsOSSupported determines if an operating system is supported by the host | ||
func IsOSSupported(os string) bool { | ||
if strings.EqualFold("windows", os) { | ||
return true | ||
} | ||
if LCOWSupported() && strings.EqualFold(os, "linux") { | ||
return true | ||
} | ||
return false | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// +build !windows windows,no_lcow | ||
|
||
package system // import "github.com/docker/docker/pkg/system" | ||
import ( | ||
"runtime" | ||
"strings" | ||
|
||
specs "github.com/opencontainers/image-spec/specs-go/v1" | ||
) | ||
|
||
// InitLCOW does nothing since LCOW is a windows only feature | ||
func InitLCOW(_ bool) {} | ||
|
||
// LCOWSupported returns true if Linux containers on Windows are supported. | ||
func LCOWSupported() bool { | ||
return false | ||
} | ||
|
||
// ValidatePlatform determines if a platform structure is valid. This function | ||
// is used for LCOW, and is a no-op on non-windows platforms. | ||
func ValidatePlatform(_ specs.Platform) error { | ||
return nil | ||
} | ||
|
||
// IsOSSupported determines if an operating system is supported by the host. | ||
func IsOSSupported(os string) bool { | ||
return strings.EqualFold(runtime.GOOS, os) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters