Browse code

integration: change container.Create signature to fix linting

```
Line 25: warning: context.Context should be the first parameter of a function (golint)
Line 44: warning: context.Context should be the first parameter of a function (golint)
Line 52: warning: context.Context should be the first parameter of a function (golint)
```

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit b4c46b0dac0d74fed8b8adc56cbb7f55788e4916)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

Sebastiaan van Stijn authored on 2019/06/06 20:00:37
Showing 13 changed files
... ...
@@ -26,7 +26,7 @@ func TestCopyFromContainerPathDoesNotExist(t *testing.T) {
26 26
 
27 27
 	ctx := context.Background()
28 28
 	apiclient := testEnv.APIClient()
29
-	cid := container.Create(t, ctx, apiclient)
29
+	cid := container.Create(ctx, t, apiclient)
30 30
 
31 31
 	_, _, err := apiclient.CopyFromContainer(ctx, cid, "/dne")
32 32
 	assert.Check(t, client.IsErrNotFound(err))
... ...
@@ -40,7 +40,7 @@ func TestCopyFromContainerPathIsNotDir(t *testing.T) {
40 40
 
41 41
 	ctx := context.Background()
42 42
 	apiclient := testEnv.APIClient()
43
-	cid := container.Create(t, ctx, apiclient)
43
+	cid := container.Create(ctx, t, apiclient)
44 44
 
45 45
 	_, _, err := apiclient.CopyFromContainer(ctx, cid, "/etc/passwd/")
46 46
 	assert.Assert(t, is.ErrorContains(err, "not a directory"))
... ...
@@ -52,7 +52,7 @@ func TestCopyToContainerPathDoesNotExist(t *testing.T) {
52 52
 
53 53
 	ctx := context.Background()
54 54
 	apiclient := testEnv.APIClient()
55
-	cid := container.Create(t, ctx, apiclient)
55
+	cid := container.Create(ctx, t, apiclient)
56 56
 
57 57
 	err := apiclient.CopyToContainer(ctx, cid, "/dne", nil, types.CopyToContainerOptions{})
58 58
 	assert.Check(t, client.IsErrNotFound(err))
... ...
@@ -66,7 +66,7 @@ func TestCopyToContainerPathIsNotDir(t *testing.T) {
66 66
 
67 67
 	ctx := context.Background()
68 68
 	apiclient := testEnv.APIClient()
69
-	cid := container.Create(t, ctx, apiclient)
69
+	cid := container.Create(ctx, t, apiclient)
70 70
 
71 71
 	err := apiclient.CopyToContainer(ctx, cid, "/etc/passwd/", nil, types.CopyToContainerOptions{})
72 72
 	assert.Assert(t, is.ErrorContains(err, "not a directory"))
... ...
@@ -40,7 +40,7 @@ func TestContainerStartOnDaemonRestart(t *testing.T) {
40 40
 
41 41
 	ctx := context.Background()
42 42
 
43
-	cID := container.Create(t, ctx, c)
43
+	cID := container.Create(ctx, t, c)
44 44
 	defer c.ContainerRemove(ctx, cID, types.ContainerRemoveOptions{Force: true})
45 45
 
46 46
 	err := c.ContainerStart(ctx, cID, types.ContainerStartOptions{})
... ...
@@ -67,7 +67,7 @@ func TestExportContainerAfterDaemonRestart(t *testing.T) {
67 67
 	defer d.Stop(t)
68 68
 
69 69
 	ctx := context.Background()
70
-	ctrID := container.Create(t, ctx, c)
70
+	ctrID := container.Create(ctx, t, c)
71 71
 
72 72
 	d.Restart(t)
73 73
 
... ...
@@ -308,7 +308,7 @@ func TestIpcModeOlderClient(t *testing.T) {
308 308
 	ctx := context.Background()
309 309
 
310 310
 	// pre-check: default ipc mode in daemon is private
311
-	cID := container.Create(t, ctx, c, container.WithAutoRemove)
311
+	cID := container.Create(ctx, t, c, container.WithAutoRemove)
312 312
 
313 313
 	inspect, err := c.ContainerInspect(ctx, cID)
314 314
 	assert.NilError(t, err)
... ...
@@ -316,7 +316,7 @@ func TestIpcModeOlderClient(t *testing.T) {
316 316
 
317 317
 	// main check: using older client creates "shareable" container
318 318
 	c = request.NewAPIClient(t, client.WithVersion("1.39"))
319
-	cID = container.Create(t, ctx, c, container.WithAutoRemove)
319
+	cID = container.Create(ctx, t, c, container.WithAutoRemove)
320 320
 
321 321
 	inspect, err = c.ContainerInspect(ctx, cID)
322 322
 	assert.NilError(t, err)
... ...
@@ -113,7 +113,7 @@ func TestKillStoppedContainer(t *testing.T) {
113 113
 	defer setupTest(t)()
114 114
 	ctx := context.Background()
115 115
 	client := testEnv.APIClient()
116
-	id := container.Create(t, ctx, client)
116
+	id := container.Create(ctx, t, client)
117 117
 	err := client.ContainerKill(ctx, id, "SIGKILL")
118 118
 	assert.Assert(t, is.ErrorContains(err, ""))
119 119
 	assert.Assert(t, is.Contains(err.Error(), "is not running"))
... ...
@@ -124,7 +124,7 @@ func TestKillStoppedContainerAPIPre120(t *testing.T) {
124 124
 	defer setupTest(t)()
125 125
 	ctx := context.Background()
126 126
 	client := request.NewAPIClient(t, client.WithVersion("1.19"))
127
-	id := container.Create(t, ctx, client)
127
+	id := container.Create(ctx, t, client)
128 128
 	err := client.ContainerKill(ctx, id, "SIGKILL")
129 129
 	assert.NilError(t, err)
130 130
 }
... ...
@@ -16,9 +16,9 @@ func TestPsFilter(t *testing.T) {
16 16
 	client := testEnv.APIClient()
17 17
 	ctx := context.Background()
18 18
 
19
-	prev := container.Create(t, ctx, client)
20
-	top := container.Create(t, ctx, client)
21
-	next := container.Create(t, ctx, client)
19
+	prev := container.Create(ctx, t, client)
20
+	top := container.Create(ctx, t, client)
21
+	next := container.Create(ctx, t, client)
22 22
 
23 23
 	containerIDs := func(containers []types.Container) []string {
24 24
 		var entries []string
... ...
@@ -19,7 +19,7 @@ func TestCommitInheritsEnv(t *testing.T) {
19 19
 	client := testEnv.APIClient()
20 20
 	ctx := context.Background()
21 21
 
22
-	cID1 := container.Create(t, ctx, client)
22
+	cID1 := container.Create(ctx, t, client)
23 23
 
24 24
 	commitResp1, err := client.ContainerCommit(ctx, cID1, types.ContainerCommitOptions{
25 25
 		Changes:   []string{"ENV PATH=/bin"},
... ...
@@ -33,7 +33,7 @@ func TestCommitInheritsEnv(t *testing.T) {
33 33
 	expectedEnv1 := []string{"PATH=/bin"}
34 34
 	assert.Check(t, is.DeepEqual(expectedEnv1, image1.Config.Env))
35 35
 
36
-	cID2 := container.Create(t, ctx, client, container.WithImage(image1.ID))
36
+	cID2 := container.Create(ctx, t, client, container.WithImage(image1.ID))
37 37
 
38 38
 	commitResp2, err := client.ContainerCommit(ctx, cID2, types.ContainerCommitOptions{
39 39
 		Changes:   []string{"ENV PATH=/usr/bin:$PATH"},
... ...
@@ -20,7 +20,7 @@ func TestRemoveImageOrphaning(t *testing.T) {
20 20
 	img := "test-container-orphaning"
21 21
 
22 22
 	// Create a container from busybox, and commit a small change so we have a new image
23
-	cID1 := container.Create(t, ctx, client, container.WithCmd(""))
23
+	cID1 := container.Create(ctx, t, client, container.WithCmd(""))
24 24
 	commitResp1, err := client.ContainerCommit(ctx, cID1, types.ContainerCommitOptions{
25 25
 		Changes:   []string{`ENTRYPOINT ["true"]`},
26 26
 		Reference: img,
... ...
@@ -33,7 +33,7 @@ func TestRemoveImageOrphaning(t *testing.T) {
33 33
 	assert.Check(t, is.Equal(resp.ID, commitResp1.ID))
34 34
 
35 35
 	// Create a container from created image, and commit a small change with same reference name
36
-	cID2 := container.Create(t, ctx, client, container.WithImage(img), container.WithCmd(""))
36
+	cID2 := container.Create(ctx, t, client, container.WithImage(img), container.WithCmd(""))
37 37
 	commitResp2, err := client.ContainerCommit(ctx, cID2, types.ContainerCommitOptions{
38 38
 		Changes:   []string{`LABEL Maintainer="Integration Tests"`},
39 39
 		Reference: img,
... ...
@@ -22,8 +22,7 @@ type TestContainerConfig struct {
22 22
 }
23 23
 
24 24
 // Create creates a container with the specified options
25
-// nolint: golint
26
-func Create(t *testing.T, ctx context.Context, client client.APIClient, ops ...func(*TestContainerConfig)) string { // nolint: golint
25
+func Create(ctx context.Context, t *testing.T, client client.APIClient, ops ...func(*TestContainerConfig)) string {
27 26
 	t.Helper()
28 27
 	cmd := []string{"top"}
29 28
 	if runtime.GOOS == "windows" {
... ...
@@ -52,7 +51,7 @@ func Create(t *testing.T, ctx context.Context, client client.APIClient, ops ...f
52 52
 // nolint: golint
53 53
 func Run(t *testing.T, ctx context.Context, client client.APIClient, ops ...func(*TestContainerConfig)) string { // nolint: golint
54 54
 	t.Helper()
55
-	id := Create(t, ctx, client, ops...)
55
+	id := Create(ctx, t, client, ops...)
56 56
 
57 57
 	err := client.ContainerStart(ctx, id, types.ContainerStartOptions{})
58 58
 	assert.NilError(t, err)
... ...
@@ -29,7 +29,7 @@ func TestDockerNetworkConnectAlias(t *testing.T) {
29 29
 		net.WithAttachable(),
30 30
 	)
31 31
 
32
-	cID1 := container.Create(t, ctx, client, func(c *container.TestContainerConfig) {
32
+	cID1 := container.Create(ctx, t, client, func(c *container.TestContainerConfig) {
33 33
 		c.NetworkingConfig = &network.NetworkingConfig{
34 34
 			EndpointsConfig: map[string]*network.EndpointSettings{
35 35
 				name: {},
... ...
@@ -52,7 +52,7 @@ func TestDockerNetworkConnectAlias(t *testing.T) {
52 52
 	assert.Check(t, is.Equal(len(ng1.NetworkSettings.Networks[name].Aliases), 2))
53 53
 	assert.Check(t, is.Equal(ng1.NetworkSettings.Networks[name].Aliases[0], "aaa"))
54 54
 
55
-	cID2 := container.Create(t, ctx, client, func(c *container.TestContainerConfig) {
55
+	cID2 := container.Create(ctx, t, client, func(c *container.TestContainerConfig) {
56 56
 		c.NetworkingConfig = &network.NetworkingConfig{
57 57
 			EndpointsConfig: map[string]*network.EndpointSettings{
58 58
 				name: {},
... ...
@@ -41,7 +41,7 @@ func TestCgroupDriverSystemdMemoryLimit(t *testing.T) {
41 41
 	const mem = 64 * 1024 * 1024 // 64 MB
42 42
 
43 43
 	ctx := context.Background()
44
-	ctrID := container.Create(t, ctx, c, func(ctr *container.TestContainerConfig) {
44
+	ctrID := container.Create(ctx, t, c, func(ctr *container.TestContainerConfig) {
45 45
 		ctr.HostConfig.Resources.Memory = mem
46 46
 	})
47 47
 	defer c.ContainerRemove(ctx, ctrID, types.ContainerRemoveOptions{Force: true})
... ...
@@ -83,7 +83,7 @@ func TestEventsBackwardsCompatible(t *testing.T) {
83 83
 	since := request.DaemonTime(ctx, t, client, testEnv)
84 84
 	ts := strconv.FormatInt(since.Unix(), 10)
85 85
 
86
-	cID := container.Create(t, ctx, client)
86
+	cID := container.Create(ctx, t, client)
87 87
 
88 88
 	// In case there is no events, the API should have responded immediately (not blocking),
89 89
 	// The test here makes sure the response time is less than 3 sec.
... ...
@@ -68,7 +68,7 @@ func TestVolumesRemove(t *testing.T) {
68 68
 
69 69
 	prefix, slash := getPrefixAndSlashFromDaemonPlatform()
70 70
 
71
-	id := container.Create(t, ctx, client, container.WithVolume(prefix+slash+"foo"))
71
+	id := container.Create(ctx, t, client, container.WithVolume(prefix+slash+"foo"))
72 72
 
73 73
 	c, err := client.ContainerInspect(ctx, id)
74 74
 	assert.NilError(t, err)