Browse Source

api/types: move ServiceUpdateResponse

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Sebastiaan van Stijn 2 years ago
parent
commit
5b3e6555a3

+ 25 - 25
api/server/router/swarm/backend.go

@@ -3,40 +3,40 @@ package swarm // import "github.com/docker/docker/api/server/router/swarm"
 import (
 import (
 	"context"
 	"context"
 
 
-	basictypes "github.com/docker/docker/api/types"
+	"github.com/docker/docker/api/types"
 	"github.com/docker/docker/api/types/backend"
 	"github.com/docker/docker/api/types/backend"
-	types "github.com/docker/docker/api/types/swarm"
+	"github.com/docker/docker/api/types/swarm"
 )
 )
 
 
 // Backend abstracts a swarm manager.
 // Backend abstracts a swarm manager.
 type Backend interface {
 type Backend interface {
-	Init(req types.InitRequest) (string, error)
-	Join(req types.JoinRequest) error
+	Init(req swarm.InitRequest) (string, error)
+	Join(req swarm.JoinRequest) error
 	Leave(ctx context.Context, force bool) error
 	Leave(ctx context.Context, force bool) error
-	Inspect() (types.Swarm, error)
-	Update(uint64, types.Spec, types.UpdateFlags) error
+	Inspect() (swarm.Swarm, error)
+	Update(uint64, swarm.Spec, swarm.UpdateFlags) error
 	GetUnlockKey() (string, error)
 	GetUnlockKey() (string, error)
-	UnlockSwarm(req types.UnlockRequest) error
-	GetServices(basictypes.ServiceListOptions) ([]types.Service, error)
-	GetService(idOrName string, insertDefaults bool) (types.Service, error)
-	CreateService(types.ServiceSpec, string, bool) (*basictypes.ServiceCreateResponse, error)
-	UpdateService(string, uint64, types.ServiceSpec, basictypes.ServiceUpdateOptions, bool) (*basictypes.ServiceUpdateResponse, error)
+	UnlockSwarm(req swarm.UnlockRequest) error
+	GetServices(types.ServiceListOptions) ([]swarm.Service, error)
+	GetService(idOrName string, insertDefaults bool) (swarm.Service, error)
+	CreateService(swarm.ServiceSpec, string, bool) (*types.ServiceCreateResponse, error)
+	UpdateService(string, uint64, swarm.ServiceSpec, types.ServiceUpdateOptions, bool) (*swarm.ServiceUpdateResponse, error)
 	RemoveService(string) error
 	RemoveService(string) error
-	ServiceLogs(context.Context, *backend.LogSelector, *basictypes.ContainerLogsOptions) (<-chan *backend.LogMessage, error)
-	GetNodes(basictypes.NodeListOptions) ([]types.Node, error)
-	GetNode(string) (types.Node, error)
-	UpdateNode(string, uint64, types.NodeSpec) error
+	ServiceLogs(context.Context, *backend.LogSelector, *types.ContainerLogsOptions) (<-chan *backend.LogMessage, error)
+	GetNodes(types.NodeListOptions) ([]swarm.Node, error)
+	GetNode(string) (swarm.Node, error)
+	UpdateNode(string, uint64, swarm.NodeSpec) error
 	RemoveNode(string, bool) error
 	RemoveNode(string, bool) error
-	GetTasks(basictypes.TaskListOptions) ([]types.Task, error)
-	GetTask(string) (types.Task, error)
-	GetSecrets(opts basictypes.SecretListOptions) ([]types.Secret, error)
-	CreateSecret(s types.SecretSpec) (string, error)
+	GetTasks(types.TaskListOptions) ([]swarm.Task, error)
+	GetTask(string) (swarm.Task, error)
+	GetSecrets(opts types.SecretListOptions) ([]swarm.Secret, error)
+	CreateSecret(s swarm.SecretSpec) (string, error)
 	RemoveSecret(idOrName string) error
 	RemoveSecret(idOrName string) error
-	GetSecret(id string) (types.Secret, error)
-	UpdateSecret(idOrName string, version uint64, spec types.SecretSpec) error
-	GetConfigs(opts basictypes.ConfigListOptions) ([]types.Config, error)
-	CreateConfig(s types.ConfigSpec) (string, error)
+	GetSecret(id string) (swarm.Secret, error)
+	UpdateSecret(idOrName string, version uint64, spec swarm.SecretSpec) error
+	GetConfigs(opts types.ConfigListOptions) ([]swarm.Config, error)
+	CreateConfig(s swarm.ConfigSpec) (string, error)
 	RemoveConfig(id string) error
 	RemoveConfig(id string) error
-	GetConfig(id string) (types.Config, error)
-	UpdateConfig(idOrName string, version uint64, spec types.ConfigSpec) error
+	GetConfig(id string) (swarm.Config, error)
+	UpdateConfig(idOrName string, version uint64, spec swarm.ConfigSpec) error
 }
 }

+ 1 - 1
api/types/service_update_response.go → api/types/swarm/service_update_response.go

@@ -1,4 +1,4 @@
-package types
+package swarm
 
 
 // This file was generated by the swagger tool.
 // This file was generated by the swagger tool.
 // Editing this file might prove futile when you re-run the swagger generate command
 // Editing this file might prove futile when you re-run the swagger generate command

+ 6 - 0
api/types/types_deprecated.go

@@ -3,6 +3,7 @@ package types
 import (
 import (
 	"github.com/docker/docker/api/types/checkpoint"
 	"github.com/docker/docker/api/types/checkpoint"
 	"github.com/docker/docker/api/types/image"
 	"github.com/docker/docker/api/types/image"
+	"github.com/docker/docker/api/types/swarm"
 	"github.com/docker/docker/api/types/system"
 	"github.com/docker/docker/api/types/system"
 )
 )
 
 
@@ -79,6 +80,11 @@ type ImageSummary = image.Summary
 // Deprecated: use [image.Metadata].
 // Deprecated: use [image.Metadata].
 type ImageMetadata = image.Metadata
 type ImageMetadata = image.Metadata
 
 
+// ServiceUpdateResponse service update response.
+//
+// Deprecated: use [swarm.ServiceUpdateResponse].
+type ServiceUpdateResponse = swarm.ServiceUpdateResponse
+
 // DecodeSecurityOptions decodes a security options string slice to a type safe
 // DecodeSecurityOptions decodes a security options string slice to a type safe
 // [system.SecurityOpt].
 // [system.SecurityOpt].
 //
 //

+ 1 - 1
client/interface.go

@@ -145,7 +145,7 @@ type ServiceAPIClient interface {
 	ServiceInspectWithRaw(ctx context.Context, serviceID string, options types.ServiceInspectOptions) (swarm.Service, []byte, error)
 	ServiceInspectWithRaw(ctx context.Context, serviceID string, options types.ServiceInspectOptions) (swarm.Service, []byte, error)
 	ServiceList(ctx context.Context, options types.ServiceListOptions) ([]swarm.Service, error)
 	ServiceList(ctx context.Context, options types.ServiceListOptions) ([]swarm.Service, error)
 	ServiceRemove(ctx context.Context, serviceID string) error
 	ServiceRemove(ctx context.Context, serviceID string) error
-	ServiceUpdate(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options types.ServiceUpdateOptions) (types.ServiceUpdateResponse, error)
+	ServiceUpdate(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options types.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error)
 	ServiceLogs(ctx context.Context, serviceID string, options types.ContainerLogsOptions) (io.ReadCloser, error)
 	ServiceLogs(ctx context.Context, serviceID string, options types.ContainerLogsOptions) (io.ReadCloser, error)
 	TaskLogs(ctx context.Context, taskID string, options types.ContainerLogsOptions) (io.ReadCloser, error)
 	TaskLogs(ctx context.Context, taskID string, options types.ContainerLogsOptions) (io.ReadCloser, error)
 	TaskInspectWithRaw(ctx context.Context, taskID string) (swarm.Task, []byte, error)
 	TaskInspectWithRaw(ctx context.Context, taskID string) (swarm.Task, []byte, error)

+ 2 - 2
client/service_update.go

@@ -15,7 +15,7 @@ import (
 // ServiceUpdate updates a Service. The version number is required to avoid conflicting writes.
 // ServiceUpdate updates a Service. The version number is required to avoid conflicting writes.
 // It should be the value as set *before* the update. You can find this value in the Meta field
 // It should be the value as set *before* the update. You can find this value in the Meta field
 // of swarm.Service, which can be found using ServiceInspectWithRaw.
 // of swarm.Service, which can be found using ServiceInspectWithRaw.
-func (cli *Client) ServiceUpdate(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options types.ServiceUpdateOptions) (types.ServiceUpdateResponse, error) {
+func (cli *Client) ServiceUpdate(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options types.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error) {
 	// Make sure we negotiated (if the client is configured to do so),
 	// Make sure we negotiated (if the client is configured to do so),
 	// as code below contains API-version specific handling of options.
 	// as code below contains API-version specific handling of options.
 	//
 	//
@@ -25,7 +25,7 @@ func (cli *Client) ServiceUpdate(ctx context.Context, serviceID string, version
 
 
 	var (
 	var (
 		query    = url.Values{}
 		query    = url.Values{}
-		response = types.ServiceUpdateResponse{}
+		response = swarm.ServiceUpdateResponse{}
 	)
 	)
 
 
 	if options.RegistryAuthFrom != "" {
 	if options.RegistryAuthFrom != "" {

+ 3 - 3
daemon/cluster/services.go

@@ -280,8 +280,8 @@ func (c *Cluster) CreateService(s swarm.ServiceSpec, encodedAuth string, queryRe
 }
 }
 
 
 // UpdateService updates existing service to match new properties.
 // UpdateService updates existing service to match new properties.
-func (c *Cluster) UpdateService(serviceIDOrName string, version uint64, spec swarm.ServiceSpec, flags types.ServiceUpdateOptions, queryRegistry bool) (*types.ServiceUpdateResponse, error) {
-	var resp *types.ServiceUpdateResponse
+func (c *Cluster) UpdateService(serviceIDOrName string, version uint64, spec swarm.ServiceSpec, flags types.ServiceUpdateOptions, queryRegistry bool) (*swarm.ServiceUpdateResponse, error) {
+	var resp *swarm.ServiceUpdateResponse
 
 
 	err := c.lockedManagerAction(func(ctx context.Context, state nodeState) error {
 	err := c.lockedManagerAction(func(ctx context.Context, state nodeState) error {
 		err := c.populateNetworkID(ctx, state.controlClient, &spec)
 		err := c.populateNetworkID(ctx, state.controlClient, &spec)
@@ -299,7 +299,7 @@ func (c *Cluster) UpdateService(serviceIDOrName string, version uint64, spec swa
 			return err
 			return err
 		}
 		}
 
 
-		resp = &types.ServiceUpdateResponse{}
+		resp = &swarm.ServiceUpdateResponse{}
 
 
 		switch serviceSpec.Task.Runtime.(type) {
 		switch serviceSpec.Task.Runtime.(type) {
 		case *swarmapi.TaskSpec_Attachment:
 		case *swarmapi.TaskSpec_Attachment:

+ 5 - 2
hack/generate-swagger-api.sh

@@ -11,8 +11,7 @@ swagger generate model -f api/swagger.yaml \
 	-n PluginMount \
 	-n PluginMount \
 	-n PluginEnv \
 	-n PluginEnv \
 	-n PluginInterfaceType \
 	-n PluginInterfaceType \
-	-n Port \
-	-n ServiceUpdateResponse
+	-n Port
 
 
 swagger generate model -f api/swagger.yaml \
 swagger generate model -f api/swagger.yaml \
 	-t api -m types/container --skip-validator -C api/swagger-gen.yaml \
 	-t api -m types/container --skip-validator -C api/swagger-gen.yaml \
@@ -40,3 +39,7 @@ swagger generate operation -f api/swagger.yaml \
 	-n ContainerTop \
 	-n ContainerTop \
 	-n ContainerUpdate \
 	-n ContainerUpdate \
 	-n ImageHistory
 	-n ImageHistory
+
+swagger generate model -f api/swagger.yaml \
+	-t api -m types/swarm --skip-validator -C api/swagger-gen.yaml \
+	-n ServiceUpdateResponse