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>
| ... | ... |
@@ -628,9 +628,7 @@ func (p *v2Puller) pullManifestList(ctx context.Context, ref reference.Named, mf |
| 628 | 628 |
// TODO(aaronl): The manifest list spec supports optional |
| 629 | 629 |
// "features" and "variant" fields. These are not yet used. |
| 630 | 630 |
// Once they are, their values should be interpreted here. |
| 631 |
- // TODO(jstarks): Once os.version and os.features are present, |
|
| 632 |
- // pass these, too. |
|
| 633 |
- if image.ValidateOSCompatibility(manifestDescriptor.Platform.OS, manifestDescriptor.Platform.Architecture, "", nil) == nil {
|
|
| 631 |
+ if manifestDescriptor.Platform.Architecture == runtime.GOARCH && manifestDescriptor.Platform.OS == runtime.GOOS {
|
|
| 634 | 632 |
manifestDigest = manifestDescriptor.Digest |
| 635 | 633 |
break |
| 636 | 634 |
} |
| 637 | 635 |
deleted file mode 100644 |
| ... | ... |
@@ -1,38 +0,0 @@ |
| 1 |
-package image |
|
| 2 |
- |
|
| 3 |
-import ( |
|
| 4 |
- "fmt" |
|
| 5 |
- "runtime" |
|
| 6 |
- "strings" |
|
| 7 |
-) |
|
| 8 |
- |
|
| 9 |
-func archMatches(arch string) bool {
|
|
| 10 |
- // Special case x86_64 as an alias for amd64 |
|
| 11 |
- return arch == runtime.GOARCH || (arch == "x86_64" && runtime.GOARCH == "amd64") |
|
| 12 |
-} |
|
| 13 |
- |
|
| 14 |
-// ValidateOSCompatibility validates that an image with the given properties can run on this machine. |
|
| 15 |
-func ValidateOSCompatibility(os string, arch string, osVersion string, osFeatures []string) error {
|
|
| 16 |
- if os != "" && os != runtime.GOOS {
|
|
| 17 |
- return fmt.Errorf("image is for OS %s, expected %s", os, runtime.GOOS)
|
|
| 18 |
- } |
|
| 19 |
- if arch != "" && !archMatches(arch) {
|
|
| 20 |
- return fmt.Errorf("image is for architecture %s, expected %s", arch, runtime.GOARCH)
|
|
| 21 |
- } |
|
| 22 |
- if osVersion != "" {
|
|
| 23 |
- thisOSVersion := getOSVersion() |
|
| 24 |
- if thisOSVersion != osVersion {
|
|
| 25 |
- return fmt.Errorf("image is for OS version '%s', expected '%s'", osVersion, thisOSVersion)
|
|
| 26 |
- } |
|
| 27 |
- } |
|
| 28 |
- var missing []string |
|
| 29 |
- for _, f := range osFeatures {
|
|
| 30 |
- if !hasOSFeature(f) {
|
|
| 31 |
- missing = append(missing, f) |
|
| 32 |
- } |
|
| 33 |
- } |
|
| 34 |
- if len(missing) > 0 {
|
|
| 35 |
- return fmt.Errorf("image requires missing OS features: %s", strings.Join(missing, ", "))
|
|
| 36 |
- } |
|
| 37 |
- return nil |
|
| 38 |
-} |
| 39 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,28 +0,0 @@ |
| 1 |
-package image |
|
| 2 |
- |
|
| 3 |
-import ( |
|
| 4 |
- "runtime" |
|
| 5 |
- "testing" |
|
| 6 |
-) |
|
| 7 |
- |
|
| 8 |
-func TestValidateOSCompatibility(t *testing.T) {
|
|
| 9 |
- err := ValidateOSCompatibility(runtime.GOOS, runtime.GOARCH, getOSVersion(), nil) |
|
| 10 |
- if err != nil {
|
|
| 11 |
- t.Error(err) |
|
| 12 |
- } |
|
| 13 |
- |
|
| 14 |
- err = ValidateOSCompatibility("DOS", runtime.GOARCH, getOSVersion(), nil)
|
|
| 15 |
- if err == nil {
|
|
| 16 |
- t.Error("expected OS compat error")
|
|
| 17 |
- } |
|
| 18 |
- |
|
| 19 |
- err = ValidateOSCompatibility(runtime.GOOS, "pdp-11", getOSVersion(), nil) |
|
| 20 |
- if err == nil {
|
|
| 21 |
- t.Error("expected architecture compat error")
|
|
| 22 |
- } |
|
| 23 |
- |
|
| 24 |
- err = ValidateOSCompatibility(runtime.GOOS, runtime.GOARCH, "98 SE", nil) |
|
| 25 |
- if err == nil {
|
|
| 26 |
- t.Error("expected OS version compat error")
|
|
| 27 |
- } |
|
| 28 |
-} |
| ... | ... |
@@ -127,11 +127,6 @@ func (is *store) Create(config []byte) (ID, error) {
|
| 127 | 127 |
return "", errors.New("too many non-empty layers in History section")
|
| 128 | 128 |
} |
| 129 | 129 |
|
| 130 |
- err = ValidateOSCompatibility(img.OS, img.Architecture, img.OSVersion, img.OSFeatures) |
|
| 131 |
- if err != nil {
|
|
| 132 |
- return "", err |
|
| 133 |
- } |
|
| 134 |
- |
|
| 135 | 130 |
dgst, err := is.fs.Set(config) |
| 136 | 131 |
if err != nil {
|
| 137 | 132 |
return "", err |