2020-04-01 06:22:05 -04:00
|
|
|
// +build windows,!no_lcow
|
|
|
|
|
2018-02-05 16:05:59 -05:00
|
|
|
package system // import "github.com/docker/docker/pkg/system"
|
2017-08-08 15:43:48 -04:00
|
|
|
|
|
|
|
import (
|
2018-06-26 14:30:19 -04:00
|
|
|
"strings"
|
2018-06-27 14:53:20 -04:00
|
|
|
|
2020-04-01 06:22:05 -04:00
|
|
|
"github.com/Microsoft/hcsshim/osversion"
|
2018-06-27 14:53:20 -04:00
|
|
|
specs "github.com/opencontainers/image-spec/specs-go/v1"
|
|
|
|
"github.com/pkg/errors"
|
2017-08-08 15:43:48 -04:00
|
|
|
)
|
|
|
|
|
2020-04-01 06:22:05 -04:00
|
|
|
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
|
2017-09-19 15:14:46 -04:00
|
|
|
}
|
2020-04-01 06:22:05 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func LCOWSupported() bool {
|
|
|
|
return lcowSupported
|
2017-09-19 15:14:46 -04:00
|
|
|
}
|
2018-06-27 14:53:20 -04:00
|
|
|
|
|
|
|
// 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 {
|
2020-04-01 06:22:05 -04:00
|
|
|
if !IsOSSupported(platform.OS) {
|
|
|
|
return errors.Errorf("unsupported os %s", platform.OS)
|
2018-06-27 14:53:20 -04:00
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
2020-04-01 06:22:05 -04:00
|
|
|
|
|
|
|
// 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
|
|
|
|
}
|