Skip to content

Consolidate api port types#51094

Merged
thaJeztah merged 3 commits intomoby:masterfrom
austinvazquez:consolidate-api-port-types
Oct 6, 2025
Merged

Consolidate api port types#51094
thaJeztah merged 3 commits intomoby:masterfrom
austinvazquez:consolidate-api-port-types

Conversation

@austinvazquez
Copy link
Contributor

@austinvazquez austinvazquez commented Oct 3, 2025

- What I did
Follow-up to #50710

- How I did it
Moved the container port/port range types under network package and deprecated and removed the usage of swarm.PortConfigProtocol.

- How to verify it

- Human readable description for the release notes

api/types/swarm: deprecated and dropped support for `PortConfigProtocol`; use `network.IPProtocol` instead.

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

@austinvazquez austinvazquez self-assigned this Oct 3, 2025
@austinvazquez austinvazquez added area/api API impact/api kind/refactor PR's that refactor, or clean-up code and removed module/api labels Oct 3, 2025
@austinvazquez austinvazquez added this to the 29.0.0 milestone Oct 3, 2025
@austinvazquez austinvazquez added the release-blocker PRs we want to block a release on label Oct 3, 2025
@thaJeztah
Copy link
Member

other PRs are merged, so this one can be rebased 😅

@thaJeztah
Copy link
Member

Oh! In case it's needed to help prevent circular imports; we also have a common package, under which we could (if needed) at sub-packages; https://github.com/moby/moby/tree/master/api/types/common

(not saying we should use that, but in case types/network, types/container types/swarm combined cause issues when importing one in the other)

Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
@austinvazquez austinvazquez force-pushed the consolidate-api-port-types branch from 783832c to 50269e6 Compare October 3, 2025 22:36
@austinvazquez austinvazquez marked this pull request as ready for review October 3, 2025 23:54
@austinvazquez austinvazquez requested a review from Copilot October 3, 2025 23:55
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR consolidates port-related types by moving container port and port range types from the container package to the network package, deprecating the use of swarm.PortConfigProtocol in favor of the consolidated types.

  • Moved port types (Port, PortRange, PortMap, PortBinding, PortSet) from api/types/container to api/types/network
  • Replaced swarm.PortConfigProtocol with network.IPProtocol throughout the codebase
  • Updated all imports and references to use the consolidated network package types

Reviewed Changes

Copilot reviewed 44 out of 49 changed files in this pull request and generated no comments.

Show a summary per file
File Description
api/types/network/port.go Moved from container package, renamed NetworkProtocol to IPProtocol
api/types/network/port_test.go Moved from container package with updated package declaration
api/types/container/config.go Updated to use network.PortSet for ExposedPorts
api/types/container/hostconfig.go Updated to use network.PortMap for PortBindings
api/types/container/network_settings.go Updated to use network.PortMap for Ports
api/types/swarm/network.go Replaced PortConfigProtocol with network.IPProtocol

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

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

@akerouanton @robmry PTAL

Comment on lines 16 to +19
const (
TCP NetworkProtocol = "tcp"
UDP NetworkProtocol = "udp"
SCTP NetworkProtocol = "sctp"
TCP IPProtocol = "tcp"
UDP IPProtocol = "udp"
SCTP IPProtocol = "sctp"
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, perhaps we should add a comment to this block to;

  • Outline these are the protocols currently supported by the daemon
  • (?) But that the list may be non-exhaustive (at least, I recall some discussion about the daemon being the source of truth for this, not the API)

Copy link
Contributor

@robmry robmry left a comment

Choose a reason for hiding this comment

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

LGTM

@thaJeztah
Copy link
Member

All green; let's bring this one in 👍

@thaJeztah thaJeztah merged commit 8ddcbbd into moby:master Oct 6, 2025
292 of 298 checks passed
@austinvazquez austinvazquez deleted the consolidate-api-port-types branch October 6, 2025 12:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/api API impact/api impact/changelog kind/refactor PR's that refactor, or clean-up code module/api release-blocker PRs we want to block a release on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants