Fix .ensure-emptyfs on non-x86_64 architectures

Now that we are checking if the image and host have the same architectures
via #21272, this value should be null so that the test passes on non-x86
machines

Signed-off-by: Christopher Jones <tophj@linux.vnet.ibm.com>
This commit is contained in:
Christopher Jones 2016-04-06 16:39:30 -04:00
Родитель 40dc921da2
Коммит 1f59bc8c03
4 изменённых файлов: 1 добавлений и 74 удалений

Просмотреть файл

@ -628,9 +628,7 @@ func (p *v2Puller) pullManifestList(ctx context.Context, ref reference.Named, mf
// TODO(aaronl): The manifest list spec supports optional
// "features" and "variant" fields. These are not yet used.
// Once they are, their values should be interpreted here.
// TODO(jstarks): Once os.version and os.features are present,
// pass these, too.
if image.ValidateOSCompatibility(manifestDescriptor.Platform.OS, manifestDescriptor.Platform.Architecture, "", nil) == nil {
if manifestDescriptor.Platform.Architecture == runtime.GOARCH && manifestDescriptor.Platform.OS == runtime.GOOS {
manifestDigest = manifestDescriptor.Digest
break
}

Просмотреть файл

@ -1,38 +0,0 @@
package image
import (
"fmt"
"runtime"
"strings"
)
func archMatches(arch string) bool {
// Special case x86_64 as an alias for amd64
return arch == runtime.GOARCH || (arch == "x86_64" && runtime.GOARCH == "amd64")
}
// ValidateOSCompatibility validates that an image with the given properties can run on this machine.
func ValidateOSCompatibility(os string, arch string, osVersion string, osFeatures []string) error {
if os != "" && os != runtime.GOOS {
return fmt.Errorf("image is for OS %s, expected %s", os, runtime.GOOS)
}
if arch != "" && !archMatches(arch) {
return fmt.Errorf("image is for architecture %s, expected %s", arch, runtime.GOARCH)
}
if osVersion != "" {
thisOSVersion := getOSVersion()
if thisOSVersion != osVersion {
return fmt.Errorf("image is for OS version '%s', expected '%s'", osVersion, thisOSVersion)
}
}
var missing []string
for _, f := range osFeatures {
if !hasOSFeature(f) {
missing = append(missing, f)
}
}
if len(missing) > 0 {
return fmt.Errorf("image requires missing OS features: %s", strings.Join(missing, ", "))
}
return nil
}

Просмотреть файл

@ -1,28 +0,0 @@
package image
import (
"runtime"
"testing"
)
func TestValidateOSCompatibility(t *testing.T) {
err := ValidateOSCompatibility(runtime.GOOS, runtime.GOARCH, getOSVersion(), nil)
if err != nil {
t.Error(err)
}
err = ValidateOSCompatibility("DOS", runtime.GOARCH, getOSVersion(), nil)
if err == nil {
t.Error("expected OS compat error")
}
err = ValidateOSCompatibility(runtime.GOOS, "pdp-11", getOSVersion(), nil)
if err == nil {
t.Error("expected architecture compat error")
}
err = ValidateOSCompatibility(runtime.GOOS, runtime.GOARCH, "98 SE", nil)
if err == nil {
t.Error("expected OS version compat error")
}
}

Просмотреть файл

@ -127,11 +127,6 @@ func (is *store) Create(config []byte) (ID, error) {
return "", errors.New("too many non-empty layers in History section")
}
err = ValidateOSCompatibility(img.OS, img.Architecture, img.OSVersion, img.OSFeatures)
if err != nil {
return "", err
}
dgst, err := is.fs.Set(config)
if err != nil {
return "", err