From 6bb9f581a5243528388b6c74a10d50dc1b2cc486 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Tue, 28 Jan 2025 15:07:31 +0100 Subject: [PATCH] libnetwork/drivers/windows: remove ErrUnsupportedAddressType It was only used in a single place, and did not implement an errdef; the type itself was not used as sentinel error. Signed-off-by: Sebastiaan van Stijn --- libnetwork/drivers/windows/port_mapping.go | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/libnetwork/drivers/windows/port_mapping.go b/libnetwork/drivers/windows/port_mapping.go index 0854d3a1a4..5a318ecc28 100644 --- a/libnetwork/drivers/windows/port_mapping.go +++ b/libnetwork/drivers/windows/port_mapping.go @@ -15,16 +15,7 @@ import ( "github.com/ishidawataru/sctp" ) -const ( - maxAllocatePortAttempts = 10 -) - -// ErrUnsupportedAddressType is returned when the specified address type is not supported. -type ErrUnsupportedAddressType string - -func (uat ErrUnsupportedAddressType) Error() string { - return fmt.Sprintf("unsupported address type: %s", string(uat)) -} +const maxAllocatePortAttempts = 10 // AllocatePorts allocates ports specified in bindings from the portMapper func AllocatePorts(portMapper *portmapper.PortMapper, bindings []types.PortBinding, containerIP net.IP) ([]types.PortBinding, error) { @@ -98,7 +89,7 @@ func allocatePort(portMapper *portmapper.PortMapper, bnd *types.PortBinding, con break default: // For completeness - return ErrUnsupportedAddressType(fmt.Sprintf("%T", netAddr)) + return fmt.Errorf("unsupported address type: %T", netAddr) } // Windows does not support host port ranges. bnd.HostPortEnd = bnd.HostPort