client: rename ServiceListResult.Services to ServiceListResult.Items

Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
This commit is contained in:
Austin Vazquez
2025-10-22 15:51:27 -05:00
parent 00abc3a9d5
commit 5a5d39205c
6 changed files with 12 additions and 12 deletions

View File

@@ -19,7 +19,7 @@ type ServiceListOptions struct {
// ServiceListResult represents the result of a service list operation. // ServiceListResult represents the result of a service list operation.
type ServiceListResult struct { type ServiceListResult struct {
Services []swarm.Service Items []swarm.Service
} }
// ServiceList returns the list of services. // ServiceList returns the list of services.
@@ -40,5 +40,5 @@ func (cli *Client) ServiceList(ctx context.Context, options ServiceListOptions)
var services []swarm.Service var services []swarm.Service
err = json.NewDecoder(resp.Body).Decode(&services) err = json.NewDecoder(resp.Body).Decode(&services)
return ServiceListResult{Services: services}, err return ServiceListResult{Items: services}, err
} }

View File

@@ -77,6 +77,6 @@ func TestServiceList(t *testing.T) {
list, err := client.ServiceList(context.Background(), listCase.options) list, err := client.ServiceList(context.Background(), listCase.options)
assert.NilError(t, err) assert.NilError(t, err)
assert.Check(t, is.Len(list.Services, 2)) assert.Check(t, is.Len(list.Items, 2))
} }
} }

View File

@@ -337,10 +337,10 @@ func noServices(ctx context.Context, apiClient client.ServiceAPIClient) func(log
switch { switch {
case err != nil: case err != nil:
return poll.Error(err) return poll.Error(err)
case len(result.Services) == 0: case len(result.Items) == 0:
return poll.Success() return poll.Success()
default: default:
return poll.Continue("waiting for all services to be removed: service count at %d", len(result.Services)) return poll.Continue("waiting for all services to be removed: service count at %d", len(result.Items))
} }
} }
} }

View File

@@ -80,16 +80,16 @@ func TestServiceListWithStatuses(t *testing.T) {
// now, let's do the list operation with no status arg set. // now, let's do the list operation with no status arg set.
result, err := apiClient.ServiceList(ctx, client.ServiceListOptions{}) result, err := apiClient.ServiceList(ctx, client.ServiceListOptions{})
assert.NilError(t, err) assert.NilError(t, err)
assert.Check(t, is.Len(result.Services, serviceCount)) assert.Check(t, is.Len(result.Items, serviceCount))
for _, service := range result.Services { for _, service := range result.Items {
assert.Check(t, is.Nil(service.ServiceStatus)) assert.Check(t, is.Nil(service.ServiceStatus))
} }
// now try again, but with Status: true. This time, we should have statuses // now try again, but with Status: true. This time, we should have statuses
result, err = apiClient.ServiceList(ctx, client.ServiceListOptions{Status: true}) result, err = apiClient.ServiceList(ctx, client.ServiceListOptions{Status: true})
assert.NilError(t, err) assert.NilError(t, err)
assert.Check(t, is.Len(result.Services, serviceCount)) assert.Check(t, is.Len(result.Items, serviceCount))
for _, service := range result.Services { for _, service := range result.Items {
replicas := *service.Spec.Mode.Replicated.Replicas replicas := *service.Spec.Mode.Replicated.Replicas
assert.Assert(t, service.ServiceStatus != nil) assert.Assert(t, service.ServiceStatus != nil)

View File

@@ -107,7 +107,7 @@ func (d *Daemon) ListServices(ctx context.Context, t testing.TB) []swarm.Service
res, err := cli.ServiceList(ctx, client.ServiceListOptions{}) res, err := cli.ServiceList(ctx, client.ServiceListOptions{})
assert.NilError(t, err) assert.NilError(t, err)
return res.Services return res.Items
} }
// GetTask returns the swarm task identified by the specified id // GetTask returns the swarm task identified by the specified id

View File

@@ -19,7 +19,7 @@ type ServiceListOptions struct {
// ServiceListResult represents the result of a service list operation. // ServiceListResult represents the result of a service list operation.
type ServiceListResult struct { type ServiceListResult struct {
Services []swarm.Service Items []swarm.Service
} }
// ServiceList returns the list of services. // ServiceList returns the list of services.
@@ -40,5 +40,5 @@ func (cli *Client) ServiceList(ctx context.Context, options ServiceListOptions)
var services []swarm.Service var services []swarm.Service
err = json.NewDecoder(resp.Body).Decode(&services) err = json.NewDecoder(resp.Body).Decode(&services)
return ServiceListResult{Services: services}, err return ServiceListResult{Items: services}, err
} }