From 2294b17e7d516a287209e878d1aaa3c7462e4a5b Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Tue, 19 Sep 2023 16:53:09 +0200 Subject: [PATCH] cli/command/network: runCreate: inline types.NetworkCreate Signed-off-by: Sebastiaan van Stijn --- cli/command/network/create.go | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/cli/command/network/create.go b/cli/command/network/create.go index 37dcdea75c6a..7b71b6181f65 100644 --- a/cli/command/network/create.go +++ b/cli/command/network/create.go @@ -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 }