daemon/cluster/executor/container/adapter.go:449:3: The copy of the 'for' variable "mount" can be deleted (Go 1.22+) (copyloopvar)
mount := mount
^
daemon/cluster/executor/container/container_test.go:124:3: The copy of the 'for' variable "c" can be deleted (Go 1.22+) (copyloopvar)
c := c
^
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| ... | ... |
@@ -446,7 +446,6 @@ func (c *containerAdapter) remove(ctx context.Context) error {
|
| 446 | 446 |
func (c *containerAdapter) createVolumes(ctx context.Context) error {
|
| 447 | 447 |
// Create plugin volumes that are embedded inside a Mount |
| 448 | 448 |
for _, mount := range c.container.task.Spec.GetContainer().Mounts {
|
| 449 |
- mount := mount |
|
| 450 | 449 |
if mount.Type != api.MountTypeVolume {
|
| 451 | 450 |
continue |
| 452 | 451 |
} |
| ... | ... |
@@ -11,7 +11,7 @@ import ( |
| 11 | 11 |
) |
| 12 | 12 |
|
| 13 | 13 |
func TestIsolationConversion(t *testing.T) {
|
| 14 |
- cases := []struct {
|
|
| 14 |
+ tests := []struct {
|
|
| 15 | 15 |
name string |
| 16 | 16 |
from swarmapi.ContainerSpec_Isolation |
| 17 | 17 |
to container.Isolation |
| ... | ... |
@@ -20,14 +20,14 @@ func TestIsolationConversion(t *testing.T) {
|
| 20 | 20 |
{name: "process", from: swarmapi.ContainerIsolationProcess, to: container.IsolationProcess},
|
| 21 | 21 |
{name: "hyperv", from: swarmapi.ContainerIsolationHyperV, to: container.IsolationHyperV},
|
| 22 | 22 |
} |
| 23 |
- for _, c := range cases {
|
|
| 24 |
- t.Run(c.name, func(t *testing.T) {
|
|
| 23 |
+ for _, tc := range tests {
|
|
| 24 |
+ t.Run(tc.name, func(t *testing.T) {
|
|
| 25 | 25 |
task := swarmapi.Task{
|
| 26 | 26 |
Spec: swarmapi.TaskSpec{
|
| 27 | 27 |
Runtime: &swarmapi.TaskSpec_Container{
|
| 28 | 28 |
Container: &swarmapi.ContainerSpec{
|
| 29 | 29 |
Image: "alpine:latest", |
| 30 |
- Isolation: c.from, |
|
| 30 |
+ Isolation: tc.from, |
|
| 31 | 31 |
}, |
| 32 | 32 |
}, |
| 33 | 33 |
}, |
| ... | ... |
@@ -36,7 +36,7 @@ func TestIsolationConversion(t *testing.T) {
|
| 36 | 36 |
// NOTE(dperny): you shouldn't ever pass nil outside of testing, |
| 37 | 37 |
// because if there are CSI volumes, the code will panic. However, |
| 38 | 38 |
// in testing. this is acceptable. |
| 39 |
- assert.Equal(t, c.to, config.hostConfig(nil).Isolation) |
|
| 39 |
+ assert.Equal(t, tc.to, config.hostConfig(nil).Isolation) |
|
| 40 | 40 |
}) |
| 41 | 41 |
} |
| 42 | 42 |
} |
| ... | ... |
@@ -87,7 +87,7 @@ func TestContainerLabels(t *testing.T) {
|
| 87 | 87 |
} |
| 88 | 88 |
|
| 89 | 89 |
func TestCredentialSpecConversion(t *testing.T) {
|
| 90 |
- cases := []struct {
|
|
| 90 |
+ tests := []struct {
|
|
| 91 | 91 |
name string |
| 92 | 92 |
from swarmapi.Privileges_CredentialSpec |
| 93 | 93 |
to []string |
| ... | ... |
@@ -120,15 +120,14 @@ func TestCredentialSpecConversion(t *testing.T) {
|
| 120 | 120 |
}, |
| 121 | 121 |
} |
| 122 | 122 |
|
| 123 |
- for _, c := range cases {
|
|
| 124 |
- c := c |
|
| 125 |
- t.Run(c.name, func(t *testing.T) {
|
|
| 123 |
+ for _, tc := range tests {
|
|
| 124 |
+ t.Run(tc.name, func(t *testing.T) {
|
|
| 126 | 125 |
task := swarmapi.Task{
|
| 127 | 126 |
Spec: swarmapi.TaskSpec{
|
| 128 | 127 |
Runtime: &swarmapi.TaskSpec_Container{
|
| 129 | 128 |
Container: &swarmapi.ContainerSpec{
|
| 130 | 129 |
Privileges: &swarmapi.Privileges{
|
| 131 |
- CredentialSpec: &c.from, |
|
| 130 |
+ CredentialSpec: &tc.from, |
|
| 132 | 131 |
}, |
| 133 | 132 |
}, |
| 134 | 133 |
}, |
| ... | ... |
@@ -138,13 +137,13 @@ func TestCredentialSpecConversion(t *testing.T) {
|
| 138 | 138 |
// NOTE(dperny): you shouldn't ever pass nil outside of testing, |
| 139 | 139 |
// because if there are CSI volumes, the code will panic. However, |
| 140 | 140 |
// in testing. this is acceptable. |
| 141 |
- assert.DeepEqual(t, c.to, config.hostConfig(nil).SecurityOpt) |
|
| 141 |
+ assert.DeepEqual(t, tc.to, config.hostConfig(nil).SecurityOpt) |
|
| 142 | 142 |
}) |
| 143 | 143 |
} |
| 144 | 144 |
} |
| 145 | 145 |
|
| 146 | 146 |
func TestTmpfsConversion(t *testing.T) {
|
| 147 |
- cases := []struct {
|
|
| 147 |
+ tests := []struct {
|
|
| 148 | 148 |
name string |
| 149 | 149 |
from []swarmapi.Mount |
| 150 | 150 |
to []mount.Mount |
| ... | ... |
@@ -197,20 +196,20 @@ func TestTmpfsConversion(t *testing.T) {
|
| 197 | 197 |
}, |
| 198 | 198 |
} |
| 199 | 199 |
|
| 200 |
- for _, c := range cases {
|
|
| 201 |
- t.Run(c.name, func(t *testing.T) {
|
|
| 200 |
+ for _, tc := range tests {
|
|
| 201 |
+ t.Run(tc.name, func(t *testing.T) {
|
|
| 202 | 202 |
task := swarmapi.Task{
|
| 203 | 203 |
Spec: swarmapi.TaskSpec{
|
| 204 | 204 |
Runtime: &swarmapi.TaskSpec_Container{
|
| 205 | 205 |
Container: &swarmapi.ContainerSpec{
|
| 206 | 206 |
Image: "alpine:latest", |
| 207 |
- Mounts: c.from, |
|
| 207 |
+ Mounts: tc.from, |
|
| 208 | 208 |
}, |
| 209 | 209 |
}, |
| 210 | 210 |
}, |
| 211 | 211 |
} |
| 212 | 212 |
config := containerConfig{task: &task}
|
| 213 |
- assert.Check(t, is.DeepEqual(c.to, config.hostConfig(nil).Mounts)) |
|
| 213 |
+ assert.Check(t, is.DeepEqual(tc.to, config.hostConfig(nil).Mounts)) |
|
| 214 | 214 |
}) |
| 215 | 215 |
} |
| 216 | 216 |
} |