Skip to content

api/types/network: move network create/connect/disconnect options from api to client#50817

Merged
austinvazquez merged 2 commits intomoby:masterfrom
austinvazquez:move-network-options-from-api-to-client
Aug 27, 2025
Merged

api/types/network: move network create/connect/disconnect options from api to client#50817
austinvazquez merged 2 commits intomoby:masterfrom
austinvazquez:move-network-options-from-api-to-client

Conversation

@austinvazquez
Copy link
Contributor

- What I did
Partial for #50740
Related to #50786

This change moves network.CreateOptions, network.ConnectOptions, and network.DisconnectOptions out of the api to the client module.

- How I did it

- How to verify it

- Human readable description for the release notes

api/types/network: move `CreateOptions`, `ConnectOptions` and `DisconnectOptions` to the client module

- A picture of a cute animal (not mandatory but encouraged)

@austinvazquez austinvazquez added this to the 29.0.0 milestone Aug 26, 2025
@austinvazquez austinvazquez self-assigned this Aug 26, 2025
@austinvazquez austinvazquez added area/api API impact/api area/daemon Core Engine kind/refactor PR's that refactor, or clean-up code area/go-sdk release-blocker PRs we want to block a release on labels Aug 26, 2025
Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just some quick comments. overall LGTM, but I may need to give it a fresh look Tomorrow.

Comment on lines +24 to +29
Name string // Name is the requested name of the network.
Driver string // Driver is the driver-name used to create the network (e.g. `bridge`, `overlay`)
Scope string // Scope describes the level at which the network exists (e.g. `swarm` for cluster-wide or `local` for machine level).
EnableIPv4 *bool `json:",omitempty"` // EnableIPv4 represents whether to enable IPv4.
EnableIPv6 *bool `json:",omitempty"` // EnableIPv6 represents whether to enable IPv6.
IPAM *IPAM // IPAM is the network's IP Address Management.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a follow-up, we should consider taking the opportunity to;

  • Add omitempty labels to these fields
  • Add Names for the json fields; we've been too relaxed on that, and it's probably good to eplicitly set the names (also with their expected casing).

…dule

Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
@austinvazquez austinvazquez force-pushed the move-network-options-from-api-to-client branch from 1027918 to 01479dc Compare August 27, 2025 12:10
Comment on lines 667 to +669
return clustertypes.NetworkCreateRequest{
ID: nw.ID,
CreateRequest: network.CreateRequest{
Name: name, // TODO(thaJeztah): this is the same as [nw.Spec.Annotations.Name]; consider using that instead
CreateOptions: options,
},
ID: nw.ID,
CreateRequest: req,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not for this PR, but now starting to wonder if we even need the intermediate CreateRequest here if it's gonna be set for the clustertypes.NetworkCreateRequest, but POSSIBLY we (or I?) did so to make sure we don't forget updating things in the cluster types when adding fields to the moby API etc.

Comment on lines 8 to +9
// WithDriver sets the driver of the network
func WithDriver(driver string) func(*network.CreateOptions) {
return func(n *network.CreateOptions) {
func WithDriver(driver string) func(*client.NetworkCreateOptions) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was always funny; our internal test client has a nicer API than the actual client. That said, I don't think the functional arguments here were all implemented correctly, so we should probably not adopt them as-is.

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
@austinvazquez austinvazquez force-pushed the move-network-options-from-api-to-client branch from 01479dc to 1b4fcb8 Compare August 27, 2025 13:11
@austinvazquez
Copy link
Contributor Author

Edited the second commit. Realized as CI was finishing up that I forgot to remove the create options type definition from api module.

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh! missed that as well

still LGTM, thanks!

@austinvazquez austinvazquez merged commit 8ac1bfa into moby:master Aug 27, 2025
175 checks passed
@austinvazquez austinvazquez deleted the move-network-options-from-api-to-client branch August 27, 2025 14:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/api API area/daemon Core Engine area/go-sdk impact/api kind/refactor PR's that refactor, or clean-up code release-blocker PRs we want to block a release on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants