summaryrefslogtreecommitdiff
path: root/cmd/podman
diff options
context:
space:
mode:
authorPaul Holzinger <paul.holzinger@web.de>2020-11-12 22:50:00 +0100
committerPaul Holzinger <paul.holzinger@web.de>2020-11-12 23:17:46 +0100
commiteab0905fa16bf2b5a9efdab3b6e6d6a1e321e4f2 (patch)
treeaefa5cead667c0c8522d6f64879df24df5e47d08 /cmd/podman
parent79f5aed31618b7d1b3c47f08ba9b33e600851232 (diff)
downloadpodman-eab0905fa16bf2b5a9efdab3b6e6d6a1e321e4f2.tar.gz
podman-eab0905fa16bf2b5a9efdab3b6e6d6a1e321e4f2.tar.bz2
podman-eab0905fa16bf2b5a9efdab3b6e6d6a1e321e4f2.zip
Fix namespace flag parsing for podman build
The namespace options for pid,ipc,uts were completely ignored. The network namespace did not accept `none`. This commit fixes these issues simply by calling `parse.NamespaceOptions` from buildah instead of implementing our own logic. Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
Diffstat (limited to 'cmd/podman')
-rw-r--r--cmd/podman/images/build.go39
1 files changed, 1 insertions, 38 deletions
diff --git a/cmd/podman/images/build.go b/cmd/podman/images/build.go
index 09914db93..b192799d6 100644
--- a/cmd/podman/images/build.go
+++ b/cmd/podman/images/build.go
@@ -14,7 +14,6 @@ import (
"github.com/containers/podman/v2/cmd/podman/utils"
"github.com/containers/podman/v2/pkg/domain/entities"
"github.com/docker/go-units"
- "github.com/opencontainers/runtime-spec/specs-go"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
@@ -315,22 +314,11 @@ func buildFlagsWrapperToOptions(c *cobra.Command, contextDir string, flags *buil
}
}
- nsValues, err := getNsValues(flags)
+ nsValues, networkPolicy, err := parse.NamespaceOptions(c)
if err != nil {
return nil, err
}
- networkPolicy := buildah.NetworkDefault
- for _, ns := range nsValues {
- if ns.Name == "none" {
- networkPolicy = buildah.NetworkDisabled
- break
- } else if !filepath.IsAbs(ns.Path) {
- networkPolicy = buildah.NetworkEnabled
- break
- }
- }
-
// `buildah bud --layers=false` acts like `docker build --squash` does.
// That is all of the new layers created during the build process are
// condensed into one, any layers present prior to this build are retained
@@ -451,28 +439,3 @@ func buildFlagsWrapperToOptions(c *cobra.Command, contextDir string, flags *buil
return &entities.BuildOptions{BuildOptions: opts}, nil
}
-
-func getNsValues(flags *buildFlagsWrapper) ([]buildah.NamespaceOption, error) {
- var ret []buildah.NamespaceOption
- if flags.Network != "" {
- switch {
- case flags.Network == "host":
- ret = append(ret, buildah.NamespaceOption{
- Name: string(specs.NetworkNamespace),
- Host: true,
- })
- case flags.Network == "container":
- ret = append(ret, buildah.NamespaceOption{
- Name: string(specs.NetworkNamespace),
- })
- case flags.Network[0] == '/':
- ret = append(ret, buildah.NamespaceOption{
- Name: string(specs.NetworkNamespace),
- Path: flags.Network,
- })
- default:
- return nil, errors.Errorf("unsupported configuration network=%s", flags.Network)
- }
- }
- return ret, nil
-}