From 1f59bc8c03df18686b93a0cd619cf2c55cbcf421 Mon Sep 17 00:00:00 2001 From: Christopher Jones Date: Wed, 6 Apr 2016 16:39:30 -0400 Subject: [PATCH] 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 --- distribution/pull_v2.go | 4 +--- image/compat.go | 38 -------------------------------------- image/compat_test.go | 28 ---------------------------- image/store.go | 5 ----- 4 files changed, 1 insertion(+), 74 deletions(-) delete mode 100644 image/compat.go delete mode 100644 image/compat_test.go diff --git a/distribution/pull_v2.go b/distribution/pull_v2.go index 2b430d840e..ecddc170b7 100644 --- a/distribution/pull_v2.go +++ b/distribution/pull_v2.go @@ -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 } diff --git a/image/compat.go b/image/compat.go deleted file mode 100644 index 2873dcf6b3..0000000000 --- a/image/compat.go +++ /dev/null @@ -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 -} diff --git a/image/compat_test.go b/image/compat_test.go deleted file mode 100644 index dace5a843d..0000000000 --- a/image/compat_test.go +++ /dev/null @@ -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") - } -} diff --git a/image/store.go b/image/store.go index 0512203938..92ac438db7 100644 --- a/image/store.go +++ b/image/store.go @@ -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