Skip to content

Commit 64de5e8

Browse files
author
Tibor Vass
committed
rm-gocheck: fix compile errors from converting check.CommentInterface to string
while :; do \ out=$(go test -c ./integration-cli 2>&1 | grep 'cannot use nil as type string in return argument') || break echo "$out" | while read line; do file=$(echo "$line" | cut -d: -f1) n=$(echo "$line" | cut -d: -f2) sed -E -i "${n}"'s#\b(return .*, )nil#\1""#g' "$file" done done \ && \ while :; do \ out=$(go test -c ./integration-cli/daemon 2>&1 | grep 'cannot use nil as type string in return argument') || break echo "$out" | while read line; do file=$(echo "$line" | cut -d: -f1) n=$(echo "$line" | cut -d: -f2) sed -E -i "${n}"'s#\b(return .*, )nil#\1""#g' "$file" done done \ && \ while :; do \ out=$(go test -c ./pkg/discovery 2>&1 | grep 'cannot use nil as type string in return argument') || break echo "$out" | while read line; do file=$(echo "$line" | cut -d: -f1) n=$(echo "$line" | cut -d: -f2) sed -E -i "${n}"'s#\b(return .*, )nil#\1""#g' "$file" done done \ && \ while :; do \ out=$(go test -c ./pkg/discovery/file 2>&1 | grep 'cannot use nil as type string in return argument') || break echo "$out" | while read line; do file=$(echo "$line" | cut -d: -f1) n=$(echo "$line" | cut -d: -f2) sed -E -i "${n}"'s#\b(return .*, )nil#\1""#g' "$file" done done \ && \ while :; do \ out=$(go test -c ./pkg/discovery/kv 2>&1 | grep 'cannot use nil as type string in return argument') || break echo "$out" | while read line; do file=$(echo "$line" | cut -d: -f1) n=$(echo "$line" | cut -d: -f2) sed -E -i "${n}"'s#\b(return .*, )nil#\1""#g' "$file" done done \ && \ while :; do \ out=$(go test -c ./pkg/discovery/memory 2>&1 | grep 'cannot use nil as type string in return argument') || break echo "$out" | while read line; do file=$(echo "$line" | cut -d: -f1) n=$(echo "$line" | cut -d: -f2) sed -E -i "${n}"'s#\b(return .*, )nil#\1""#g' "$file" done done \ && \ while :; do \ out=$(go test -c ./pkg/discovery/nodes 2>&1 | grep 'cannot use nil as type string in return argument') || break echo "$out" | while read line; do file=$(echo "$line" | cut -d: -f1) n=$(echo "$line" | cut -d: -f2) sed -E -i "${n}"'s#\b(return .*, )nil#\1""#g' "$file" done done Signed-off-by: Tibor Vass <tibor@docker.com>
1 parent 7813dfe commit 64de5e8

11 files changed

+51
-51
lines changed

integration-cli/daemon/daemon.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func (d *Daemon) CheckActiveContainerCount(c *testing.T) (interface{}, string) {
9292
out, err := d.Cmd("ps", "-q")
9393
assert.NilError(c, err)
9494
if len(strings.TrimSpace(out)) == 0 {
95-
return 0, nil
95+
return 0, ""
9696
}
9797
return len(strings.Split(strings.TrimSpace(out), "\n")), fmt.Sprintf("output: %q", string(out))
9898
}

integration-cli/daemon/daemon_swarm.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func (d *Daemon) CheckServiceTasksInState(service string, state swarm.TaskState,
2626
}
2727
}
2828
}
29-
return count, nil
29+
return count, ""
3030
}
3131
}
3232

@@ -43,7 +43,7 @@ func (d *Daemon) CheckServiceTasksInStateWithError(service string, state swarm.T
4343
}
4444
}
4545
}
46-
return count, nil
46+
return count, ""
4747
}
4848
}
4949

@@ -57,9 +57,9 @@ func (d *Daemon) CheckServiceUpdateState(service string) func(*testing.T) (inter
5757
return func(c *testing.T) (interface{}, string) {
5858
service := d.GetService(c, service)
5959
if service.UpdateStatus == nil {
60-
return "", nil
60+
return "", ""
6161
}
62-
return service.UpdateStatus.State, nil
62+
return service.UpdateStatus.State, ""
6363
}
6464
}
6565

@@ -93,7 +93,7 @@ func (d *Daemon) CheckPluginImage(plugin string) func(c *testing.T) (interface{}
9393
func (d *Daemon) CheckServiceTasks(service string) func(*testing.T) (interface{}, string) {
9494
return func(c *testing.T) (interface{}, string) {
9595
tasks := d.GetServiceTasks(c, service)
96-
return len(tasks), nil
96+
return len(tasks), ""
9797
}
9898
}
9999

@@ -118,7 +118,7 @@ func (d *Daemon) CheckRunningTaskNetworks(c *testing.T) (interface{}, string) {
118118
result[network.Target]++
119119
}
120120
}
121-
return result, nil
121+
return result, ""
122122
}
123123

124124
// CheckRunningTaskImages returns the times each image is running as a task.
@@ -142,7 +142,7 @@ func (d *Daemon) CheckRunningTaskImages(c *testing.T) (interface{}, string) {
142142
result[task.Spec.ContainerSpec.Image]++
143143
}
144144
}
145-
return result, nil
145+
return result, ""
146146
}
147147

148148
// CheckNodeReadyCount returns the number of ready node on the swarm
@@ -154,20 +154,20 @@ func (d *Daemon) CheckNodeReadyCount(c *testing.T) (interface{}, string) {
154154
readyCount++
155155
}
156156
}
157-
return readyCount, nil
157+
return readyCount, ""
158158
}
159159

160160
// CheckLocalNodeState returns the current swarm node state
161161
func (d *Daemon) CheckLocalNodeState(c *testing.T) (interface{}, string) {
162162
info := d.SwarmInfo(c)
163-
return info.LocalNodeState, nil
163+
return info.LocalNodeState, ""
164164
}
165165

166166
// CheckControlAvailable returns the current swarm control available
167167
func (d *Daemon) CheckControlAvailable(c *testing.T) (interface{}, string) {
168168
info := d.SwarmInfo(c)
169169
assert.Equal(c, info.LocalNodeState, swarm.LocalNodeStateActive)
170-
return info.ControlAvailable, nil
170+
return info.ControlAvailable, ""
171171
}
172172

173173
// CheckLeader returns whether there is a leader on the swarm or not
@@ -184,7 +184,7 @@ func (d *Daemon) CheckLeader(c *testing.T) (interface{}, string) {
184184

185185
for _, node := range ls {
186186
if node.ManagerStatus != nil && node.ManagerStatus.Leader {
187-
return nil, nil
187+
return nil, ""
188188
}
189189
}
190190
return fmt.Errorf("no leader"), "could not find leader"

integration-cli/docker_api_exec_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ func (s *DockerSuite) TestExecStateCleanup(c *testing.T) {
218218
checkReadDir := func(c *testing.T) (interface{}, string) {
219219
fi, err := ioutil.ReadDir(stateDir)
220220
assert.NilError(c, err)
221-
return len(fi), nil
221+
return len(fi), ""
222222
}
223223

224224
fi, err := ioutil.ReadDir(stateDir)

integration-cli/docker_api_swarm_service_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ func (s *DockerSwarmSuite) TestAPISwarmServicesUpdateStartFirst(c *testing.T) {
231231
startingTasks = append(startingTasks, t)
232232
}
233233
}
234-
return startingTasks, nil
234+
return startingTasks, ""
235235
}, checker.HasLen, expected)
236236

237237
return startingTasks

integration-cli/docker_api_swarm_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ func (s *DockerSwarmSuite) TestAPISwarmPromoteDemote(c *testing.T) {
229229
}
230230
certs, err := helpers.ParseCertificatesPEM(certBytes)
231231
if err == nil && len(certs) > 0 && len(certs[0].Subject.OrganizationalUnit) > 0 {
232-
return certs[0].Subject.OrganizationalUnit[0], nil
232+
return certs[0].Subject.OrganizationalUnit[0], ""
233233
}
234234
return "", "could not get organizational unit from certificate"
235235
}, checker.Equals, "swarm-worker")
@@ -405,7 +405,7 @@ func (s *DockerSwarmSuite) TestAPISwarmRaftQuorum(c *testing.T) {
405405
// d1 will eventually step down from leader because there is no longer an active quorum, wait for that to happen
406406
waitAndAssert(c, defaultReconciliationTimeout*2, func(c *testing.T) (interface{}, string) {
407407
_, err := cli.ServiceCreate(context.Background(), service.Spec, types.ServiceCreateOptions{})
408-
return err.Error(), nil
408+
return err.Error(), ""
409409
}, checker.Contains, "Make sure more than half of the managers are online.")
410410

411411
d2.StartNode(c)
@@ -756,7 +756,7 @@ func checkClusterHealth(c *testing.T, cl []*daemon.Daemon, managerCount, workerC
756756
for _, n := range d.ListNodes(c) {
757757
waitReady := func(c *testing.T) (interface{}, string) {
758758
if n.Status.State == swarm.NodeStateReady {
759-
return true, nil
759+
return true, ""
760760
}
761761
nn := d.GetNode(c, n.ID)
762762
n = *nn
@@ -766,7 +766,7 @@ func checkClusterHealth(c *testing.T, cl []*daemon.Daemon, managerCount, workerC
766766

767767
waitActive := func(c *testing.T) (interface{}, string) {
768768
if n.Spec.Availability == swarm.NodeAvailabilityActive {
769-
return true, nil
769+
return true, ""
770770
}
771771
nn := d.GetNode(c, n.ID)
772772
n = *nn

integration-cli/docker_cli_daemon_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2073,7 +2073,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithUnpausedRunningContainer(t *tes
20732073
// the resume event might be received after we do the inspect
20742074
waitAndAssert(t, defaultReconciliationTimeout, func(*testing.T) (interface{}, string) {
20752075
result := icmd.RunCommand("kill", "-0", strings.TrimSpace(pid))
2076-
return result.ExitCode, nil
2076+
return result.ExitCode, ""
20772077
}, checker.Equals, 0)
20782078

20792079
// restart the daemon

integration-cli/docker_cli_prune_unix_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ func pruneNetworkAndVerify(c *testing.T, d *daemon.Daemon, kept, pruned []string
2727
waitAndAssert(c, defaultReconciliationTimeout, func(*testing.T) (interface{}, string) {
2828
out, err := d.Cmd("network", "ls", "--format", "{{.Name}}")
2929
assert.NilError(c, err)
30-
return out, nil
30+
return out, ""
3131
}, checker.Contains, s)
3232
}
3333

3434
for _, s := range pruned {
3535
waitAndAssert(c, defaultReconciliationTimeout, func(*testing.T) (interface{}, string) {
3636
out, err := d.Cmd("network", "ls", "--format", "{{.Name}}")
3737
assert.NilError(c, err)
38-
return out, nil
38+
return out, ""
3939
}, checker.Not(checker.Contains), s)
4040
}
4141
}

integration-cli/docker_cli_restart_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func (s *DockerSuite) TestRestartRunningContainer(c *testing.T) {
3838

3939
getLogs := func(c *testing.T) (interface{}, string) {
4040
out, _ := dockerCmd(c, "logs", cleanedContainerID)
41-
return out, nil
41+
return out, ""
4242
}
4343

4444
// Wait 10 seconds for the 'echo' to appear in the logs

integration-cli/docker_cli_service_create_test.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ func (s *DockerSwarmSuite) TestServiceCreateMountVolume(c *testing.T) {
2525
var tasks []swarm.Task
2626
waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, string) {
2727
tasks = d.GetServiceTasks(c, id)
28-
return len(tasks) > 0, nil
28+
return len(tasks) > 0, ""
2929
}, checker.Equals, true)
3030

3131
task := tasks[0]
3232
waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, string) {
3333
if task.NodeID == "" || task.Status.ContainerStatus == nil {
3434
task = d.GetTask(c, task.ID)
3535
}
36-
return task.NodeID != "" && task.Status.ContainerStatus != nil, nil
36+
return task.NodeID != "" && task.Status.ContainerStatus != nil, ""
3737
}, checker.Equals, true)
3838

3939
// check container mount config
@@ -139,15 +139,15 @@ func (s *DockerSwarmSuite) TestServiceCreateWithSecretSourceTargetPaths(c *testi
139139
var tasks []swarm.Task
140140
waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, string) {
141141
tasks = d.GetServiceTasks(c, serviceName)
142-
return len(tasks) > 0, nil
142+
return len(tasks) > 0, ""
143143
}, checker.Equals, true)
144144

145145
task := tasks[0]
146146
waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, string) {
147147
if task.NodeID == "" || task.Status.ContainerStatus == nil {
148148
task = d.GetTask(c, task.ID)
149149
}
150-
return task.NodeID != "" && task.Status.ContainerStatus != nil, nil
150+
return task.NodeID != "" && task.Status.ContainerStatus != nil, ""
151151
}, checker.Equals, true)
152152

153153
for testName, testTarget := range testPaths {
@@ -189,15 +189,15 @@ func (s *DockerSwarmSuite) TestServiceCreateWithSecretReferencedTwice(c *testing
189189
var tasks []swarm.Task
190190
waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, string) {
191191
tasks = d.GetServiceTasks(c, serviceName)
192-
return len(tasks) > 0, nil
192+
return len(tasks) > 0, ""
193193
}, checker.Equals, true)
194194

195195
task := tasks[0]
196196
waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, string) {
197197
if task.NodeID == "" || task.Status.ContainerStatus == nil {
198198
task = d.GetTask(c, task.ID)
199199
}
200-
return task.NodeID != "" && task.Status.ContainerStatus != nil, nil
200+
return task.NodeID != "" && task.Status.ContainerStatus != nil, ""
201201
}, checker.Equals, true)
202202

203203
for _, target := range []string{"target1", "target2"} {
@@ -286,15 +286,15 @@ func (s *DockerSwarmSuite) TestServiceCreateWithConfigSourceTargetPaths(c *testi
286286
var tasks []swarm.Task
287287
waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, string) {
288288
tasks = d.GetServiceTasks(c, serviceName)
289-
return len(tasks) > 0, nil
289+
return len(tasks) > 0, ""
290290
}, checker.Equals, true)
291291

292292
task := tasks[0]
293293
waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, string) {
294294
if task.NodeID == "" || task.Status.ContainerStatus == nil {
295295
task = d.GetTask(c, task.ID)
296296
}
297-
return task.NodeID != "" && task.Status.ContainerStatus != nil, nil
297+
return task.NodeID != "" && task.Status.ContainerStatus != nil, ""
298298
}, checker.Equals, true)
299299

300300
for testName, testTarget := range testPaths {
@@ -336,15 +336,15 @@ func (s *DockerSwarmSuite) TestServiceCreateWithConfigReferencedTwice(c *testing
336336
var tasks []swarm.Task
337337
waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, string) {
338338
tasks = d.GetServiceTasks(c, serviceName)
339-
return len(tasks) > 0, nil
339+
return len(tasks) > 0, ""
340340
}, checker.Equals, true)
341341

342342
task := tasks[0]
343343
waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, string) {
344344
if task.NodeID == "" || task.Status.ContainerStatus == nil {
345345
task = d.GetTask(c, task.ID)
346346
}
347-
return task.NodeID != "" && task.Status.ContainerStatus != nil, nil
347+
return task.NodeID != "" && task.Status.ContainerStatus != nil, ""
348348
}, checker.Equals, true)
349349

350350
for _, target := range []string{"target1", "target2"} {
@@ -368,15 +368,15 @@ func (s *DockerSwarmSuite) TestServiceCreateMountTmpfs(c *testing.T) {
368368
var tasks []swarm.Task
369369
waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, string) {
370370
tasks = d.GetServiceTasks(c, id)
371-
return len(tasks) > 0, nil
371+
return len(tasks) > 0, ""
372372
}, checker.Equals, true)
373373

374374
task := tasks[0]
375375
waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, string) {
376376
if task.NodeID == "" || task.Status.ContainerStatus == nil {
377377
task = d.GetTask(c, task.ID)
378378
}
379-
return task.NodeID != "" && task.Status.ContainerStatus != nil, nil
379+
return task.NodeID != "" && task.Status.ContainerStatus != nil, ""
380380
}, checker.Equals, true)
381381

382382
// check container mount config
@@ -424,15 +424,15 @@ func (s *DockerSwarmSuite) TestServiceCreateWithNetworkAlias(c *testing.T) {
424424
var tasks []swarm.Task
425425
waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, string) {
426426
tasks = d.GetServiceTasks(c, id)
427-
return len(tasks) > 0, nil
427+
return len(tasks) > 0, ""
428428
}, checker.Equals, true)
429429

430430
task := tasks[0]
431431
waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, string) {
432432
if task.NodeID == "" || task.Status.ContainerStatus == nil {
433433
task = d.GetTask(c, task.ID)
434434
}
435-
return task.NodeID != "" && task.Status.ContainerStatus != nil, nil
435+
return task.NodeID != "" && task.Status.ContainerStatus != nil, ""
436436
}, checker.Equals, true)
437437

438438
// check container alias config

integration-cli/docker_cli_service_health_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,36 +41,36 @@ func (s *DockerSwarmSuite) TestServiceHealthRun(c *testing.T) {
4141
var tasks []swarm.Task
4242
waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, string) {
4343
tasks = d.GetServiceTasks(c, id)
44-
return tasks, nil
44+
return tasks, ""
4545
}, checker.HasLen, 1)
4646

4747
task := tasks[0]
4848

4949
// wait for task to start
5050
waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, string) {
5151
task = d.GetTask(c, task.ID)
52-
return task.Status.State, nil
52+
return task.Status.State, ""
5353
}, checker.Equals, swarm.TaskStateRunning)
5454
containerID := task.Status.ContainerStatus.ContainerID
5555

5656
// wait for container to be healthy
5757
waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, string) {
5858
out, _ := d.Cmd("inspect", "--format={{.State.Health.Status}}", containerID)
59-
return strings.TrimSpace(out), nil
59+
return strings.TrimSpace(out), ""
6060
}, checker.Equals, "healthy")
6161

6262
// make it fail
6363
d.Cmd("exec", containerID, "rm", "/status")
6464
// wait for container to be unhealthy
6565
waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, string) {
6666
out, _ := d.Cmd("inspect", "--format={{.State.Health.Status}}", containerID)
67-
return strings.TrimSpace(out), nil
67+
return strings.TrimSpace(out), ""
6868
}, checker.Equals, "unhealthy")
6969

7070
// Task should be terminated
7171
waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, string) {
7272
task = d.GetTask(c, task.ID)
73-
return task.Status.State, nil
73+
return task.Status.State, ""
7474
}, checker.Equals, swarm.TaskStateFailed)
7575

7676
if !strings.Contains(task.Status.Err, container.ErrContainerUnhealthy.Error()) {
@@ -102,15 +102,15 @@ func (s *DockerSwarmSuite) TestServiceHealthStart(c *testing.T) {
102102
var tasks []swarm.Task
103103
waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, string) {
104104
tasks = d.GetServiceTasks(c, id)
105-
return tasks, nil
105+
return tasks, ""
106106
}, checker.HasLen, 1)
107107

108108
task := tasks[0]
109109

110110
// wait for task to start
111111
waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, string) {
112112
task = d.GetTask(c, task.ID)
113-
return task.Status.State, nil
113+
return task.Status.State, ""
114114
}, checker.Equals, swarm.TaskStateStarting)
115115

116116
containerID := task.Status.ContainerStatus.ContainerID
@@ -119,7 +119,7 @@ func (s *DockerSwarmSuite) TestServiceHealthStart(c *testing.T) {
119119
waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, string) {
120120
out, _ := d.Cmd("inspect", "--format={{.State.Health.FailingStreak}}", containerID)
121121
failingStreak, _ := strconv.Atoi(strings.TrimSpace(out))
122-
return failingStreak, nil
122+
return failingStreak, ""
123123
}, checker.GreaterThan, 0)
124124

125125
// task should be blocked at starting status
@@ -132,6 +132,6 @@ func (s *DockerSwarmSuite) TestServiceHealthStart(c *testing.T) {
132132
// Task should be at running status
133133
waitAndAssert(c, defaultReconciliationTimeout, func(c *testing.T) (interface{}, string) {
134134
task = d.GetTask(c, task.ID)
135-
return task.Status.State, nil
135+
return task.Status.State, ""
136136
}, checker.Equals, swarm.TaskStateRunning)
137137
}

0 commit comments

Comments
 (0)