diff options
author | Giuseppe Scrivano <gscrivan@redhat.com> | 2019-03-08 15:10:06 +0100 |
---|---|---|
committer | Giuseppe Scrivano <gscrivan@redhat.com> | 2019-03-11 09:28:57 +0100 |
commit | 06e444124f3b4989481c02c15a2fe1cf7fcb0b61 (patch) | |
tree | 0036f70f5f2b8f48cf0749f66439e036d1e9388f /cmd | |
parent | 349e6911497a95a6a8121524b56704fe680f2b09 (diff) | |
download | podman-06e444124f3b4989481c02c15a2fe1cf7fcb0b61.tar.gz podman-06e444124f3b4989481c02c15a2fe1cf7fcb0b61.tar.bz2 podman-06e444124f3b4989481c02c15a2fe1cf7fcb0b61.zip |
build: honor --net
when --net is specified, pass it down to Buildah.
Depends on: https://github.com/containers/buildah/pull/1395
Closes: https://github.com/containers/libpod/issues/2572
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/podman/build.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/cmd/podman/build.go b/cmd/podman/build.go index 5fcf03b93..72d78aff9 100644 --- a/cmd/podman/build.go +++ b/cmd/podman/build.go @@ -1,6 +1,7 @@ package main import ( + "fmt" "os" "path/filepath" "strings" @@ -11,6 +12,7 @@ import ( "github.com/containers/libpod/cmd/podman/cliconfig" "github.com/containers/libpod/pkg/adapter" "github.com/docker/go-units" + "github.com/opencontainers/runtime-spec/specs-go" "github.com/pkg/errors" "github.com/sirupsen/logrus" "github.com/spf13/cobra" @@ -83,6 +85,26 @@ func getDockerfiles(files []string) []string { return dockerfiles } +func getNsValues(c *cliconfig.BuildValues) ([]buildah.NamespaceOption, error) { + var ret []buildah.NamespaceOption + if c.Network != "" { + if c.Network == "host" { + ret = append(ret, buildah.NamespaceOption{ + Name: string(specs.NetworkNamespace), + Host: true, + }) + } else if c.Network[0] == '/' { + ret = append(ret, buildah.NamespaceOption{ + Name: string(specs.NetworkNamespace), + Path: c.Network, + }) + } else { + return nil, fmt.Errorf("unsupported configuration network=%s", c.Network) + } + } + return ret, nil +} + func buildCmd(c *cliconfig.BuildValues) error { // The following was taken directly from containers/buildah/cmd/bud.go // TODO Find a away to vendor more of this in rather than copy from bud @@ -227,6 +249,11 @@ func buildCmd(c *cliconfig.BuildValues) error { } } + nsValues, err := getNsValues(c) + if err != nil { + return err + } + buildOpts := buildah.CommonBuildOptions{ AddHost: c.AddHost, CgroupParent: c.CgroupParent, @@ -257,6 +284,7 @@ func buildCmd(c *cliconfig.BuildValues) error { IIDFile: c.Iidfile, Labels: c.Label, Layers: layers, + NamespaceOptions: nsValues, NoCache: c.NoCache, Out: stdout, Output: output, |