Skip to content

Commit

Permalink
Merge pull request #4622 from thaJeztah/update_engine_step2
Browse files Browse the repository at this point in the history
cli/command/network: runCreate: inline types.NetworkCreate
  • Loading branch information
thaJeztah authored Nov 13, 2023
2 parents f19d27e + 2294b17 commit b1a124c
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions cli/command/network/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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
}
Expand Down

0 comments on commit b1a124c

Please sign in to comment.