|
@@ -10,12 +10,16 @@ import (
|
|
|
|
|
|
// NetworkCreate creates a new network in the docker host.
|
|
// NetworkCreate creates a new network in the docker host.
|
|
func (cli *Client) NetworkCreate(ctx context.Context, name string, options types.NetworkCreate) (types.NetworkCreateResponse, error) {
|
|
func (cli *Client) NetworkCreate(ctx context.Context, name string, options types.NetworkCreate) (types.NetworkCreateResponse, error) {
|
|
|
|
+ var response types.NetworkCreateResponse
|
|
|
|
+
|
|
// Make sure we negotiated (if the client is configured to do so),
|
|
// Make sure we negotiated (if the client is configured to do so),
|
|
// as code below contains API-version specific handling of options.
|
|
// as code below contains API-version specific handling of options.
|
|
//
|
|
//
|
|
// Normally, version-negotiation (if enabled) would not happen until
|
|
// Normally, version-negotiation (if enabled) would not happen until
|
|
// the API request is made.
|
|
// the API request is made.
|
|
- cli.checkVersion(ctx)
|
|
|
|
|
|
+ if err := cli.checkVersion(ctx); err != nil {
|
|
|
|
+ return response, err
|
|
|
|
+ }
|
|
|
|
|
|
networkCreateRequest := types.NetworkCreateRequest{
|
|
networkCreateRequest := types.NetworkCreateRequest{
|
|
NetworkCreate: options,
|
|
NetworkCreate: options,
|
|
@@ -25,7 +29,6 @@ func (cli *Client) NetworkCreate(ctx context.Context, name string, options types
|
|
networkCreateRequest.CheckDuplicate = true //nolint:staticcheck // ignore SA1019: CheckDuplicate is deprecated since API v1.44.
|
|
networkCreateRequest.CheckDuplicate = true //nolint:staticcheck // ignore SA1019: CheckDuplicate is deprecated since API v1.44.
|
|
}
|
|
}
|
|
|
|
|
|
- var response types.NetworkCreateResponse
|
|
|
|
serverResp, err := cli.post(ctx, "/networks/create", nil, networkCreateRequest, nil)
|
|
serverResp, err := cli.post(ctx, "/networks/create", nil, networkCreateRequest, nil)
|
|
defer ensureReaderClosed(serverResp)
|
|
defer ensureReaderClosed(serverResp)
|
|
if err != nil {
|
|
if err != nil {
|