api/types: move ServiceCreateResponse, and generate from swagger
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
5b3e6555a3
commit
ec69501e94
10 changed files with 63 additions and 32 deletions
|
@ -19,7 +19,7 @@ type Backend interface {
|
|||
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)
|
||||
CreateService(swarm.ServiceSpec, string, bool) (*swarm.ServiceCreateResponse, error)
|
||||
UpdateService(string, uint64, swarm.ServiceSpec, types.ServiceUpdateOptions, bool) (*swarm.ServiceUpdateResponse, error)
|
||||
RemoveService(string) error
|
||||
ServiceLogs(context.Context, *backend.LogSelector, *types.ContainerLogsOptions) (<-chan *backend.LogMessage, error)
|
||||
|
|
|
@ -4487,6 +4487,29 @@ definitions:
|
|||
description: "The image ID of an image that was deleted"
|
||||
type: "string"
|
||||
|
||||
ServiceCreateResponse:
|
||||
type: "object"
|
||||
description: |
|
||||
contains the information returned to a client on the
|
||||
creation of a new service.
|
||||
properties:
|
||||
ID:
|
||||
description: "The ID of the created service."
|
||||
type: "string"
|
||||
x-nullable: false
|
||||
example: "ak7w3gjqoa3kuz8xcpnyy0pvl"
|
||||
Warnings:
|
||||
description: |
|
||||
Optional warning message.
|
||||
|
||||
FIXME(thaJeztah): this should have "omitempty" in the generated type.
|
||||
type: "array"
|
||||
x-nullable: true
|
||||
items:
|
||||
type: "string"
|
||||
example:
|
||||
- "unable to pin image doesnotexist:latest to digest: image library/doesnotexist:latest not found"
|
||||
|
||||
ServiceUpdateResponse:
|
||||
type: "object"
|
||||
properties:
|
||||
|
@ -4496,7 +4519,8 @@ definitions:
|
|||
items:
|
||||
type: "string"
|
||||
example:
|
||||
Warning: "unable to pin image doesnotexist:latest to digest: image library/doesnotexist:latest not found"
|
||||
Warnings:
|
||||
- "unable to pin image doesnotexist:latest to digest: image library/doesnotexist:latest not found"
|
||||
|
||||
ContainerSummary:
|
||||
type: "object"
|
||||
|
@ -11099,18 +11123,7 @@ paths:
|
|||
201:
|
||||
description: "no error"
|
||||
schema:
|
||||
type: "object"
|
||||
title: "ServiceCreateResponse"
|
||||
properties:
|
||||
ID:
|
||||
description: "The ID of the created service."
|
||||
type: "string"
|
||||
Warning:
|
||||
description: "Optional warning message"
|
||||
type: "string"
|
||||
example:
|
||||
ID: "ak7w3gjqoa3kuz8xcpnyy0pvl"
|
||||
Warning: "unable to pin image doesnotexist:latest to digest: image library/doesnotexist:latest not found"
|
||||
$ref: "#/definitions/ServiceCreateResponse"
|
||||
400:
|
||||
description: "bad parameter"
|
||||
schema:
|
||||
|
|
|
@ -322,15 +322,6 @@ type ServiceCreateOptions struct {
|
|||
QueryRegistry bool
|
||||
}
|
||||
|
||||
// ServiceCreateResponse contains the information returned to a client
|
||||
// on the creation of a new service.
|
||||
type ServiceCreateResponse struct {
|
||||
// ID is the ID of the created service.
|
||||
ID string
|
||||
// Warnings is a set of non-fatal warning messages to pass on to the user.
|
||||
Warnings []string `json:",omitempty"`
|
||||
}
|
||||
|
||||
// Values for RegistryAuthFrom in ServiceUpdateOptions
|
||||
const (
|
||||
RegistryAuthFromSpec = "spec"
|
||||
|
|
20
api/types/swarm/service_create_response.go
Normal file
20
api/types/swarm/service_create_response.go
Normal file
|
@ -0,0 +1,20 @@
|
|||
package swarm
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
// ServiceCreateResponse contains the information returned to a client on the
|
||||
// creation of a new service.
|
||||
//
|
||||
// swagger:model ServiceCreateResponse
|
||||
type ServiceCreateResponse struct {
|
||||
|
||||
// The ID of the created service.
|
||||
ID string `json:"ID,omitempty"`
|
||||
|
||||
// Optional warning message.
|
||||
//
|
||||
// FIXME(thaJeztah): this should have "omitempty" in the generated type.
|
||||
//
|
||||
Warnings []string `json:"Warnings"`
|
||||
}
|
|
@ -80,6 +80,12 @@ type ImageSummary = image.Summary
|
|||
// Deprecated: use [image.Metadata].
|
||||
type ImageMetadata = image.Metadata
|
||||
|
||||
// ServiceCreateResponse contains the information returned to a client
|
||||
// on the creation of a new service.
|
||||
//
|
||||
// Deprecated: use [swarm.ServiceCreateResponse].
|
||||
type ServiceCreateResponse = swarm.ServiceCreateResponse
|
||||
|
||||
// ServiceUpdateResponse service update response.
|
||||
//
|
||||
// Deprecated: use [swarm.ServiceUpdateResponse].
|
||||
|
|
|
@ -141,7 +141,7 @@ type PluginAPIClient interface {
|
|||
|
||||
// ServiceAPIClient defines API client methods for the services
|
||||
type ServiceAPIClient interface {
|
||||
ServiceCreate(ctx context.Context, service swarm.ServiceSpec, options types.ServiceCreateOptions) (types.ServiceCreateResponse, error)
|
||||
ServiceCreate(ctx context.Context, service swarm.ServiceSpec, options types.ServiceCreateOptions) (swarm.ServiceCreateResponse, error)
|
||||
ServiceInspectWithRaw(ctx context.Context, serviceID string, options types.ServiceInspectOptions) (swarm.Service, []byte, error)
|
||||
ServiceList(ctx context.Context, options types.ServiceListOptions) ([]swarm.Service, error)
|
||||
ServiceRemove(ctx context.Context, serviceID string) error
|
||||
|
|
|
@ -17,8 +17,8 @@ import (
|
|||
)
|
||||
|
||||
// ServiceCreate creates a new service.
|
||||
func (cli *Client) ServiceCreate(ctx context.Context, service swarm.ServiceSpec, options types.ServiceCreateOptions) (types.ServiceCreateResponse, error) {
|
||||
var response types.ServiceCreateResponse
|
||||
func (cli *Client) ServiceCreate(ctx context.Context, service swarm.ServiceSpec, options types.ServiceCreateOptions) (swarm.ServiceCreateResponse, error) {
|
||||
var response swarm.ServiceCreateResponse
|
||||
|
||||
// Make sure we negotiated (if the client is configured to do so),
|
||||
// as code below contains API-version specific handling of options.
|
||||
|
|
|
@ -38,7 +38,7 @@ func TestServiceCreate(t *testing.T) {
|
|||
if req.Method != http.MethodPost {
|
||||
return nil, fmt.Errorf("expected POST method, got %s", req.Method)
|
||||
}
|
||||
b, err := json.Marshal(types.ServiceCreateResponse{
|
||||
b, err := json.Marshal(swarm.ServiceCreateResponse{
|
||||
ID: "service_id",
|
||||
})
|
||||
if err != nil {
|
||||
|
@ -77,7 +77,7 @@ func TestServiceCreateCompatiblePlatforms(t *testing.T) {
|
|||
assert.Check(t, is.Len(serviceSpec.TaskTemplate.Placement.Platforms, 1))
|
||||
|
||||
p := serviceSpec.TaskTemplate.Placement.Platforms[0]
|
||||
b, err := json.Marshal(types.ServiceCreateResponse{
|
||||
b, err := json.Marshal(swarm.ServiceCreateResponse{
|
||||
ID: "service_" + p.OS + "_" + p.Architecture,
|
||||
})
|
||||
if err != nil {
|
||||
|
@ -153,7 +153,7 @@ func TestServiceCreateDigestPinning(t *testing.T) {
|
|||
}
|
||||
serviceCreateImage = service.TaskTemplate.ContainerSpec.Image
|
||||
|
||||
b, err := json.Marshal(types.ServiceCreateResponse{
|
||||
b, err := json.Marshal(swarm.ServiceCreateResponse{
|
||||
ID: "service_id",
|
||||
})
|
||||
if err != nil {
|
||||
|
|
|
@ -180,8 +180,8 @@ func (c *Cluster) GetService(input string, insertDefaults bool) (swarm.Service,
|
|||
}
|
||||
|
||||
// CreateService creates a new service in a managed swarm cluster.
|
||||
func (c *Cluster) CreateService(s swarm.ServiceSpec, encodedAuth string, queryRegistry bool) (*types.ServiceCreateResponse, error) {
|
||||
var resp *types.ServiceCreateResponse
|
||||
func (c *Cluster) CreateService(s swarm.ServiceSpec, encodedAuth string, queryRegistry bool) (*swarm.ServiceCreateResponse, error) {
|
||||
var resp *swarm.ServiceCreateResponse
|
||||
err := c.lockedManagerAction(func(ctx context.Context, state nodeState) error {
|
||||
err := c.populateNetworkID(ctx, state.controlClient, &s)
|
||||
if err != nil {
|
||||
|
@ -193,7 +193,7 @@ func (c *Cluster) CreateService(s swarm.ServiceSpec, encodedAuth string, queryRe
|
|||
return errdefs.InvalidParameter(err)
|
||||
}
|
||||
|
||||
resp = &types.ServiceCreateResponse{}
|
||||
resp = &swarm.ServiceCreateResponse{}
|
||||
|
||||
switch serviceSpec.Task.Runtime.(type) {
|
||||
case *swarmapi.TaskSpec_Attachment:
|
||||
|
|
|
@ -42,4 +42,5 @@ swagger generate operation -f api/swagger.yaml \
|
|||
|
||||
swagger generate model -f api/swagger.yaml \
|
||||
-t api -m types/swarm --skip-validator -C api/swagger-gen.yaml \
|
||||
-n ServiceCreateResponse \
|
||||
-n ServiceUpdateResponse
|
||||
|
|
Loading…
Reference in a new issue