Merge pull request #51150 from austinvazquez/fix-swarm-type

api: fix swarm network field from addr to prefix
This commit is contained in:
Austin Vazquez
2025-10-09 14:15:02 -05:00
committed by GitHub
3 changed files with 10 additions and 10 deletions

View File

@@ -56,8 +56,8 @@ const (
// EndpointVirtualIP represents the virtual ip of a port.
type EndpointVirtualIP struct {
NetworkID string `json:",omitempty"`
Addr netip.Addr `json:",omitempty"`
NetworkID string `json:",omitempty"`
Addr netip.Prefix `json:",omitempty"`
}
// Network represents a network.
@@ -91,8 +91,8 @@ type NetworkAttachmentConfig struct {
// NetworkAttachment represents a network attachment.
type NetworkAttachment struct {
Network Network `json:",omitempty"`
Addresses []netip.Addr `json:",omitempty"`
Network Network `json:",omitempty"`
Addresses []netip.Prefix `json:",omitempty"`
}
// IPAMOptions represents ipam options.

View File

@@ -22,7 +22,7 @@ func networkAttachmentFromGRPC(na *swarmapi.NetworkAttachment) types.NetworkAtta
if na != nil {
return types.NetworkAttachment{
Network: networkFromGRPC(na.Network),
Addresses: sliceutil.Map(na.Addresses, func(s string) netip.Addr { a, _ := netip.ParseAddr(s); return a }),
Addresses: sliceutil.Map(na.Addresses, func(s string) netip.Prefix { a, _ := netip.ParsePrefix(s); return a }),
}
}
return types.NetworkAttachment{}
@@ -130,7 +130,7 @@ func endpointFromGRPC(e *swarmapi.Endpoint) types.Endpoint {
}
for _, v := range e.VirtualIPs {
vip, _ := netip.ParseAddr(v.Addr)
vip, _ := netip.ParsePrefix(v.Addr)
endpoint.VirtualIPs = append(endpoint.VirtualIPs, types.EndpointVirtualIP{
NetworkID: v.NetworkID,
Addr: vip,

View File

@@ -56,8 +56,8 @@ const (
// EndpointVirtualIP represents the virtual ip of a port.
type EndpointVirtualIP struct {
NetworkID string `json:",omitempty"`
Addr netip.Addr `json:",omitempty"`
NetworkID string `json:",omitempty"`
Addr netip.Prefix `json:",omitempty"`
}
// Network represents a network.
@@ -91,8 +91,8 @@ type NetworkAttachmentConfig struct {
// NetworkAttachment represents a network attachment.
type NetworkAttachment struct {
Network Network `json:",omitempty"`
Addresses []netip.Addr `json:",omitempty"`
Network Network `json:",omitempty"`
Addresses []netip.Prefix `json:",omitempty"`
}
// IPAMOptions represents ipam options.