aboutsummaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-11-13 16:44:45 +0100
committerGitHub <noreply@github.com>2020-11-13 16:44:45 +0100
commit6d9d9fee30b5982858d51a666f0c335ba47323a0 (patch)
treeef3ceeb9326ca6710a8bbbe7983cd01bafdcd21a /cmd
parent0b1a60ec27928a40ac827148c1517098612616bd (diff)
parenteab0905fa16bf2b5a9efdab3b6e6d6a1e321e4f2 (diff)
downloadpodman-6d9d9fee30b5982858d51a666f0c335ba47323a0.tar.gz
podman-6d9d9fee30b5982858d51a666f0c335ba47323a0.tar.bz2
podman-6d9d9fee30b5982858d51a666f0c335ba47323a0.zip
Merge pull request #8326 from Luap99/fix-build-namespace
Fix namespace flag parsing for podman build
Diffstat (limited to 'cmd')
-rw-r--r--cmd/podman/images/build.go40
1 files changed, 2 insertions, 38 deletions
diff --git a/cmd/podman/images/build.go b/cmd/podman/images/build.go
index 5d0208c63..ccae25276 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"
@@ -128,6 +127,7 @@ func buildFlags(flags *pflag.FlagSet) {
}
flags.AddFlagSet(&fromAndBudFlags)
_ = flags.MarkHidden("signature-policy")
+ flags.SetNormalizeFunc(buildahCLI.AliasFlags)
}
// build executes the build command.
@@ -314,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
@@ -450,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
-}