From f877360dc19a7136b0ac3b99d7a6f0b85460d667 Mon Sep 17 00:00:00 2001 From: Albin Kerouanton Date: Mon, 11 Sep 2023 01:15:06 +0200 Subject: [PATCH] api/t/swarm: Fix deprecation for ServiceSpec.Networks Signed-off-by: Albin Kerouanton --- api/swagger.yaml | 5 ++++- api/types/swarm/service.go | 6 +++--- daemon/cluster/convert/service.go | 4 ++-- daemon/cluster/networks.go | 2 +- docs/api/version-history.md | 2 ++ 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/api/swagger.yaml b/api/swagger.yaml index 2fc0a351ba..2adcc437a0 100644 --- a/api/swagger.yaml +++ b/api/swagger.yaml @@ -4248,7 +4248,10 @@ definitions: - "stop-first" - "start-first" Networks: - description: "Specifies which networks the service should attach to." + description: | + Specifies which networks the service should attach to. + + Deprecated: This field is deprecated since v1.44. The Networks field in TaskSpec should be used instead. type: "array" items: $ref: "#/definitions/NetworkAttachmentConfig" diff --git a/api/types/swarm/service.go b/api/types/swarm/service.go index 6eb452d24d..5b6d5ec120 100644 --- a/api/types/swarm/service.go +++ b/api/types/swarm/service.go @@ -34,9 +34,9 @@ type ServiceSpec struct { UpdateConfig *UpdateConfig `json:",omitempty"` RollbackConfig *UpdateConfig `json:",omitempty"` - // Networks field in ServiceSpec is deprecated. The - // same field in TaskSpec should be used instead. - // This field will be removed in a future release. + // Networks specifies which networks the service should attach to. + // + // Deprecated: This field is deprecated since v1.44. The Networks field in TaskSpec should be used instead. Networks []NetworkAttachmentConfig `json:",omitempty"` EndpointSpec *EndpointSpec `json:",omitempty"` } diff --git a/daemon/cluster/convert/service.go b/daemon/cluster/convert/service.go index 3177019673..e427276249 100644 --- a/daemon/cluster/convert/service.go +++ b/daemon/cluster/convert/service.go @@ -158,8 +158,8 @@ func ServiceSpecToGRPC(s types.ServiceSpec) (swarmapi.ServiceSpec, error) { name = namesgenerator.GetRandomName(0) } - serviceNetworks := make([]*swarmapi.NetworkAttachmentConfig, 0, len(s.Networks)) - for _, n := range s.Networks { + serviceNetworks := make([]*swarmapi.NetworkAttachmentConfig, 0, len(s.Networks)) //nolint:staticcheck // ignore SA1019: field is deprecated. + for _, n := range s.Networks { //nolint:staticcheck // ignore SA1019: field is deprecated. netConfig := &swarmapi.NetworkAttachmentConfig{Target: n.Target, Aliases: n.Aliases, DriverAttachmentOpts: n.DriverOpts} serviceNetworks = append(serviceNetworks, netConfig) } diff --git a/daemon/cluster/networks.go b/daemon/cluster/networks.go index 00d076e0a0..e00bc935a0 100644 --- a/daemon/cluster/networks.go +++ b/daemon/cluster/networks.go @@ -306,7 +306,7 @@ func (c *Cluster) populateNetworkID(ctx context.Context, client swarmapi.Control // but fallback to service spec for backward compatibility networks := s.TaskTemplate.Networks if len(networks) == 0 { - networks = s.Networks + networks = s.Networks //nolint:staticcheck // ignore SA1019: field is deprecated. } for i, n := range networks { apiNetwork, err := getNetwork(ctx, client, n.Target) diff --git a/docs/api/version-history.md b/docs/api/version-history.md index 3bf92febe5..66edee1a91 100644 --- a/docs/api/version-history.md +++ b/docs/api/version-history.md @@ -63,6 +63,8 @@ keywords: "API, Docker, rcli, REST, documentation" * A new endpoint-specific `MacAddress` field has been added to `NetworkSettings.EndpointSettings` on `POST /containers/create`, and to `EndpointConfig` on `POST /networks/{id}/connect`. The container-wide `MacAddress` field in `Config`, on `POST /containers/create`, is now deprecated. +* The field `Networks` in the `POST /services/create` and `POST /services/{id}/update` + requests is now deprecated. You should instead use the field `TaskTemplate.Networks`. ## v1.43 API changes