Skip to content

Commit 5ad0867

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

16 files changed

Lines changed: 32 additions & 33 deletions

File tree

api/server/router/swarm/backend.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ type Backend interface {
2828
GetNode(string) (swarm.Node, error)
2929
UpdateNode(string, uint64, swarm.NodeSpec) error
3030
RemoveNode(string, bool) error
31-
GetTasks(types.TaskListOptions) ([]swarm.Task, error)
31+
GetTasks(swarm.TaskListOptions) ([]swarm.Task, error)
3232
GetTask(string) (swarm.Task, error)
3333
GetSecrets(opts swarm.SecretListOptions) ([]swarm.Secret, error)
3434
CreateSecret(s swarm.SecretSpec) (string, error)

api/server/router/swarm/cluster_routes.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ func (sr *swarmRouter) getTasks(ctx context.Context, w http.ResponseWriter, r *h
385385
return err
386386
}
387387

388-
tasks, err := sr.backend.GetTasks(basictypes.TaskListOptions{Filters: filter})
388+
tasks, err := sr.backend.GetTasks(types.TaskListOptions{Filters: filter})
389389
if err != nil {
390390
log.G(ctx).WithContext(ctx).WithError(err).Debug("Error getting tasks")
391391
return err

api/types/client.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import (
44
"bufio"
55
"context"
66
"net"
7-
8-
"github.com/docker/docker/api/types/filters"
97
)
108

119
// NewHijackedResponse initializes a [HijackedResponse] type.
@@ -99,11 +97,6 @@ type ServiceUpdateOptions struct {
9997
QueryRegistry bool
10098
}
10199

102-
// TaskListOptions holds parameters to list tasks with.
103-
type TaskListOptions struct {
104-
Filters filters.Args
105-
}
106-
107100
// PluginRemoveOptions holds parameters to remove plugins.
108101
type PluginRemoveOptions struct {
109102
Force bool

api/types/swarm/task.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package swarm // import "github.com/docker/docker/api/types/swarm"
33
import (
44
"time"
55

6+
"github.com/docker/docker/api/types/filters"
67
"github.com/docker/docker/api/types/swarm/runtime"
78
)
89

@@ -223,3 +224,8 @@ type VolumeAttachment struct {
223224
// in the ContainerSpec, that this volume fulfills.
224225
Target string `json:",omitempty"`
225226
}
227+
228+
// TaskListOptions holds parameters to list tasks with.
229+
type TaskListOptions struct {
230+
Filters filters.Args
231+
}

api/types/types_deprecated.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,11 @@ type NodeListOptions = swarm.NodeListOptions
148148
// Deprecated: use [swarm.NodeRemoveOptions].
149149
type NodeRemoveOptions = swarm.NodeRemoveOptions
150150

151+
// TaskListOptions holds parameters to list tasks with.
152+
//
153+
// Deprecated: use [swarm.TaskListOptions].
154+
type TaskListOptions = swarm.TaskListOptions
155+
151156
// ServiceListOptions holds parameters to list services with.
152157
//
153158
// Deprecated: use [swarm.ServiceListOptions].

client/client_interfaces.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ type ServiceAPIClient interface {
184184
ServiceLogs(ctx context.Context, serviceID string, options container.LogsOptions) (io.ReadCloser, error)
185185
TaskLogs(ctx context.Context, taskID string, options container.LogsOptions) (io.ReadCloser, error)
186186
TaskInspectWithRaw(ctx context.Context, taskID string) (swarm.Task, []byte, error)
187-
TaskList(ctx context.Context, options types.TaskListOptions) ([]swarm.Task, error)
187+
TaskList(ctx context.Context, options swarm.TaskListOptions) ([]swarm.Task, error)
188188
}
189189

190190
// SwarmAPIClient defines API client methods for the swarm

client/task_list.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@ import (
55
"encoding/json"
66
"net/url"
77

8-
"github.com/docker/docker/api/types"
98
"github.com/docker/docker/api/types/filters"
109
"github.com/docker/docker/api/types/swarm"
1110
)
1211

1312
// TaskList returns the list of tasks.
14-
func (cli *Client) TaskList(ctx context.Context, options types.TaskListOptions) ([]swarm.Task, error) {
13+
func (cli *Client) TaskList(ctx context.Context, options swarm.TaskListOptions) ([]swarm.Task, error) {
1514
query := url.Values{}
1615

1716
if options.Filters.Len() > 0 {

client/task_list_test.go

Lines changed: 4 additions & 5 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
"github.com/docker/docker/api/types/filters"
1514
"github.com/docker/docker/api/types/swarm"
1615
"github.com/docker/docker/errdefs"
@@ -23,25 +22,25 @@ func TestTaskListError(t *testing.T) {
2322
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
2423
}
2524

26-
_, err := client.TaskList(context.Background(), types.TaskListOptions{})
25+
_, err := client.TaskList(context.Background(), swarm.TaskListOptions{})
2726
assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
2827
}
2928

3029
func TestTaskList(t *testing.T) {
3130
const expectedURL = "/tasks"
3231

3332
listCases := []struct {
34-
options types.TaskListOptions
33+
options swarm.TaskListOptions
3534
expectedQueryParams map[string]string
3635
}{
3736
{
38-
options: types.TaskListOptions{},
37+
options: swarm.TaskListOptions{},
3938
expectedQueryParams: map[string]string{
4039
"filters": "",
4140
},
4241
},
4342
{
44-
options: types.TaskListOptions{
43+
options: swarm.TaskListOptions{
4544
Filters: filters.NewArgs(
4645
filters.Arg("label", "label1"),
4746
filters.Arg("label", "label2"),

daemon/cluster/tasks.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package cluster // import "github.com/docker/docker/daemon/cluster"
33
import (
44
"context"
55

6-
apitypes "github.com/docker/docker/api/types"
76
"github.com/docker/docker/api/types/filters"
87
types "github.com/docker/docker/api/types/swarm"
98
"github.com/docker/docker/daemon/cluster/convert"
@@ -12,7 +11,7 @@ import (
1211
)
1312

1413
// GetTasks returns a list of tasks matching the filter options.
15-
func (c *Cluster) GetTasks(options apitypes.TaskListOptions) ([]types.Task, error) {
14+
func (c *Cluster) GetTasks(options types.TaskListOptions) ([]types.Task, error) {
1615
var r *swarmapi.ListTasksResponse
1716

1817
err := c.lockedManagerAction(func(ctx context.Context, state nodeState) error {

integration-cli/daemon/daemon_swarm.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"strings"
77
"testing"
88

9-
"github.com/docker/docker/api/types"
109
"github.com/docker/docker/api/types/filters"
1110
"github.com/docker/docker/api/types/swarm"
1211
"github.com/docker/docker/errdefs"
@@ -103,7 +102,7 @@ func (d *Daemon) CheckRunningTaskNetworks(ctx context.Context) func(t *testing.T
103102
cli := d.NewClientT(t)
104103
defer cli.Close()
105104

106-
tasks, err := cli.TaskList(ctx, types.TaskListOptions{
105+
tasks, err := cli.TaskList(ctx, swarm.TaskListOptions{
107106
Filters: filters.NewArgs(filters.Arg("desired-state", "running")),
108107
})
109108
assert.NilError(t, err)
@@ -124,7 +123,7 @@ func (d *Daemon) CheckRunningTaskImages(ctx context.Context) func(t *testing.T)
124123
cli := d.NewClientT(t)
125124
defer cli.Close()
126125

127-
tasks, err := cli.TaskList(ctx, types.TaskListOptions{
126+
tasks, err := cli.TaskList(ctx, swarm.TaskListOptions{
128127
Filters: filters.NewArgs(filters.Arg("desired-state", "running")),
129128
})
130129
assert.NilError(t, err)

0 commit comments

Comments
 (0)