mirror of
https://github.com/containers/podman.git
synced 2025-10-25 10:16:43 +08:00
Merge pull request #16141 from sbrivio-rh/pasta
Add pasta networking mode
This commit is contained in:
@ -95,7 +95,7 @@ func DefineNetFlags(cmd *cobra.Command) {
|
||||
}
|
||||
|
||||
// NetFlagsToNetOptions parses the network flags for the given cmd.
|
||||
func NetFlagsToNetOptions(opts *entities.NetOptions, flags pflag.FlagSet) (*entities.NetOptions, error) {
|
||||
func NetFlagsToNetOptions(opts *entities.NetOptions, flags pflag.FlagSet, pastaNetworkNameExists bool) (*entities.NetOptions, error) {
|
||||
var (
|
||||
err error
|
||||
)
|
||||
@ -192,7 +192,7 @@ func NetFlagsToNetOptions(opts *entities.NetOptions, flags pflag.FlagSet) (*enti
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ns, networks, options, err := specgen.ParseNetworkFlag(network)
|
||||
ns, networks, options, err := specgen.ParseNetworkFlag(network, pastaNetworkNameExists)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@ -105,8 +105,15 @@ func init() {
|
||||
|
||||
func commonFlags(cmd *cobra.Command) error {
|
||||
var err error
|
||||
|
||||
report, err := registry.ContainerEngine().NetworkExists(registry.Context(), "pasta")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
pastaNetworkNameExists := report.Value
|
||||
|
||||
flags := cmd.Flags()
|
||||
cliVals.Net, err = common.NetFlagsToNetOptions(nil, *flags)
|
||||
cliVals.Net, err = common.NetFlagsToNetOptions(nil, *flags, pastaNetworkNameExists)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -130,12 +130,18 @@ func create(cmd *cobra.Command, args []string) error {
|
||||
createOptions.Infra = false
|
||||
}
|
||||
|
||||
report, err := registry.ContainerEngine().NetworkExists(registry.Context(), "pasta")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
pastaNetworkNameExists := report.Value
|
||||
|
||||
if !createOptions.Infra {
|
||||
if cmd.Flag("no-hosts").Changed {
|
||||
return fmt.Errorf("cannot specify --no-hosts without an infra container")
|
||||
}
|
||||
flags := cmd.Flags()
|
||||
createOptions.Net, err = common.NetFlagsToNetOptions(nil, *flags)
|
||||
createOptions.Net, err = common.NetFlagsToNetOptions(nil, *flags, pastaNetworkNameExists)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -152,7 +158,7 @@ func create(cmd *cobra.Command, args []string) error {
|
||||
} else {
|
||||
// reassign certain options for lbpod api, these need to be populated in spec
|
||||
flags := cmd.Flags()
|
||||
infraOptions.Net, err = common.NetFlagsToNetOptions(nil, *flags)
|
||||
infraOptions.Net, err = common.NetFlagsToNetOptions(nil, *flags, pastaNetworkNameExists)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user