@@ -14,7 +14,6 @@ import (
1414 "github.com/containers/podman/v2/cmd/podman/utils"
1515 "github.com/containers/podman/v2/pkg/domain/entities"
1616 "github.com/docker/go-units"
17- "github.com/opencontainers/runtime-spec/specs-go"
1817 "github.com/pkg/errors"
1918 "github.com/sirupsen/logrus"
2019 "github.com/spf13/cobra"
@@ -128,6 +127,7 @@ func buildFlags(flags *pflag.FlagSet) {
128127 }
129128 flags .AddFlagSet (& fromAndBudFlags )
130129 _ = flags .MarkHidden ("signature-policy" )
130+ flags .SetNormalizeFunc (buildahCLI .AliasFlags )
131131}
132132
133133// build executes the build command.
@@ -314,22 +314,11 @@ func buildFlagsWrapperToOptions(c *cobra.Command, contextDir string, flags *buil
314314 }
315315 }
316316
317- nsValues , err := getNsValues ( flags )
317+ nsValues , networkPolicy , err := parse . NamespaceOptions ( c )
318318 if err != nil {
319319 return nil , err
320320 }
321321
322- networkPolicy := buildah .NetworkDefault
323- for _ , ns := range nsValues {
324- if ns .Name == "none" {
325- networkPolicy = buildah .NetworkDisabled
326- break
327- } else if ! filepath .IsAbs (ns .Path ) {
328- networkPolicy = buildah .NetworkEnabled
329- break
330- }
331- }
332-
333322 // `buildah bud --layers=false` acts like `docker build --squash` does.
334323 // That is all of the new layers created during the build process are
335324 // 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
450439
451440 return & entities.BuildOptions {BuildOptions : opts }, nil
452441}
453-
454- func getNsValues (flags * buildFlagsWrapper ) ([]buildah.NamespaceOption , error ) {
455- var ret []buildah.NamespaceOption
456- if flags .Network != "" {
457- switch {
458- case flags .Network == "host" :
459- ret = append (ret , buildah.NamespaceOption {
460- Name : string (specs .NetworkNamespace ),
461- Host : true ,
462- })
463- case flags .Network == "container" :
464- ret = append (ret , buildah.NamespaceOption {
465- Name : string (specs .NetworkNamespace ),
466- })
467- case flags .Network [0 ] == '/' :
468- ret = append (ret , buildah.NamespaceOption {
469- Name : string (specs .NetworkNamespace ),
470- Path : flags .Network ,
471- })
472- default :
473- return nil , errors .Errorf ("unsupported configuration network=%s" , flags .Network )
474- }
475- }
476- return ret , nil
477- }
0 commit comments