summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-11-16 17:36:12 +0100
committerGitHub <noreply@github.com>2019-11-16 17:36:12 +0100
commitc6f2383213b6a8ebf4c4b9f5d5162e7c08fa7c9f (patch)
tree2679ecc671b6a4e36adcb84c95b0586b60b5f69a
parent51c08f3be6176d66097a2289f7b4174b79339427 (diff)
parent96ab0c64b4e398c1be0a352e88fa900688fcd2e1 (diff)
downloadpodman-c6f2383213b6a8ebf4c4b9f5d5162e7c08fa7c9f.tar.gz
podman-c6f2383213b6a8ebf4c4b9f5d5162e7c08fa7c9f.tar.bz2
podman-c6f2383213b6a8ebf4c4b9f5d5162e7c08fa7c9f.zip
Merge pull request #4505 from vrothberg/arch
container create: os/arch check
-rw-r--r--cmd/podman/shared/create.go16
1 files changed, 14 insertions, 2 deletions
diff --git a/cmd/podman/shared/create.go b/cmd/podman/shared/create.go
index f74c1c62d..bb4e9cd12 100644
--- a/cmd/podman/shared/create.go
+++ b/cmd/podman/shared/create.go
@@ -7,6 +7,7 @@ import (
"io"
"os"
"path/filepath"
+ goruntime "runtime"
"strconv"
"strings"
"syscall"
@@ -88,9 +89,11 @@ func CreateContainer(ctx context.Context, c *GenericCLIResults, runtime *libpod.
return nil, nil, err
}
+ overrideOS := c.String("override-os")
+ overrideArch := c.String("override-arch")
dockerRegistryOptions := image.DockerRegistryOptions{
- OSChoice: c.String("override-os"),
- ArchitectureChoice: c.String("override-arch"),
+ OSChoice: overrideOS,
+ ArchitectureChoice: overrideArch,
}
newImage, err := runtime.ImageRuntime().New(ctx, name, rtc.SignaturePolicyPath, c.String("authfile"), writer, &dockerRegistryOptions, image.SigningOptions{}, nil, pullType)
@@ -101,6 +104,15 @@ func CreateContainer(ctx context.Context, c *GenericCLIResults, runtime *libpod.
if err != nil {
return nil, nil, err
}
+
+ if overrideOS == "" && data.Os != goruntime.GOOS {
+ return nil, nil, errors.Errorf("incompatible image OS %q on %q host", data.Os, goruntime.GOOS)
+ }
+
+ if overrideArch == "" && data.Architecture != goruntime.GOARCH {
+ return nil, nil, errors.Errorf("incompatible image architecture %q on %q host", data.Architecture, goruntime.GOARCH)
+ }
+
names := newImage.Names()
if len(names) > 0 {
imageName = names[0]