From 9ca4b6c6f5105566b19c87f2ecd1bc1d54f791d3 Mon Sep 17 00:00:00 2001 From: Brent Baude Date: Sun, 15 Mar 2020 12:30:33 -0500 Subject: add os|arch attributes when building when building images, we can now add the os and arch of the image using overrides from the commandline. the commandline options set sane defaults so we use those as well. Fixes: #5503 Signed-off-by: Brent Baude --- cmd/podman/build.go | 2 ++ test/e2e/build_test.go | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/cmd/podman/build.go b/cmd/podman/build.go index b8b315c68..acd402fdd 100644 --- a/cmd/podman/build.go +++ b/cmd/podman/build.go @@ -342,6 +342,7 @@ func buildCmd(c *cliconfig.BuildValues) error { } options := imagebuildah.BuildOptions{ + Architecture: c.Arch, CommonBuildOpts: &buildOpts, AdditionalTags: tags, Annotations: c.Annotation, @@ -359,6 +360,7 @@ func buildCmd(c *cliconfig.BuildValues) error { Layers: layers, NamespaceOptions: nsValues, NoCache: c.NoCache, + OS: c.OS, Out: stdout, Output: output, OutputFormat: format, diff --git a/test/e2e/build_test.go b/test/e2e/build_test.go index b4e400549..240ef1627 100644 --- a/test/e2e/build_test.go +++ b/test/e2e/build_test.go @@ -6,6 +6,7 @@ import ( "io/ioutil" "os" "path/filepath" + "runtime" "strings" . "github.com/containers/libpod/test/utils" @@ -43,6 +44,15 @@ var _ = Describe("Podman build", func() { session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) + iid := session.OutputToStringArray()[len(session.OutputToStringArray())-1] + + // Verify that OS and Arch are being set + inspect := podmanTest.PodmanNoCache([]string{"inspect", iid}) + inspect.WaitWithDefaultTimeout() + data := inspect.InspectImageJSON() + Expect(data[0].Os).To(Equal(runtime.GOOS)) + Expect(data[0].Architecture).To(Equal(runtime.GOARCH)) + session = podmanTest.PodmanNoCache([]string{"rmi", "alpine"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) -- cgit v1.2.3-54-g00ecf