Skip to content

Commit 31d6293

Browse files
committed
api/types: move ServiceCreateOptions to api/types/swarm
Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 5ad0867 commit 31d6293

12 files changed

Lines changed: 34 additions & 34 deletions

File tree

api/types/client.go

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,6 @@ func (h *HijackedResponse) CloseWrite() error {
4646
return nil
4747
}
4848

49-
// ServiceCreateOptions contains the options to use when creating a service.
50-
type ServiceCreateOptions struct {
51-
// EncodedRegistryAuth is the encoded registry authorization credentials to
52-
// use when updating the service.
53-
//
54-
// This field follows the format of the X-Registry-Auth header.
55-
EncodedRegistryAuth string
56-
57-
// QueryRegistry indicates whether the service update requires
58-
// contacting a registry. A registry may be contacted to retrieve
59-
// the image digest and manifest, which in turn can be used to update
60-
// platform or other information about the service.
61-
QueryRegistry bool
62-
}
63-
6449
// Values for RegistryAuthFrom in ServiceUpdateOptions
6550
const (
6651
RegistryAuthFromSpec = "spec"

api/types/swarm/service.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,21 @@ type JobStatus struct {
205205
LastExecution time.Time `json:",omitempty"`
206206
}
207207

208+
// ServiceCreateOptions contains the options to use when creating a service.
209+
type ServiceCreateOptions struct {
210+
// EncodedRegistryAuth is the encoded registry authorization credentials to
211+
// use when updating the service.
212+
//
213+
// This field follows the format of the X-Registry-Auth header.
214+
EncodedRegistryAuth string
215+
216+
// QueryRegistry indicates whether the service update requires
217+
// contacting a registry. A registry may be contacted to retrieve
218+
// the image digest and manifest, which in turn can be used to update
219+
// platform or other information about the service.
220+
QueryRegistry bool
221+
}
222+
208223
// ServiceListOptions holds parameters to list services with.
209224
type ServiceListOptions struct {
210225
Filters filters.Args

api/types/types_deprecated.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,11 @@ type NodeRemoveOptions = swarm.NodeRemoveOptions
153153
// Deprecated: use [swarm.TaskListOptions].
154154
type TaskListOptions = swarm.TaskListOptions
155155

156+
// ServiceCreateOptions contains the options to use when creating a service.
157+
//
158+
// Deprecated: use [swarm.ServiceCreateOptions].
159+
type ServiceCreateOptions = swarm.ServiceCreateOptions
160+
156161
// ServiceListOptions holds parameters to list services with.
157162
//
158163
// Deprecated: use [swarm.ServiceListOptions].

client/client_interfaces.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ type PluginAPIClient interface {
176176

177177
// ServiceAPIClient defines API client methods for the services
178178
type ServiceAPIClient interface {
179-
ServiceCreate(ctx context.Context, service swarm.ServiceSpec, options types.ServiceCreateOptions) (swarm.ServiceCreateResponse, error)
179+
ServiceCreate(ctx context.Context, service swarm.ServiceSpec, options swarm.ServiceCreateOptions) (swarm.ServiceCreateResponse, error)
180180
ServiceInspectWithRaw(ctx context.Context, serviceID string, options swarm.ServiceInspectOptions) (swarm.Service, []byte, error)
181181
ServiceList(ctx context.Context, options swarm.ServiceListOptions) ([]swarm.Service, error)
182182
ServiceRemove(ctx context.Context, serviceID string) error

client/service_create.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"strings"
99

1010
"github.com/distribution/reference"
11-
"github.com/docker/docker/api/types"
1211
"github.com/docker/docker/api/types/registry"
1312
"github.com/docker/docker/api/types/swarm"
1413
"github.com/docker/docker/api/types/versions"
@@ -17,7 +16,7 @@ import (
1716
)
1817

1918
// ServiceCreate creates a new service.
20-
func (cli *Client) ServiceCreate(ctx context.Context, service swarm.ServiceSpec, options types.ServiceCreateOptions) (swarm.ServiceCreateResponse, error) {
19+
func (cli *Client) ServiceCreate(ctx context.Context, service swarm.ServiceSpec, options swarm.ServiceCreateOptions) (swarm.ServiceCreateResponse, error) {
2120
var response swarm.ServiceCreateResponse
2221

2322
// Make sure we negotiated (if the client is configured to do so),

client/service_create_test.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"strings"
1111
"testing"
1212

13-
"github.com/docker/docker/api/types"
1413
registrytypes "github.com/docker/docker/api/types/registry"
1514
"github.com/docker/docker/api/types/swarm"
1615
"github.com/docker/docker/errdefs"
@@ -24,7 +23,7 @@ func TestServiceCreateError(t *testing.T) {
2423
client := &Client{
2524
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
2625
}
27-
_, err := client.ServiceCreate(context.Background(), swarm.ServiceSpec{}, types.ServiceCreateOptions{})
26+
_, err := client.ServiceCreate(context.Background(), swarm.ServiceSpec{}, swarm.ServiceCreateOptions{})
2827
assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
2928
}
3029

@@ -36,7 +35,7 @@ func TestServiceCreateConnectionError(t *testing.T) {
3635
client, err := NewClientWithOpts(WithAPIVersionNegotiation(), WithHost("tcp://no-such-host.invalid"))
3736
assert.NilError(t, err)
3837

39-
_, err = client.ServiceCreate(context.Background(), swarm.ServiceSpec{}, types.ServiceCreateOptions{})
38+
_, err = client.ServiceCreate(context.Background(), swarm.ServiceSpec{}, swarm.ServiceCreateOptions{})
4039
assert.Check(t, is.ErrorType(err, IsErrConnectionFailed))
4140
}
4241

@@ -63,7 +62,7 @@ func TestServiceCreate(t *testing.T) {
6362
}),
6463
}
6564

66-
r, err := client.ServiceCreate(context.Background(), swarm.ServiceSpec{}, types.ServiceCreateOptions{})
65+
r, err := client.ServiceCreate(context.Background(), swarm.ServiceSpec{}, swarm.ServiceCreateOptions{})
6766
assert.NilError(t, err)
6867
assert.Check(t, is.Equal(r.ID, "service_id"))
6968
}
@@ -122,7 +121,7 @@ func TestServiceCreateCompatiblePlatforms(t *testing.T) {
122121

123122
spec := swarm.ServiceSpec{TaskTemplate: swarm.TaskSpec{ContainerSpec: &swarm.ContainerSpec{Image: "foobar:1.0"}}}
124123

125-
r, err := client.ServiceCreate(context.Background(), spec, types.ServiceCreateOptions{QueryRegistry: true})
124+
r, err := client.ServiceCreate(context.Background(), spec, swarm.ServiceCreateOptions{QueryRegistry: true})
126125
assert.NilError(t, err)
127126
assert.Check(t, is.Equal("service_linux_amd64", r.ID))
128127
}
@@ -201,7 +200,7 @@ func TestServiceCreateDigestPinning(t *testing.T) {
201200
Image: p.img,
202201
},
203202
},
204-
}, types.ServiceCreateOptions{QueryRegistry: true})
203+
}, swarm.ServiceCreateOptions{QueryRegistry: true})
205204
assert.NilError(t, err)
206205

207206
assert.Check(t, is.Equal(r.ID, "service_id"))

integration-cli/docker_api_swarm_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ func (s *DockerSwarmSuite) TestAPISwarmRaftQuorum(c *testing.T) {
414414

415415
// d1 will eventually step down from leader because there is no longer an active quorum, wait for that to happen
416416
poll.WaitOn(c, pollCheck(c, func(c *testing.T) (interface{}, string) {
417-
_, err := cli.ServiceCreate(testutil.GetContext(c), service.Spec, types.ServiceCreateOptions{})
417+
_, err := cli.ServiceCreate(testutil.GetContext(c), service.Spec, swarm.ServiceCreateOptions{})
418418
return err.Error(), ""
419419
}, checker.Contains("Make sure more than half of the managers are online.")), poll.WithTimeout(defaultReconciliationTimeout*2))
420420

integration/internal/swarm/service.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func CreateService(ctx context.Context, t *testing.T, d *daemon.Daemon, opts ...
6464
defer apiClient.Close()
6565

6666
spec := CreateServiceSpec(t, opts...)
67-
resp, err := apiClient.ServiceCreate(ctx, spec, types.ServiceCreateOptions{})
67+
resp, err := apiClient.ServiceCreate(ctx, spec, swarmtypes.ServiceCreateOptions{})
6868
assert.NilError(t, err, "error creating service")
6969
return resp.ID
7070
}

integration/service/create_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"testing"
88
"time"
99

10-
"github.com/docker/docker/api/types"
1110
"github.com/docker/docker/api/types/container"
1211
"github.com/docker/docker/api/types/filters"
1312
swarmtypes "github.com/docker/docker/api/types/swarm"
@@ -165,7 +164,7 @@ func TestCreateServiceConflict(t *testing.T) {
165164
swarm.CreateService(ctx, t, d, serviceSpec...)
166165

167166
spec := swarm.CreateServiceSpec(t, serviceSpec...)
168-
_, err := c.ServiceCreate(ctx, spec, types.ServiceCreateOptions{})
167+
_, err := c.ServiceCreate(ctx, spec, swarmtypes.ServiceCreateOptions{})
169168
assert.Check(t, errdefs.IsConflict(err))
170169
assert.ErrorContains(t, err, "service "+serviceName+" already exists")
171170
}

integration/service/inspect_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"testing"
55
"time"
66

7-
"github.com/docker/docker/api/types"
87
"github.com/docker/docker/api/types/container"
98
swarmtypes "github.com/docker/docker/api/types/swarm"
109
"github.com/docker/docker/integration/internal/swarm"
@@ -28,7 +27,7 @@ func TestInspect(t *testing.T) {
2827
var instances uint64 = 2
2928
serviceSpec := fullSwarmServiceSpec("test-service-inspect"+t.Name(), instances)
3029

31-
resp, err := client.ServiceCreate(ctx, serviceSpec, types.ServiceCreateOptions{
30+
resp, err := client.ServiceCreate(ctx, serviceSpec, swarmtypes.ServiceCreateOptions{
3231
QueryRegistry: false,
3332
})
3433
assert.NilError(t, err)

0 commit comments

Comments
 (0)