Skip to content

Commit b5f15bc

Browse files
committed
api/types: move EventsOptions to api/types/events
Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent ecb24af commit b5f15bc

10 files changed

Lines changed: 30 additions & 27 deletions

File tree

api/types/client.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,6 @@ import (
1212
units "github.com/docker/go-units"
1313
)
1414

15-
// EventsOptions holds parameters to filter events with.
16-
type EventsOptions struct {
17-
Since string
18-
Until string
19-
Filters filters.Args
20-
}
21-
2215
// NewHijackedResponse intializes a HijackedResponse type
2316
func NewHijackedResponse(conn net.Conn, mediaType string) HijackedResponse {
2417
return HijackedResponse{Conn: conn, Reader: bufio.NewReader(conn), mediaType: mediaType}

api/types/events/events.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
package events // import "github.com/docker/docker/api/types/events"
2+
import "github.com/docker/docker/api/types/filters"
23

34
// Type is used for event-types.
45
type Type string
@@ -125,3 +126,10 @@ type Message struct {
125126
Time int64 `json:"time,omitempty"`
126127
TimeNano int64 `json:"timeNano,omitempty"`
127128
}
129+
130+
// ListOptions holds parameters to filter events with.
131+
type ListOptions struct {
132+
Since string
133+
Until string
134+
Filters filters.Args
135+
}

api/types/types_deprecated.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package types
22

33
import (
44
"github.com/docker/docker/api/types/container"
5+
"github.com/docker/docker/api/types/events"
56
"github.com/docker/docker/api/types/image"
67
"github.com/docker/docker/api/types/network"
78
"github.com/docker/docker/api/types/volume"
@@ -111,3 +112,8 @@ type CopyToContainerOptions = container.CopyToContainerOptions
111112
//
112113
// Deprecated: use [container.StatsResponse].
113114
type ContainerStats = container.StatsResponse
115+
116+
// EventsOptions holds parameters to filter events with.
117+
//
118+
// Deprecated: use [events.ListOptions].
119+
type EventsOptions = events.ListOptions

client/events.go

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

9-
"github.com/docker/docker/api/types"
109
"github.com/docker/docker/api/types/events"
1110
"github.com/docker/docker/api/types/filters"
1211
timetypes "github.com/docker/docker/api/types/time"
@@ -16,7 +15,7 @@ import (
1615
// by cancelling the context. Once the stream has been completely read an io.EOF error will
1716
// be sent over the error channel. If an error is sent all processing will be stopped. It's up
1817
// to the caller to reopen the stream in the event of an error by reinvoking this method.
19-
func (cli *Client) Events(ctx context.Context, options types.EventsOptions) (<-chan events.Message, <-chan error) {
18+
func (cli *Client) Events(ctx context.Context, options events.ListOptions) (<-chan events.Message, <-chan error) {
2019
messages := make(chan events.Message)
2120
errs := make(chan error, 1)
2221

@@ -68,7 +67,7 @@ func (cli *Client) Events(ctx context.Context, options types.EventsOptions) (<-c
6867
return messages, errs
6968
}
7069

71-
func buildEventsQueryParams(cliVersion string, options types.EventsOptions) (url.Values, error) {
70+
func buildEventsQueryParams(cliVersion string, options events.ListOptions) (url.Values, error) {
7271
query := url.Values{}
7372
ref := time.Now()
7473

client/events_test.go

Lines changed: 7 additions & 8 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/events"
1514
"github.com/docker/docker/api/types/filters"
1615
"github.com/docker/docker/errdefs"
@@ -20,17 +19,17 @@ import (
2019

2120
func TestEventsErrorInOptions(t *testing.T) {
2221
errorCases := []struct {
23-
options types.EventsOptions
22+
options events.ListOptions
2423
expectedError string
2524
}{
2625
{
27-
options: types.EventsOptions{
26+
options: events.ListOptions{
2827
Since: "2006-01-02TZ",
2928
},
3029
expectedError: `parsing time "2006-01-02TZ"`,
3130
},
3231
{
33-
options: types.EventsOptions{
32+
options: events.ListOptions{
3433
Until: "2006-01-02TZ",
3534
},
3635
expectedError: `parsing time "2006-01-02TZ"`,
@@ -52,7 +51,7 @@ func TestEventsErrorFromServer(t *testing.T) {
5251
client := &Client{
5352
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
5453
}
55-
_, errs := client.Events(context.Background(), types.EventsOptions{})
54+
_, errs := client.Events(context.Background(), events.ListOptions{})
5655
err := <-errs
5756
assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
5857
}
@@ -64,13 +63,13 @@ func TestEvents(t *testing.T) {
6463
expectedFiltersJSON := fmt.Sprintf(`{"type":{"%s":true}}`, events.ContainerEventType)
6564

6665
eventsCases := []struct {
67-
options types.EventsOptions
66+
options events.ListOptions
6867
events []events.Message
6968
expectedEvents map[string]bool
7069
expectedQueryParams map[string]string
7170
}{
7271
{
73-
options: types.EventsOptions{
72+
options: events.ListOptions{
7473
Filters: fltrs,
7574
},
7675
expectedQueryParams: map[string]string{
@@ -80,7 +79,7 @@ func TestEvents(t *testing.T) {
8079
expectedEvents: make(map[string]bool),
8180
},
8281
{
83-
options: types.EventsOptions{
82+
options: events.ListOptions{
8483
Filters: fltrs,
8584
},
8685
expectedQueryParams: map[string]string{

client/interface.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ type SwarmAPIClient interface {
165165

166166
// SystemAPIClient defines API client methods for the system
167167
type SystemAPIClient interface {
168-
Events(ctx context.Context, options types.EventsOptions) (<-chan events.Message, <-chan error)
168+
Events(ctx context.Context, options events.ListOptions) (<-chan events.Message, <-chan error)
169169
Info(ctx context.Context) (system.Info, error)
170170
RegistryLogin(ctx context.Context, auth registry.AuthConfig) (registry.AuthenticateOKBody, error)
171171
DiskUsage(ctx context.Context, options types.DiskUsageOptions) (types.DiskUsage, error)

integration/container/pause_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"time"
77

88
cerrdefs "github.com/containerd/errdefs"
9-
"github.com/docker/docker/api/types"
109
containertypes "github.com/docker/docker/api/types/container"
1110
"github.com/docker/docker/api/types/events"
1211
"github.com/docker/docker/api/types/filters"
@@ -41,7 +40,7 @@ func TestPause(t *testing.T) {
4140

4241
until := request.DaemonUnixTime(ctx, t, apiClient, testEnv)
4342

44-
messages, errs := apiClient.Events(ctx, types.EventsOptions{
43+
messages, errs := apiClient.Events(ctx, events.ListOptions{
4544
Since: since,
4645
Until: until,
4746
Filters: filters.NewArgs(filters.Arg(string(events.ContainerEventType), cID)),

integration/container/restart_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ func TestContainerRestartWithCancelledRequest(t *testing.T) {
244244
}()
245245

246246
// Start listening for events.
247-
messages, errs := apiClient.Events(ctx, types.EventsOptions{
247+
messages, errs := apiClient.Events(ctx, events.ListOptions{
248248
Filters: filters.NewArgs(
249249
filters.Arg("container", cID),
250250
filters.Arg("event", string(events.ActionRestart)),

integration/plugin/authz/authz_plugin_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ func systemTime(ctx context.Context, t *testing.T, client client.APIClient, test
287287
}
288288

289289
func systemEventsSince(ctx context.Context, client client.APIClient, since string) (<-chan eventtypes.Message, <-chan error, func()) {
290-
eventOptions := types.EventsOptions{
290+
eventOptions := eventtypes.ListOptions{
291291
Since: since,
292292
}
293293
ctx, cancel := context.WithCancel(ctx)

integration/system/event_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"testing"
1212
"time"
1313

14-
"github.com/docker/docker/api/types"
1514
containertypes "github.com/docker/docker/api/types/container"
1615
"github.com/docker/docker/api/types/events"
1716
"github.com/docker/docker/api/types/filters"
@@ -38,7 +37,7 @@ func TestEventsExecDie(t *testing.T) {
3837
})
3938
assert.NilError(t, err)
4039

41-
msg, errs := client.Events(ctx, types.EventsOptions{
40+
msg, errs := client.Events(ctx, events.ListOptions{
4241
Filters: filters.NewArgs(
4342
filters.Arg("container", cID),
4443
filters.Arg("event", string(events.ActionExecDie)),
@@ -156,7 +155,7 @@ func TestEventsVolumeCreate(t *testing.T) {
156155
filters.Arg("event", "create"),
157156
filters.Arg("volume", volName),
158157
)
159-
messages, errs := client.Events(ctx, types.EventsOptions{
158+
messages, errs := client.Events(ctx, events.ListOptions{
160159
Since: since,
161160
Until: request.DaemonUnixTime(ctx, t, client, testEnv),
162161
Filters: filter,
@@ -172,7 +171,7 @@ func TestEventsVolumeCreate(t *testing.T) {
172171
Target: "/tmp/foo",
173172
}))
174173

175-
messages, errs = client.Events(ctx, types.EventsOptions{
174+
messages, errs = client.Events(ctx, events.ListOptions{
176175
Since: since,
177176
Until: request.DaemonUnixTime(ctx, t, client, testEnv),
178177
Filters: filter,

0 commit comments

Comments
 (0)