github.com/jwhonce/docker@v0.6.7-0.20190327063223-da823cf3a5a3/pkg/system/lcow.go (about)

     1  package system // import "github.com/docker/docker/pkg/system"
     2  
     3  import (
     4  	"runtime"
     5  	"strings"
     6  
     7  	specs "github.com/opencontainers/image-spec/specs-go/v1"
     8  	"github.com/pkg/errors"
     9  )
    10  
    11  // IsOSSupported determines if an operating system is supported by the host
    12  func IsOSSupported(os string) bool {
    13  	if strings.EqualFold(runtime.GOOS, os) {
    14  		return true
    15  	}
    16  	if LCOWSupported() && strings.EqualFold(os, "linux") {
    17  		return true
    18  	}
    19  	return false
    20  }
    21  
    22  // ValidatePlatform determines if a platform structure is valid.
    23  // TODO This is a temporary windows-only function, should be replaced by
    24  // comparison of worker capabilities
    25  func ValidatePlatform(platform specs.Platform) error {
    26  	if runtime.GOOS == "windows" {
    27  		if !(platform.OS == runtime.GOOS || (LCOWSupported() && platform.OS == "linux")) {
    28  			return errors.Errorf("unsupported os %s", platform.OS)
    29  		}
    30  	}
    31  	return nil
    32  }