Merge pull request #4622 from thaJeztah/update_engine_step2

cli/command/network: runCreate: inline types.NetworkCreate
This commit is contained in:
Sebastiaan van Stijn 2023-11-13 15:47:51 +01:00 committed by GitHub
commit b1a124ccbf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 11 deletions

View File

@ -92,8 +92,13 @@ func runCreate(dockerCli command.Cli, options createOptions) error {
return err
}
// Construct network create request body
nc := types.NetworkCreate{
var configFrom *network.ConfigReference
if options.configFrom != "" {
configFrom = &network.ConfigReference{
Network: options.configFrom,
}
}
resp, err := client.NetworkCreate(context.Background(), options.name, types.NetworkCreate{
Driver: options.driver,
Options: options.driverOpts.GetAll(),
IPAM: &network.IPAM{
@ -107,16 +112,9 @@ func runCreate(dockerCli command.Cli, options createOptions) error {
Ingress: options.ingress,
Scope: options.scope,
ConfigOnly: options.configOnly,
ConfigFrom: configFrom,
Labels: opts.ConvertKVStringsToMap(options.labels.GetAll()),
}
if from := options.configFrom; from != "" {
nc.ConfigFrom = &network.ConfigReference{
Network: from,
}
}
resp, err := client.NetworkCreate(context.Background(), options.name, nc)
})
if err != nil {
return err
}