github.com/kaisenlinux/docker.io@v0.0.0-20230510090727-ea55db55fac7/engine/pkg/system/lcow.go (about) 1 //go:build windows && !no_lcow 2 // +build windows,!no_lcow 3 4 package system // import "github.com/docker/docker/pkg/system" 5 6 import ( 7 "strings" 8 9 "github.com/Microsoft/hcsshim/osversion" 10 specs "github.com/opencontainers/image-spec/specs-go/v1" 11 "github.com/pkg/errors" 12 ) 13 14 var ( 15 // lcowSupported determines if Linux Containers on Windows are supported. 16 lcowSupported = false 17 ) 18 19 // InitLCOW sets whether LCOW is supported or not. Requires RS5+ 20 func InitLCOW(experimental bool) { 21 if experimental && osversion.Build() >= osversion.RS5 { 22 lcowSupported = true 23 } 24 } 25 26 func LCOWSupported() bool { 27 return lcowSupported 28 } 29 30 // ValidatePlatform determines if a platform structure is valid. 31 // TODO This is a temporary windows-only function, should be replaced by 32 // comparison of worker capabilities 33 func ValidatePlatform(platform specs.Platform) error { 34 if !IsOSSupported(platform.OS) { 35 return errors.Errorf("unsupported os %s", platform.OS) 36 } 37 return nil 38 } 39 40 // IsOSSupported determines if an operating system is supported by the host 41 func IsOSSupported(os string) bool { 42 if strings.EqualFold("windows", os) { 43 return true 44 } 45 if LCOWSupported() && strings.EqualFold(os, "linux") { 46 return true 47 } 48 return false 49 }