Skip to content

Commit

Permalink
add os|arch attributes when building
Browse files Browse the repository at this point in the history
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: containers#5503

Signed-off-by: Brent Baude <[email protected]>
  • Loading branch information
baude authored and snj33v committed May 31, 2020
1 parent 9aa1873 commit 2da0653
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cmd/podman/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ func buildCmd(c *cliconfig.BuildValues) error {
}

options := imagebuildah.BuildOptions{
Architecture: c.Arch,
CommonBuildOpts: &buildOpts,
AdditionalTags: tags,
Annotations: c.Annotation,
Expand All @@ -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,
Expand Down
10 changes: 10 additions & 0 deletions test/e2e/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"io/ioutil"
"os"
"path/filepath"
"runtime"
"strings"

. "github.com/containers/libpod/test/utils"
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit 2da0653

Please sign in to comment.