mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
api/types/swarm: deprecate PortConfigProtocol
Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
This commit is contained in:
@@ -32,7 +32,7 @@ const (
|
||||
// PortConfig represents the config of a port.
|
||||
type PortConfig struct {
|
||||
Name string `json:",omitempty"`
|
||||
Protocol PortConfigProtocol `json:",omitempty"`
|
||||
Protocol network.IPProtocol `json:",omitempty"`
|
||||
// TargetPort is the port inside the container
|
||||
TargetPort uint32 `json:",omitempty"`
|
||||
// PublishedPort is the port on the swarm hosts
|
||||
@@ -55,17 +55,22 @@ const (
|
||||
)
|
||||
|
||||
// PortConfigProtocol represents the protocol of a port.
|
||||
type PortConfigProtocol string
|
||||
//
|
||||
// Deprecated: use [network.IPProtocol] instead.
|
||||
type PortConfigProtocol = network.IPProtocol
|
||||
|
||||
const (
|
||||
// TODO(stevvooe): These should be used generally, not just for PortConfig.
|
||||
|
||||
// PortConfigProtocolTCP TCP
|
||||
PortConfigProtocolTCP PortConfigProtocol = "tcp"
|
||||
// Deprecated: use [network.TCP] instead.
|
||||
PortConfigProtocolTCP PortConfigProtocol = network.TCP
|
||||
// PortConfigProtocolUDP UDP
|
||||
PortConfigProtocolUDP PortConfigProtocol = "udp"
|
||||
// Deprecated: use [network.UDP] instead.
|
||||
PortConfigProtocolUDP PortConfigProtocol = network.UDP
|
||||
// PortConfigProtocolSCTP SCTP
|
||||
PortConfigProtocolSCTP PortConfigProtocol = "sctp"
|
||||
// Deprecated: use [network.SCTP] instead.
|
||||
PortConfigProtocolSCTP PortConfigProtocol = network.SCTP
|
||||
)
|
||||
|
||||
// EndpointVirtualIP represents the virtual ip of a port.
|
||||
|
||||
@@ -144,7 +144,7 @@ func endpointFromGRPC(e *swarmapi.Endpoint) types.Endpoint {
|
||||
func swarmPortConfigToAPIPortConfig(portConfig *swarmapi.PortConfig) types.PortConfig {
|
||||
return types.PortConfig{
|
||||
Name: portConfig.Name,
|
||||
Protocol: types.PortConfigProtocol(strings.ToLower(swarmapi.PortConfig_Protocol_name[int32(portConfig.Protocol)])),
|
||||
Protocol: network.IPProtocol(strings.ToLower(swarmapi.PortConfig_Protocol_name[int32(portConfig.Protocol)])),
|
||||
PublishMode: types.PortConfigPublishMode(strings.ToLower(swarmapi.PortConfig_PublishMode_name[int32(portConfig.PublishMode)])),
|
||||
TargetPort: portConfig.TargetPort,
|
||||
PublishedPort: portConfig.PublishedPort,
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"strings"
|
||||
|
||||
gogotypes "github.com/gogo/protobuf/types"
|
||||
"github.com/moby/moby/api/types/network"
|
||||
types "github.com/moby/moby/api/types/swarm"
|
||||
swarmapi "github.com/moby/swarmkit/v2/api"
|
||||
)
|
||||
@@ -75,7 +76,7 @@ func TaskFromGRPC(t swarmapi.Task) (types.Task, error) {
|
||||
for _, p := range t.Status.PortStatus.Ports {
|
||||
task.Status.PortStatus.Ports = append(task.Status.PortStatus.Ports, types.PortConfig{
|
||||
Name: p.Name,
|
||||
Protocol: types.PortConfigProtocol(strings.ToLower(swarmapi.PortConfig_Protocol_name[int32(p.Protocol)])),
|
||||
Protocol: network.IPProtocol(strings.ToLower(swarmapi.PortConfig_Protocol_name[int32(p.Protocol)])),
|
||||
PublishMode: types.PortConfigPublishMode(strings.ToLower(swarmapi.PortConfig_PublishMode_name[int32(p.PublishMode)])),
|
||||
TargetPort: p.TargetPort,
|
||||
PublishedPort: p.PublishedPort,
|
||||
|
||||
@@ -354,7 +354,7 @@ func createServices(ctx context.Context, t *testing.T, d *daemon.Daemon, section
|
||||
hp, err := strconv.Atoi(hostPort.HostPort)
|
||||
assert.NilError(t, err)
|
||||
portConfig = append(portConfig, swarmtypes.PortConfig{
|
||||
Protocol: swarmtypes.PortConfigProtocol(ctrPP.Proto()),
|
||||
Protocol: ctrPP.Proto(),
|
||||
PublishedPort: uint32(hp),
|
||||
TargetPort: uint32(ctrPP.Num()),
|
||||
})
|
||||
|
||||
@@ -82,7 +82,7 @@ func TestHostPortMappings(t *testing.T) {
|
||||
swarm.ServiceWithNetwork(netName),
|
||||
swarm.ServiceWithEndpoint(&swarmtypes.EndpointSpec{
|
||||
Ports: []swarmtypes.PortConfig{
|
||||
{Protocol: swarmtypes.PortConfigProtocolTCP, TargetPort: 80, PublishedPort: 80, PublishMode: swarmtypes.PortConfigPublishModeHost},
|
||||
{Protocol: networktypes.TCP, TargetPort: 80, PublishedPort: 80, PublishMode: swarmtypes.PortConfigPublishModeHost},
|
||||
},
|
||||
}))
|
||||
defer apiClient.ServiceRemove(ctx, svcID)
|
||||
|
||||
@@ -276,7 +276,7 @@ func TestServiceRemoveKeepsIngressNetwork(t *testing.T) {
|
||||
swarm.ServiceWithEndpoint(&swarmtypes.EndpointSpec{
|
||||
Ports: []swarmtypes.PortConfig{
|
||||
{
|
||||
Protocol: swarmtypes.PortConfigProtocolTCP,
|
||||
Protocol: networktypes.TCP,
|
||||
TargetPort: 80,
|
||||
PublishMode: swarmtypes.PortConfigPublishModeIngress,
|
||||
},
|
||||
|
||||
15
vendor/github.com/moby/moby/api/types/swarm/network.go
generated
vendored
15
vendor/github.com/moby/moby/api/types/swarm/network.go
generated
vendored
@@ -32,7 +32,7 @@ const (
|
||||
// PortConfig represents the config of a port.
|
||||
type PortConfig struct {
|
||||
Name string `json:",omitempty"`
|
||||
Protocol PortConfigProtocol `json:",omitempty"`
|
||||
Protocol network.IPProtocol `json:",omitempty"`
|
||||
// TargetPort is the port inside the container
|
||||
TargetPort uint32 `json:",omitempty"`
|
||||
// PublishedPort is the port on the swarm hosts
|
||||
@@ -55,17 +55,22 @@ const (
|
||||
)
|
||||
|
||||
// PortConfigProtocol represents the protocol of a port.
|
||||
type PortConfigProtocol string
|
||||
//
|
||||
// Deprecated: use [network.IPProtocol] instead.
|
||||
type PortConfigProtocol = network.IPProtocol
|
||||
|
||||
const (
|
||||
// TODO(stevvooe): These should be used generally, not just for PortConfig.
|
||||
|
||||
// PortConfigProtocolTCP TCP
|
||||
PortConfigProtocolTCP PortConfigProtocol = "tcp"
|
||||
// Deprecated: use [network.TCP] instead.
|
||||
PortConfigProtocolTCP PortConfigProtocol = network.TCP
|
||||
// PortConfigProtocolUDP UDP
|
||||
PortConfigProtocolUDP PortConfigProtocol = "udp"
|
||||
// Deprecated: use [network.UDP] instead.
|
||||
PortConfigProtocolUDP PortConfigProtocol = network.UDP
|
||||
// PortConfigProtocolSCTP SCTP
|
||||
PortConfigProtocolSCTP PortConfigProtocol = "sctp"
|
||||
// Deprecated: use [network.SCTP] instead.
|
||||
PortConfigProtocolSCTP PortConfigProtocol = network.SCTP
|
||||
)
|
||||
|
||||
// EndpointVirtualIP represents the virtual ip of a port.
|
||||
|
||||
Reference in New Issue
Block a user