mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
api/types/swarm: move ServiceInspectOptions type to client
Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
This commit is contained in:
@@ -208,9 +208,3 @@ const (
|
||||
RegistryAuthFromSpec = "spec"
|
||||
RegistryAuthFromPreviousSpec = "previous-spec"
|
||||
)
|
||||
|
||||
// ServiceInspectOptions holds parameters related to the "service inspect"
|
||||
// operation.
|
||||
type ServiceInspectOptions struct {
|
||||
InsertDefaults bool
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"))
|
||||
}
|
||||
|
||||
7
client/swarm_service_inspect_opts.go
Normal file
7
client/swarm_service_inspect_opts.go
Normal file
@@ -0,0 +1,7 @@
|
||||
package client
|
||||
|
||||
// ServiceInspectOptions holds parameters related to the "service inspect"
|
||||
// operation.
|
||||
type ServiceInspectOptions struct {
|
||||
InsertDefaults bool
|
||||
}
|
||||
@@ -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"))
|
||||
|
||||
@@ -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})
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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{
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
6
vendor/github.com/moby/moby/api/types/swarm/service.go
generated
vendored
6
vendor/github.com/moby/moby/api/types/swarm/service.go
generated
vendored
@@ -208,9 +208,3 @@ const (
|
||||
RegistryAuthFromSpec = "spec"
|
||||
RegistryAuthFromPreviousSpec = "previous-spec"
|
||||
)
|
||||
|
||||
// ServiceInspectOptions holds parameters related to the "service inspect"
|
||||
// operation.
|
||||
type ServiceInspectOptions struct {
|
||||
InsertDefaults bool
|
||||
}
|
||||
|
||||
2
vendor/github.com/moby/moby/client/client_interfaces.go
generated
vendored
2
vendor/github.com/moby/moby/client/client_interfaces.go
generated
vendored
@@ -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)
|
||||
|
||||
2
vendor/github.com/moby/moby/client/service_inspect.go
generated
vendored
2
vendor/github.com/moby/moby/client/service_inspect.go
generated
vendored
@@ -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
|
||||
|
||||
7
vendor/github.com/moby/moby/client/swarm_service_inspect_opts.go
generated
vendored
Normal file
7
vendor/github.com/moby/moby/client/swarm_service_inspect_opts.go
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
package client
|
||||
|
||||
// ServiceInspectOptions holds parameters related to the "service inspect"
|
||||
// operation.
|
||||
type ServiceInspectOptions struct {
|
||||
InsertDefaults bool
|
||||
}
|
||||
Reference in New Issue
Block a user