mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
api/types/network: CreateRequest: remove deprecated CheckDuplicate field
CheckDuplicate is removed in API v1.44, and no longer used by
daemons supporting that API version (v25.0.0-beta.1 and up)
regardless of the API version used, but it must be set to true
when sent to older daemons (see [moby@78479b1]).
This patch moves adding the field to the client through an ad-hoc struct
so that we don't have to carry the field in the API module.
We can remove this once daemon versions v24.0 and lower are no longer
expected to be used (when Mirantis Container Runtime v23 is EOL).
https://github.com/moby/moby/blob/v2.0.0-beta.0/project/BRANCHES-AND-TAGS.md.
This field was removed from API v1.44 and no longer used by daemons supporting
that API version (v25.0.0-beta.1 and up) regardless of the API version used,
but for older version of the daemon required this option to be set.
[moby@78479b1]: 78479b1915
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@@ -28,10 +28,6 @@ type CreateRequest struct {
|
||||
ConfigFrom *ConfigReference // ConfigFrom specifies the source which will provide the configuration for this network. The specified network must be a config-only network; see [CreateOptions.ConfigOnly].
|
||||
Options map[string]string // Options specifies the network-specific options to use for when creating the network.
|
||||
Labels map[string]string // Labels holds metadata specific to the network being created.
|
||||
|
||||
// Deprecated: CheckDuplicate is deprecated since API v1.44, but it defaults to true when sent by the client
|
||||
// package to older daemons.
|
||||
CheckDuplicate *bool `json:",omitempty"`
|
||||
}
|
||||
|
||||
// ServiceInfo represents service parameters with the list of service's tasks
|
||||
|
||||
@@ -34,12 +34,29 @@ func (cli *Client) NetworkCreate(ctx context.Context, name string, options Netwo
|
||||
Options: options.Options,
|
||||
Labels: options.Labels,
|
||||
}
|
||||
|
||||
var req any
|
||||
if versions.LessThan(cli.version, "1.44") {
|
||||
enabled := true
|
||||
networkCreateRequest.CheckDuplicate = &enabled //nolint:staticcheck // ignore SA1019: CheckDuplicate is deprecated since API v1.44.
|
||||
// CheckDuplicate is removed in API v1.44, and no longer used by
|
||||
// daemons supporting that API version (v25.0.0-beta.1 and up)
|
||||
// regardless of the API version used, but it must be set to true
|
||||
// when sent to older daemons.
|
||||
//
|
||||
// TODO(thaJeztah) remove this once daemon versions v24.0 and lower are no
|
||||
// longer expected to be used (when Mirantis Container Runtime v23
|
||||
// is EOL); https://github.com/moby/moby/blob/v2.0.0-beta.0/project/BRANCHES-AND-TAGS.md
|
||||
req = struct {
|
||||
network.CreateRequest
|
||||
CheckDuplicate bool
|
||||
}{
|
||||
CreateRequest: networkCreateRequest,
|
||||
CheckDuplicate: true,
|
||||
}
|
||||
} else {
|
||||
req = networkCreateRequest
|
||||
}
|
||||
|
||||
resp, err := cli.post(ctx, "/networks/create", nil, networkCreateRequest, nil)
|
||||
resp, err := cli.post(ctx, "/networks/create", nil, req, nil)
|
||||
defer ensureReaderClosed(resp)
|
||||
if err != nil {
|
||||
return network.CreateResponse{}, err
|
||||
|
||||
4
vendor/github.com/moby/moby/api/types/network/network_types.go
generated
vendored
4
vendor/github.com/moby/moby/api/types/network/network_types.go
generated
vendored
@@ -28,10 +28,6 @@ type CreateRequest struct {
|
||||
ConfigFrom *ConfigReference // ConfigFrom specifies the source which will provide the configuration for this network. The specified network must be a config-only network; see [CreateOptions.ConfigOnly].
|
||||
Options map[string]string // Options specifies the network-specific options to use for when creating the network.
|
||||
Labels map[string]string // Labels holds metadata specific to the network being created.
|
||||
|
||||
// Deprecated: CheckDuplicate is deprecated since API v1.44, but it defaults to true when sent by the client
|
||||
// package to older daemons.
|
||||
CheckDuplicate *bool `json:",omitempty"`
|
||||
}
|
||||
|
||||
// ServiceInfo represents service parameters with the list of service's tasks
|
||||
|
||||
23
vendor/github.com/moby/moby/client/network_create.go
generated
vendored
23
vendor/github.com/moby/moby/client/network_create.go
generated
vendored
@@ -34,12 +34,29 @@ func (cli *Client) NetworkCreate(ctx context.Context, name string, options Netwo
|
||||
Options: options.Options,
|
||||
Labels: options.Labels,
|
||||
}
|
||||
|
||||
var req any
|
||||
if versions.LessThan(cli.version, "1.44") {
|
||||
enabled := true
|
||||
networkCreateRequest.CheckDuplicate = &enabled //nolint:staticcheck // ignore SA1019: CheckDuplicate is deprecated since API v1.44.
|
||||
// CheckDuplicate is removed in API v1.44, and no longer used by
|
||||
// daemons supporting that API version (v25.0.0-beta.1 and up)
|
||||
// regardless of the API version used, but it must be set to true
|
||||
// when sent to older daemons.
|
||||
//
|
||||
// TODO(thaJeztah) remove this once daemon versions v24.0 and lower are no
|
||||
// longer expected to be used (when Mirantis Container Runtime v23
|
||||
// is EOL); https://github.com/moby/moby/blob/v2.0.0-beta.0/project/BRANCHES-AND-TAGS.md
|
||||
req = struct {
|
||||
network.CreateRequest
|
||||
CheckDuplicate bool
|
||||
}{
|
||||
CreateRequest: networkCreateRequest,
|
||||
CheckDuplicate: true,
|
||||
}
|
||||
} else {
|
||||
req = networkCreateRequest
|
||||
}
|
||||
|
||||
resp, err := cli.post(ctx, "/networks/create", nil, networkCreateRequest, nil)
|
||||
resp, err := cli.post(ctx, "/networks/create", nil, req, nil)
|
||||
defer ensureReaderClosed(resp)
|
||||
if err != nil {
|
||||
return network.CreateResponse{}, err
|
||||
|
||||
Reference in New Issue
Block a user