mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
client: refactor ServiceCreate, ServiceUpdate, SwarmUpdate
Put the version and spec in the options-struct, as we did for other swarm-related methods. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@@ -21,6 +21,7 @@ func (d *Daemon) createServiceWithOptions(ctx context.Context, t testing.TB, opt
|
||||
for _, fn := range f {
|
||||
fn(&service)
|
||||
}
|
||||
opts.Spec = service.Spec
|
||||
|
||||
cli := d.NewClientT(t)
|
||||
defer cli.Close()
|
||||
@@ -28,7 +29,7 @@ func (d *Daemon) createServiceWithOptions(ctx context.Context, t testing.TB, opt
|
||||
ctx, cancel := context.WithTimeout(ctx, 30*time.Second)
|
||||
defer cancel()
|
||||
|
||||
res, err := cli.ServiceCreate(ctx, service.Spec, opts)
|
||||
res, err := cli.ServiceCreate(ctx, opts)
|
||||
assert.NilError(t, err)
|
||||
return res.ID
|
||||
}
|
||||
@@ -78,14 +79,17 @@ func (d *Daemon) GetServiceTasksWithFilters(ctx context.Context, t testing.TB, s
|
||||
// UpdateService updates a swarm service with the specified service constructor
|
||||
func (d *Daemon) UpdateService(ctx context.Context, t testing.TB, service *swarm.Service, f ...ServiceConstructor) {
|
||||
t.Helper()
|
||||
cli := d.NewClientT(t)
|
||||
defer cli.Close()
|
||||
apiClient := d.NewClientT(t)
|
||||
defer apiClient.Close()
|
||||
|
||||
for _, fn := range f {
|
||||
fn(service)
|
||||
}
|
||||
|
||||
_, err := cli.ServiceUpdate(ctx, service.ID, service.Version, service.Spec, client.ServiceUpdateOptions{})
|
||||
_, err := apiClient.ServiceUpdate(ctx, service.ID, client.ServiceUpdateOptions{
|
||||
Version: service.Version,
|
||||
Spec: service.Spec,
|
||||
})
|
||||
assert.NilError(t, err)
|
||||
}
|
||||
|
||||
|
||||
@@ -205,8 +205,9 @@ func (d *Daemon) UpdateSwarm(t testing.TB, f ...SpecConstructor) {
|
||||
fn(&sw.Spec)
|
||||
}
|
||||
|
||||
_, err := cli.SwarmUpdate(context.Background(), sw.Version, client.SwarmUpdateOptions{
|
||||
Swarm: sw.Spec,
|
||||
_, err := cli.SwarmUpdate(t.Context(), client.SwarmUpdateOptions{
|
||||
Version: sw.Version,
|
||||
Spec: sw.Spec,
|
||||
})
|
||||
assert.NilError(t, err)
|
||||
}
|
||||
@@ -220,8 +221,9 @@ func (d *Daemon) RotateTokens(t testing.TB) {
|
||||
result, err := cli.SwarmInspect(t.Context(), client.SwarmInspectOptions{})
|
||||
assert.NilError(t, err)
|
||||
|
||||
_, err = cli.SwarmUpdate(t.Context(), result.Swarm.Version, client.SwarmUpdateOptions{
|
||||
Swarm: result.Swarm.Spec,
|
||||
_, err = cli.SwarmUpdate(t.Context(), client.SwarmUpdateOptions{
|
||||
Version: result.Swarm.Version,
|
||||
Spec: result.Swarm.Spec,
|
||||
RotateManagerToken: true,
|
||||
RotateWorkerToken: true,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user