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 (
|
|
|
|
"runtime"
|
2018-06-26 14:30:19 -04:00
|
|
|
"strings"
|
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
|
|
|
)
|
|
|
|
|
2017-09-19 15:14:46 -04:00
|
|
|
// IsOSSupported determines if an operating system is supported by the host
|
|
|
|
func IsOSSupported(os string) bool {
|
2018-02-23 18:29:26 -05:00
|
|
|
if strings.EqualFold(runtime.GOOS, os) {
|
2017-09-19 15:14:46 -04:00
|
|
|
return true
|
|
|
|
}
|
2018-02-23 18:29:26 -05:00
|
|
|
if LCOWSupported() && strings.EqualFold(os, "linux") {
|
2017-09-19 15:14:46 -04:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
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 {
|
|
|
|
if runtime.GOOS == "windows" {
|
|
|
|
if !(platform.OS == runtime.GOOS || (LCOWSupported() && platform.OS == "linux")) {
|
|
|
|
return errors.Errorf("unsupported os %s", platform.OS)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|