diff --git a/api/types/swarm/service.go b/api/types/swarm/service.go index 381f55b79d..63e543a424 100644 --- a/api/types/swarm/service.go +++ b/api/types/swarm/service.go @@ -208,9 +208,3 @@ const ( RegistryAuthFromSpec = "spec" RegistryAuthFromPreviousSpec = "previous-spec" ) - -// ServiceInspectOptions holds parameters related to the "service inspect" -// operation. -type ServiceInspectOptions struct { - InsertDefaults bool -} diff --git a/client/client_interfaces.go b/client/client_interfaces.go index 2887b838ff..c686f535f5 100644 --- a/client/client_interfaces.go +++ b/client/client_interfaces.go @@ -163,7 +163,7 @@ type PluginAPIClient interface { // ServiceAPIClient defines API client methods for the services type ServiceAPIClient interface { ServiceCreate(ctx context.Context, service swarm.ServiceSpec, options ServiceCreateOptions) (swarm.ServiceCreateResponse, error) - ServiceInspectWithRaw(ctx context.Context, serviceID string, options swarm.ServiceInspectOptions) (swarm.Service, []byte, error) + ServiceInspectWithRaw(ctx context.Context, serviceID string, options ServiceInspectOptions) (swarm.Service, []byte, error) ServiceList(ctx context.Context, options ServiceListOptions) ([]swarm.Service, error) ServiceRemove(ctx context.Context, serviceID string) error ServiceUpdate(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error) diff --git a/client/service_inspect.go b/client/service_inspect.go index dab40392a2..ab79f91d34 100644 --- a/client/service_inspect.go +++ b/client/service_inspect.go @@ -12,7 +12,7 @@ import ( ) // ServiceInspectWithRaw returns the service information and the raw data. -func (cli *Client) ServiceInspectWithRaw(ctx context.Context, serviceID string, opts swarm.ServiceInspectOptions) (swarm.Service, []byte, error) { +func (cli *Client) ServiceInspectWithRaw(ctx context.Context, serviceID string, opts ServiceInspectOptions) (swarm.Service, []byte, error) { serviceID, err := trimID("service", serviceID) if err != nil { return swarm.Service{}, nil, err diff --git a/client/service_inspect_test.go b/client/service_inspect_test.go index 1ae93606c6..d3ddadb802 100644 --- a/client/service_inspect_test.go +++ b/client/service_inspect_test.go @@ -22,7 +22,7 @@ func TestServiceInspectError(t *testing.T) { client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), } - _, _, err := client.ServiceInspectWithRaw(context.Background(), "nothing", swarm.ServiceInspectOptions{}) + _, _, err := client.ServiceInspectWithRaw(context.Background(), "nothing", ServiceInspectOptions{}) assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal)) } @@ -31,7 +31,7 @@ func TestServiceInspectServiceNotFound(t *testing.T) { client: newMockClient(errorMock(http.StatusNotFound, "Server error")), } - _, _, err := client.ServiceInspectWithRaw(context.Background(), "unknown", swarm.ServiceInspectOptions{}) + _, _, err := client.ServiceInspectWithRaw(context.Background(), "unknown", ServiceInspectOptions{}) assert.Check(t, is.ErrorType(err, cerrdefs.IsNotFound)) } @@ -41,11 +41,11 @@ func TestServiceInspectWithEmptyID(t *testing.T) { return nil, errors.New("should not make request") }), } - _, _, err := client.ServiceInspectWithRaw(context.Background(), "", swarm.ServiceInspectOptions{}) + _, _, err := client.ServiceInspectWithRaw(context.Background(), "", ServiceInspectOptions{}) assert.Check(t, is.ErrorType(err, cerrdefs.IsInvalidArgument)) assert.Check(t, is.ErrorContains(err, "value is empty")) - _, _, err = client.ServiceInspectWithRaw(context.Background(), " ", swarm.ServiceInspectOptions{}) + _, _, err = client.ServiceInspectWithRaw(context.Background(), " ", ServiceInspectOptions{}) assert.Check(t, is.ErrorType(err, cerrdefs.IsInvalidArgument)) assert.Check(t, is.ErrorContains(err, "value is empty")) } @@ -70,7 +70,7 @@ func TestServiceInspect(t *testing.T) { }), } - serviceInspect, _, err := client.ServiceInspectWithRaw(context.Background(), "service_id", swarm.ServiceInspectOptions{}) + serviceInspect, _, err := client.ServiceInspectWithRaw(context.Background(), "service_id", ServiceInspectOptions{}) assert.NilError(t, err) assert.Check(t, is.Equal(serviceInspect.ID, "service_id")) } diff --git a/client/swarm_service_inspect_opts.go b/client/swarm_service_inspect_opts.go new file mode 100644 index 0000000000..691f3634e4 --- /dev/null +++ b/client/swarm_service_inspect_opts.go @@ -0,0 +1,7 @@ +package client + +// ServiceInspectOptions holds parameters related to the "service inspect" +// operation. +type ServiceInspectOptions struct { + InsertDefaults bool +} diff --git a/integration-cli/docker_api_swarm_service_test.go b/integration-cli/docker_api_swarm_service_test.go index 77b8cb2f9a..2924001beb 100644 --- a/integration-cli/docker_api_swarm_service_test.go +++ b/integration-cli/docker_api_swarm_service_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/moby/moby/api/types/swarm" + "github.com/moby/moby/client" "github.com/moby/moby/v2/integration-cli/checker" "github.com/moby/moby/v2/integration-cli/cli" "github.com/moby/moby/v2/integration-cli/cli/build" @@ -71,19 +72,19 @@ func (s *DockerSwarmSuite) TestAPISwarmServicesCreate(c *testing.T) { id := d.CreateService(ctx, c, simpleTestService, setInstances(instances)) poll.WaitOn(c, pollCheck(c, d.CheckActiveContainerCount(ctx), checker.Equals(instances)), poll.WithTimeout(defaultReconciliationTimeout)) - client := d.NewClientT(c) - defer client.Close() + apiClient := d.NewClientT(c) + defer apiClient.Close() - options := swarm.ServiceInspectOptions{InsertDefaults: true} + options := client.ServiceInspectOptions{InsertDefaults: true} // insertDefaults inserts UpdateConfig when service is fetched by ID - resp, _, err := client.ServiceInspectWithRaw(ctx, id, options) + resp, _, err := apiClient.ServiceInspectWithRaw(ctx, id, options) out := fmt.Sprintf("%+v", resp) assert.NilError(c, err) assert.Assert(c, is.Contains(out, "UpdateConfig")) // insertDefaults inserts UpdateConfig when service is fetched by ID - resp, _, err = client.ServiceInspectWithRaw(ctx, "top", options) + resp, _, err = apiClient.ServiceInspectWithRaw(ctx, "top", options) out = fmt.Sprintf("%+v", resp) assert.NilError(c, err) assert.Assert(c, is.Contains(out, "UpdateConfig")) diff --git a/integration/network/service_test.go b/integration/network/service_test.go index c750ddc703..3092c55ac7 100644 --- a/integration/network/service_test.go +++ b/integration/network/service_test.go @@ -245,7 +245,7 @@ func TestServiceWithPredefinedNetwork(t *testing.T) { poll.WaitOn(t, swarm.RunningTasksCount(ctx, c, serviceID, instances), swarm.ServicePoll) - _, _, err := c.ServiceInspectWithRaw(ctx, serviceID, swarmtypes.ServiceInspectOptions{}) + _, _, err := c.ServiceInspectWithRaw(ctx, serviceID, client.ServiceInspectOptions{}) assert.NilError(t, err) err = c.ServiceRemove(ctx, serviceID) @@ -286,7 +286,7 @@ func TestServiceRemoveKeepsIngressNetwork(t *testing.T) { poll.WaitOn(t, swarm.RunningTasksCount(ctx, c, serviceID, instances), swarm.ServicePoll) - _, _, err := c.ServiceInspectWithRaw(ctx, serviceID, swarmtypes.ServiceInspectOptions{}) + _, _, err := c.ServiceInspectWithRaw(ctx, serviceID, client.ServiceInspectOptions{}) assert.NilError(t, err) err = c.ServiceRemove(ctx, serviceID) @@ -440,7 +440,7 @@ func TestServiceWithDefaultAddressPoolInit(t *testing.T) { poll.WaitOn(t, swarm.RunningTasksCount(ctx, cli, serviceID, instances), swarm.ServicePoll) - _, _, err := cli.ServiceInspectWithRaw(ctx, serviceID, swarmtypes.ServiceInspectOptions{}) + _, _, err := cli.ServiceInspectWithRaw(ctx, serviceID, client.ServiceInspectOptions{}) assert.NilError(t, err) out, err := cli.NetworkInspect(ctx, overlayID, client.NetworkInspectOptions{Verbose: true}) diff --git a/integration/service/create_test.go b/integration/service/create_test.go index 494ca17fb9..08b5976369 100644 --- a/integration/service/create_test.go +++ b/integration/service/create_test.go @@ -101,7 +101,7 @@ func TestCreateServiceMultipleTimes(t *testing.T) { serviceID := swarm.CreateService(ctx, t, d, serviceSpec...) poll.WaitOn(t, swarm.RunningTasksCount(ctx, apiClient, serviceID, instances), swarm.ServicePoll) - _, _, err := apiClient.ServiceInspectWithRaw(ctx, serviceID, swarmtypes.ServiceInspectOptions{}) + _, _, err := apiClient.ServiceInspectWithRaw(ctx, serviceID, client.ServiceInspectOptions{}) assert.NilError(t, err) err = apiClient.ServiceRemove(ctx, serviceID) @@ -186,7 +186,7 @@ func TestCreateServiceMaxReplicas(t *testing.T) { serviceID := swarm.CreateService(ctx, t, d, serviceSpec...) poll.WaitOn(t, swarm.RunningTasksCount(ctx, apiClient, serviceID, maxReplicas), swarm.ServicePoll) - _, _, err := apiClient.ServiceInspectWithRaw(ctx, serviceID, swarmtypes.ServiceInspectOptions{}) + _, _, err := apiClient.ServiceInspectWithRaw(ctx, serviceID, client.ServiceInspectOptions{}) assert.NilError(t, err) } @@ -382,7 +382,7 @@ func TestCreateServiceSysctls(t *testing.T) { assert.DeepEqual(t, tasks[0].Spec.ContainerSpec.Sysctls, expectedSysctls) // verify that the service also has the sysctl set in the spec. - service, _, err := apiClient.ServiceInspectWithRaw(ctx, serviceID, swarmtypes.ServiceInspectOptions{}) + service, _, err := apiClient.ServiceInspectWithRaw(ctx, serviceID, client.ServiceInspectOptions{}) assert.NilError(t, err) assert.DeepEqual(t, service.Spec.TaskTemplate.ContainerSpec.Sysctls, expectedSysctls, @@ -454,7 +454,7 @@ func TestCreateServiceCapabilities(t *testing.T) { assert.DeepEqual(t, tasks[0].Spec.ContainerSpec.CapabilityDrop, capDrop) // verify that the service also has the capabilities set in the spec. - service, _, err := apiClient.ServiceInspectWithRaw(ctx, serviceID, swarmtypes.ServiceInspectOptions{}) + service, _, err := apiClient.ServiceInspectWithRaw(ctx, serviceID, client.ServiceInspectOptions{}) assert.NilError(t, err) assert.DeepEqual(t, service.Spec.TaskTemplate.ContainerSpec.CapabilityAdd, capAdd) assert.DeepEqual(t, service.Spec.TaskTemplate.ContainerSpec.CapabilityDrop, capDrop) diff --git a/integration/service/inspect_test.go b/integration/service/inspect_test.go index a9b7c4aa51..2b79f98a05 100644 --- a/integration/service/inspect_test.go +++ b/integration/service/inspect_test.go @@ -36,7 +36,7 @@ func TestInspect(t *testing.T) { id := resp.ID poll.WaitOn(t, swarm.RunningTasksCount(ctx, apiClient, id, instances)) - service, _, err := apiClient.ServiceInspectWithRaw(ctx, id, swarmtypes.ServiceInspectOptions{}) + service, _, err := apiClient.ServiceInspectWithRaw(ctx, id, client.ServiceInspectOptions{}) assert.NilError(t, err) expected := swarmtypes.Service{ diff --git a/integration/service/jobs_test.go b/integration/service/jobs_test.go index 8e50989639..9b1ee1f60b 100644 --- a/integration/service/jobs_test.go +++ b/integration/service/jobs_test.go @@ -60,8 +60,8 @@ func TestReplicatedJob(t *testing.T) { d := swarm.NewSwarm(ctx, t, testEnv) defer d.Stop(t) - client := d.NewClientT(t) - defer client.Close() + apiClient := d.NewClientT(t) + defer apiClient.Close() id := swarm.CreateService(ctx, t, d, swarm.ServiceWithMode(swarmtypes.ServiceMode{ @@ -74,12 +74,12 @@ func TestReplicatedJob(t *testing.T) { swarm.ServiceWithCommand([]string{"true"}), ) - service, _, err := client.ServiceInspectWithRaw( - ctx, id, swarmtypes.ServiceInspectOptions{}, + service, _, err := apiClient.ServiceInspectWithRaw( + ctx, id, client.ServiceInspectOptions{}, ) assert.NilError(t, err) - poll.WaitOn(t, swarm.JobComplete(ctx, client, service), swarm.ServicePoll) + poll.WaitOn(t, swarm.JobComplete(ctx, apiClient, service), swarm.ServicePoll) } // TestUpdateReplicatedJob tests that a job can be updated, and that it runs with the @@ -108,7 +108,7 @@ func TestUpdateReplicatedJob(t *testing.T) { ) service, _, err := apiClient.ServiceInspectWithRaw( - ctx, id, swarmtypes.ServiceInspectOptions{}, + ctx, id, client.ServiceInspectOptions{}, ) assert.NilError(t, err) @@ -125,7 +125,7 @@ func TestUpdateReplicatedJob(t *testing.T) { assert.NilError(t, err) service2, _, err := apiClient.ServiceInspectWithRaw( - ctx, id, swarmtypes.ServiceInspectOptions{}, + ctx, id, client.ServiceInspectOptions{}, ) assert.NilError(t, err) diff --git a/integration/service/update_test.go b/integration/service/update_test.go index 4cffb7693b..b42d345d02 100644 --- a/integration/service/update_test.go +++ b/integration/service/update_test.go @@ -341,14 +341,14 @@ func getServiceTaskContainer(ctx context.Context, t *testing.T, cli client.APICl func getService(ctx context.Context, t *testing.T, cli client.ServiceAPIClient, serviceID string) swarmtypes.Service { t.Helper() - service, _, err := cli.ServiceInspectWithRaw(ctx, serviceID, swarmtypes.ServiceInspectOptions{}) + service, _, err := cli.ServiceInspectWithRaw(ctx, serviceID, client.ServiceInspectOptions{}) assert.NilError(t, err) return service } -func serviceIsUpdated(ctx context.Context, client client.ServiceAPIClient, serviceID string) func(log poll.LogT) poll.Result { +func serviceIsUpdated(ctx context.Context, apiClient client.ServiceAPIClient, serviceID string) func(log poll.LogT) poll.Result { return func(log poll.LogT) poll.Result { - service, _, err := client.ServiceInspectWithRaw(ctx, serviceID, swarmtypes.ServiceInspectOptions{}) + service, _, err := apiClient.ServiceInspectWithRaw(ctx, serviceID, client.ServiceInspectOptions{}) switch { case err != nil: return poll.Error(err) @@ -363,9 +363,9 @@ func serviceIsUpdated(ctx context.Context, client client.ServiceAPIClient, servi } } -func serviceSpecIsUpdated(ctx context.Context, client client.ServiceAPIClient, serviceID string, serviceOldVersion uint64) func(log poll.LogT) poll.Result { +func serviceSpecIsUpdated(ctx context.Context, apiClient client.ServiceAPIClient, serviceID string, serviceOldVersion uint64) func(log poll.LogT) poll.Result { return func(log poll.LogT) poll.Result { - service, _, err := client.ServiceInspectWithRaw(ctx, serviceID, swarmtypes.ServiceInspectOptions{}) + service, _, err := apiClient.ServiceInspectWithRaw(ctx, serviceID, client.ServiceInspectOptions{}) switch { case err != nil: return poll.Error(err) diff --git a/testutil/daemon/service.go b/testutil/daemon/service.go index df6a0b3acf..5c9bb2dcd8 100644 --- a/testutil/daemon/service.go +++ b/testutil/daemon/service.go @@ -44,7 +44,7 @@ func (d *Daemon) GetService(ctx context.Context, t testing.TB, id string) *swarm cli := d.NewClientT(t) defer cli.Close() - service, _, err := cli.ServiceInspectWithRaw(ctx, id, swarm.ServiceInspectOptions{}) + service, _, err := cli.ServiceInspectWithRaw(ctx, id, client.ServiceInspectOptions{}) assert.NilError(t, err) return &service } diff --git a/vendor/github.com/moby/moby/api/types/swarm/service.go b/vendor/github.com/moby/moby/api/types/swarm/service.go index 381f55b79d..63e543a424 100644 --- a/vendor/github.com/moby/moby/api/types/swarm/service.go +++ b/vendor/github.com/moby/moby/api/types/swarm/service.go @@ -208,9 +208,3 @@ const ( RegistryAuthFromSpec = "spec" RegistryAuthFromPreviousSpec = "previous-spec" ) - -// ServiceInspectOptions holds parameters related to the "service inspect" -// operation. -type ServiceInspectOptions struct { - InsertDefaults bool -} diff --git a/vendor/github.com/moby/moby/client/client_interfaces.go b/vendor/github.com/moby/moby/client/client_interfaces.go index 2887b838ff..c686f535f5 100644 --- a/vendor/github.com/moby/moby/client/client_interfaces.go +++ b/vendor/github.com/moby/moby/client/client_interfaces.go @@ -163,7 +163,7 @@ type PluginAPIClient interface { // ServiceAPIClient defines API client methods for the services type ServiceAPIClient interface { ServiceCreate(ctx context.Context, service swarm.ServiceSpec, options ServiceCreateOptions) (swarm.ServiceCreateResponse, error) - ServiceInspectWithRaw(ctx context.Context, serviceID string, options swarm.ServiceInspectOptions) (swarm.Service, []byte, error) + ServiceInspectWithRaw(ctx context.Context, serviceID string, options ServiceInspectOptions) (swarm.Service, []byte, error) ServiceList(ctx context.Context, options ServiceListOptions) ([]swarm.Service, error) ServiceRemove(ctx context.Context, serviceID string) error ServiceUpdate(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error) diff --git a/vendor/github.com/moby/moby/client/service_inspect.go b/vendor/github.com/moby/moby/client/service_inspect.go index dab40392a2..ab79f91d34 100644 --- a/vendor/github.com/moby/moby/client/service_inspect.go +++ b/vendor/github.com/moby/moby/client/service_inspect.go @@ -12,7 +12,7 @@ import ( ) // ServiceInspectWithRaw returns the service information and the raw data. -func (cli *Client) ServiceInspectWithRaw(ctx context.Context, serviceID string, opts swarm.ServiceInspectOptions) (swarm.Service, []byte, error) { +func (cli *Client) ServiceInspectWithRaw(ctx context.Context, serviceID string, opts ServiceInspectOptions) (swarm.Service, []byte, error) { serviceID, err := trimID("service", serviceID) if err != nil { return swarm.Service{}, nil, err diff --git a/vendor/github.com/moby/moby/client/swarm_service_inspect_opts.go b/vendor/github.com/moby/moby/client/swarm_service_inspect_opts.go new file mode 100644 index 0000000000..691f3634e4 --- /dev/null +++ b/vendor/github.com/moby/moby/client/swarm_service_inspect_opts.go @@ -0,0 +1,7 @@ +package client + +// ServiceInspectOptions holds parameters related to the "service inspect" +// operation. +type ServiceInspectOptions struct { + InsertDefaults bool +}