Browse code

rename "image" vars to prevent conflicts with imports

We have many "image" packages, so these vars easily conflict/shadow
imports. Let's rename them (and in some cases use a const) to
prevent that.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

Sebastiaan van Stijn authored on 2024/01/19 20:31:25
Showing 19 changed files
... ...
@@ -24,10 +24,10 @@ func (s *distributionRouter) getDistributionInfo(ctx context.Context, w http.Res
24 24
 
25 25
 	w.Header().Set("Content-Type", "application/json")
26 26
 
27
-	image := vars["name"]
27
+	imgName := vars["name"]
28 28
 
29 29
 	// TODO why is reference.ParseAnyReference() / reference.ParseNormalizedNamed() not using the reference.ErrTagInvalidFormat (and so on) errors?
30
-	ref, err := reference.ParseAnyReference(image)
30
+	ref, err := reference.ParseAnyReference(imgName)
31 31
 	if err != nil {
32 32
 		return errdefs.InvalidParameter(err)
33 33
 	}
... ...
@@ -37,7 +37,7 @@ func (s *distributionRouter) getDistributionInfo(ctx context.Context, w http.Res
37 37
 			// full image ID
38 38
 			return errors.Errorf("no manifest found for full image ID")
39 39
 		}
40
-		return errdefs.InvalidParameter(errors.Errorf("unknown image reference format: %s", image))
40
+		return errdefs.InvalidParameter(errors.Errorf("unknown image reference format: %s", imgName))
41 41
 	}
42 42
 
43 43
 	// For a search it is not an error if no auth was given. Ignore invalid
... ...
@@ -72,9 +72,9 @@ func (ir *imageRouter) postImagesCreate(ctx context.Context, w http.ResponseWrit
72 72
 		// Special case: "pull -a" may send an image name with a
73 73
 		// trailing :. This is ugly, but let's not break API
74 74
 		// compatibility.
75
-		image := strings.TrimSuffix(img, ":")
75
+		imgName := strings.TrimSuffix(img, ":")
76 76
 
77
-		ref, err := reference.ParseNormalizedNamed(image)
77
+		ref, err := reference.ParseNormalizedNamed(imgName)
78 78
 		if err != nil {
79 79
 			return errdefs.InvalidParameter(err)
80 80
 		}
... ...
@@ -10,11 +10,11 @@ import (
10 10
 )
11 11
 
12 12
 // DistributionInspect returns the image digest with the full manifest.
13
-func (cli *Client) DistributionInspect(ctx context.Context, image, encodedRegistryAuth string) (registry.DistributionInspect, error) {
13
+func (cli *Client) DistributionInspect(ctx context.Context, imageRef, encodedRegistryAuth string) (registry.DistributionInspect, error) {
14 14
 	// Contact the registry to retrieve digest and platform information
15 15
 	var distributionInspect registry.DistributionInspect
16
-	if image == "" {
17
-		return distributionInspect, objectNotFoundError{object: "distribution", id: image}
16
+	if imageRef == "" {
17
+		return distributionInspect, objectNotFoundError{object: "distribution", id: imageRef}
18 18
 	}
19 19
 
20 20
 	if err := cli.NewVersionError(ctx, "1.30", "distribution inspect"); err != nil {
... ...
@@ -28,7 +28,7 @@ func (cli *Client) DistributionInspect(ctx context.Context, image, encodedRegist
28 28
 		}
29 29
 	}
30 30
 
31
-	resp, err := cli.get(ctx, "/distribution/"+image+"/json", url.Values{}, headers)
31
+	resp, err := cli.get(ctx, "/distribution/"+imageRef+"/json", url.Values{}, headers)
32 32
 	defer ensureReaderClosed(resp)
33 33
 	if err != nil {
34 34
 		return distributionInspect, err
... ...
@@ -109,11 +109,11 @@ func TestServiceConvertToGRPCGenericRuntimePlugin(t *testing.T) {
109 109
 }
110 110
 
111 111
 func TestServiceConvertToGRPCContainerRuntime(t *testing.T) {
112
-	image := "alpine:latest"
112
+	const imgName = "alpine:latest"
113 113
 	s := swarmtypes.ServiceSpec{
114 114
 		TaskTemplate: swarmtypes.TaskSpec{
115 115
 			ContainerSpec: &swarmtypes.ContainerSpec{
116
-				Image: image,
116
+				Image: imgName,
117 117
 			},
118 118
 		},
119 119
 		Mode: swarmtypes.ServiceMode{
... ...
@@ -131,8 +131,8 @@ func TestServiceConvertToGRPCContainerRuntime(t *testing.T) {
131 131
 		t.Fatal("expected type swarmapi.TaskSpec_Container")
132 132
 	}
133 133
 
134
-	if v.Container.Image != image {
135
-		t.Fatalf("expected image %s; received %s", image, v.Container.Image)
134
+	if v.Container.Image != imgName {
135
+		t.Fatalf("expected image %s; received %s", imgName, v.Container.Image)
136 136
 	}
137 137
 }
138 138
 
... ...
@@ -132,8 +132,8 @@ func (s *DockerAPISuite) TestAPIImagesSizeCompatibility(c *testing.T) {
132 132
 	images, err := apiclient.ImageList(testutil.GetContext(c), types.ImageListOptions{})
133 133
 	assert.NilError(c, err)
134 134
 	assert.Assert(c, len(images) != 0)
135
-	for _, image := range images {
136
-		assert.Assert(c, image.Size != int64(-1))
135
+	for _, img := range images {
136
+		assert.Assert(c, img.Size != int64(-1))
137 137
 	}
138 138
 
139 139
 	apiclient, err = client.NewClientWithOpts(client.FromEnv, client.WithVersion("v1.24"))
... ...
@@ -143,7 +143,7 @@ func (s *DockerAPISuite) TestAPIImagesSizeCompatibility(c *testing.T) {
143 143
 	v124Images, err := apiclient.ImageList(testutil.GetContext(c), types.ImageListOptions{})
144 144
 	assert.NilError(c, err)
145 145
 	assert.Assert(c, len(v124Images) != 0)
146
-	for _, image := range v124Images {
147
-		assert.Assert(c, image.Size != int64(-1))
146
+	for _, img := range v124Images {
147
+		assert.Assert(c, img.Size != int64(-1))
148 148
 	}
149 149
 }
... ...
@@ -6044,22 +6044,22 @@ func (s *DockerCLIBuildSuite) TestBuildWindowsEnvCaseInsensitive(c *testing.T) {
6044 6044
 
6045 6045
 // Test case for 29667
6046 6046
 func (s *DockerCLIBuildSuite) TestBuildWorkdirImageCmd(c *testing.T) {
6047
-	image := "testworkdirimagecmd"
6048
-	buildImageSuccessfully(c, image, build.WithDockerfile(`
6047
+	imgName := "testworkdirimagecmd"
6048
+	buildImageSuccessfully(c, imgName, build.WithDockerfile(`
6049 6049
 FROM busybox
6050 6050
 WORKDIR /foo/bar
6051 6051
 `))
6052
-	out := cli.DockerCmd(c, "inspect", "--format", "{{ json .Config.Cmd }}", image).Stdout()
6052
+	out := cli.DockerCmd(c, "inspect", "--format", "{{ json .Config.Cmd }}", imgName).Stdout()
6053 6053
 	assert.Equal(c, strings.TrimSpace(out), `["sh"]`)
6054 6054
 
6055
-	image = "testworkdirlabelimagecmd"
6056
-	buildImageSuccessfully(c, image, build.WithDockerfile(`
6055
+	imgName = "testworkdirlabelimagecmd"
6056
+	buildImageSuccessfully(c, imgName, build.WithDockerfile(`
6057 6057
 FROM busybox
6058 6058
 WORKDIR /foo/bar
6059 6059
 LABEL a=b
6060 6060
 `))
6061 6061
 
6062
-	out = cli.DockerCmd(c, "inspect", "--format", "{{ json .Config.Cmd }}", image).Stdout()
6062
+	out = cli.DockerCmd(c, "inspect", "--format", "{{ json .Config.Cmd }}", imgName).Stdout()
6063 6063
 	assert.Equal(c, strings.TrimSpace(out), `["sh"]`)
6064 6064
 }
6065 6065
 
... ...
@@ -195,12 +195,12 @@ func (s *DockerCLICreateSuite) TestCreateLabelFromImage(c *testing.T) {
195 195
 }
196 196
 
197 197
 func (s *DockerCLICreateSuite) TestCreateHostnameWithNumber(c *testing.T) {
198
-	image := "busybox"
198
+	imgName := "busybox"
199 199
 	// Busybox on Windows does not implement hostname command
200 200
 	if testEnv.DaemonInfo.OSType == "windows" {
201
-		image = testEnv.PlatformDefaults.BaseImage
201
+		imgName = testEnv.PlatformDefaults.BaseImage
202 202
 	}
203
-	out := cli.DockerCmd(c, "run", "-h", "web.0", image, "hostname").Combined()
203
+	out := cli.DockerCmd(c, "run", "-h", "web.0", imgName, "hostname").Combined()
204 204
 	assert.Equal(c, strings.TrimSpace(out), "web.0", "hostname not set, expected `web.0`, got: %s", out)
205 205
 }
206 206
 
... ...
@@ -67,9 +67,9 @@ func (s *DockerCLIEventSuite) TestEventsTimestampFormats(c *testing.T) {
67 67
 }
68 68
 
69 69
 func (s *DockerCLIEventSuite) TestEventsUntag(c *testing.T) {
70
-	image := "busybox"
71
-	cli.DockerCmd(c, "tag", image, "utest:tag1")
72
-	cli.DockerCmd(c, "tag", image, "utest:tag2")
70
+	const imgName = "busybox"
71
+	cli.DockerCmd(c, "tag", imgName, "utest:tag1")
72
+	cli.DockerCmd(c, "tag", imgName, "utest:tag2")
73 73
 	cli.DockerCmd(c, "rmi", "utest:tag1")
74 74
 	cli.DockerCmd(c, "rmi", "utest:tag2")
75 75
 
... ...
@@ -143,8 +143,8 @@ func (s *DockerCLIEventSuite) TestEventsContainerEventsSinceUnixEpoch(c *testing
143 143
 func (s *DockerCLIEventSuite) TestEventsImageTag(c *testing.T) {
144 144
 	time.Sleep(1 * time.Second) // because API has seconds granularity
145 145
 	since := daemonUnixTime(c)
146
-	image := "testimageevents:tag"
147
-	cli.DockerCmd(c, "tag", "busybox", image)
146
+	const imgName = "testimageevents:tag"
147
+	cli.DockerCmd(c, "tag", "busybox", imgName)
148 148
 
149 149
 	out := cli.DockerCmd(c, "events", "--since", since, "--until", daemonUnixTime(c)).Stdout()
150 150
 
... ...
@@ -153,7 +153,7 @@ func (s *DockerCLIEventSuite) TestEventsImageTag(c *testing.T) {
153 153
 	event := strings.TrimSpace(events[0])
154 154
 
155 155
 	matches := eventstestutils.ScanMap(event)
156
-	assert.Assert(c, matchEventID(matches, image), "matches: %v\nout:\n%s", matches, out)
156
+	assert.Assert(c, matchEventID(matches, imgName), "matches: %v\nout:\n%s", matches, out)
157 157
 	assert.Equal(c, matches["action"], "tag")
158 158
 }
159 159
 
... ...
@@ -227,8 +227,8 @@ func (s *DockerCLIImagesSuite) TestImagesFilterSpaceTrimCase(c *testing.T) {
227 227
 		if idx < 4 && !reflect.DeepEqual(listing, imageListings[idx+1]) {
228 228
 			for idx, errListing := range imageListings {
229 229
 				fmt.Printf("out %d\n", idx)
230
-				for _, image := range errListing {
231
-					fmt.Print(image)
230
+				for _, img := range errListing {
231
+					fmt.Print(img)
232 232
 				}
233 233
 				fmt.Print("")
234 234
 			}
... ...
@@ -40,8 +40,8 @@ func (s *DockerCLIImportSuite) TestImportDisplay(c *testing.T) {
40 40
 
41 41
 	assert.Assert(c, strings.Count(out, "\n") == 1, "display is expected 1 '\\n' but didn't")
42 42
 
43
-	image := strings.TrimSpace(out)
44
-	out = cli.DockerCmd(c, "run", "--rm", image, "true").Combined()
43
+	imgRef := strings.TrimSpace(out)
44
+	out = cli.DockerCmd(c, "run", "--rm", imgRef, "true").Combined()
45 45
 	assert.Equal(c, out, "", "command output should've been nothing.")
46 46
 }
47 47
 
... ...
@@ -71,9 +71,9 @@ func (s *DockerCLIImportSuite) TestImportFile(c *testing.T) {
71 71
 
72 72
 	out := cli.DockerCmd(c, "import", temporaryFile.Name()).Combined()
73 73
 	assert.Assert(c, strings.Count(out, "\n") == 1, "display is expected 1 '\\n' but didn't")
74
-	image := strings.TrimSpace(out)
74
+	imgRef := strings.TrimSpace(out)
75 75
 
76
-	out = cli.DockerCmd(c, "run", "--rm", image, "true").Combined()
76
+	out = cli.DockerCmd(c, "run", "--rm", imgRef, "true").Combined()
77 77
 	assert.Equal(c, out, "", "command output should've been nothing.")
78 78
 }
79 79
 
... ...
@@ -94,9 +94,9 @@ func (s *DockerCLIImportSuite) TestImportGzipped(c *testing.T) {
94 94
 	temporaryFile.Close()
95 95
 	out := cli.DockerCmd(c, "import", temporaryFile.Name()).Combined()
96 96
 	assert.Assert(c, strings.Count(out, "\n") == 1, "display is expected 1 '\\n' but didn't")
97
-	image := strings.TrimSpace(out)
97
+	imgRef := strings.TrimSpace(out)
98 98
 
99
-	out = cli.DockerCmd(c, "run", "--rm", image, "true").Combined()
99
+	out = cli.DockerCmd(c, "run", "--rm", imgRef, "true").Combined()
100 100
 	assert.Equal(c, out, "", "command output should've been nothing.")
101 101
 }
102 102
 
... ...
@@ -116,9 +116,9 @@ func (s *DockerCLIImportSuite) TestImportFileWithMessage(c *testing.T) {
116 116
 	message := "Testing commit message"
117 117
 	out := cli.DockerCmd(c, "import", "-m", message, temporaryFile.Name()).Combined()
118 118
 	assert.Assert(c, strings.Count(out, "\n") == 1, "display is expected 1 '\\n' but didn't")
119
-	image := strings.TrimSpace(out)
119
+	imgRef := strings.TrimSpace(out)
120 120
 
121
-	out = cli.DockerCmd(c, "history", image).Combined()
121
+	out = cli.DockerCmd(c, "history", imgRef).Combined()
122 122
 	split := strings.Split(out, "\n")
123 123
 
124 124
 	assert.Equal(c, len(split), 3, "expected 3 lines from image history")
... ...
@@ -127,7 +127,7 @@ func (s *DockerCLIImportSuite) TestImportFileWithMessage(c *testing.T) {
127 127
 
128 128
 	assert.Equal(c, message, split[3], "didn't get expected value in commit message")
129 129
 
130
-	out = cli.DockerCmd(c, "run", "--rm", image, "true").Combined()
130
+	out = cli.DockerCmd(c, "run", "--rm", imgRef, "true").Combined()
131 131
 	assert.Equal(c, out, "", "command output should've been nothing")
132 132
 }
133 133
 
... ...
@@ -147,8 +147,8 @@ func (s *DockerCLIImportSuite) TestImportWithQuotedChanges(c *testing.T) {
147 147
 	cli.Docker(cli.Args("export", "test-import"), cli.WithStdout(bufio.NewWriter(temporaryFile))).Assert(c, icmd.Success)
148 148
 
149 149
 	result := cli.DockerCmd(c, "import", "-c", `ENTRYPOINT ["/bin/sh", "-c"]`, temporaryFile.Name())
150
-	image := strings.TrimSpace(result.Stdout())
150
+	imgRef := strings.TrimSpace(result.Stdout())
151 151
 
152
-	result = cli.DockerCmd(c, "run", "--rm", image, "true")
152
+	result = cli.DockerCmd(c, "run", "--rm", imgRef, "true")
153 153
 	result.Assert(c, icmd.Expected{Out: icmd.None})
154 154
 }
... ...
@@ -179,17 +179,17 @@ func (s *DockerCLIRmiSuite) TestRmiTagWithExistingContainers(c *testing.T) {
179 179
 }
180 180
 
181 181
 func (s *DockerCLIRmiSuite) TestRmiForceWithExistingContainers(c *testing.T) {
182
-	image := "busybox-clone"
182
+	const imgName = "busybox-clone"
183 183
 
184 184
 	icmd.RunCmd(icmd.Cmd{
185
-		Command: []string{dockerBinary, "build", "--no-cache", "-t", image, "-"},
185
+		Command: []string{dockerBinary, "build", "--no-cache", "-t", imgName, "-"},
186 186
 		Stdin: strings.NewReader(`FROM busybox
187 187
 MAINTAINER foo`),
188 188
 	}).Assert(c, icmd.Success)
189 189
 
190
-	cli.DockerCmd(c, "run", "--name", "test-force-rmi", image, "/bin/true")
190
+	cli.DockerCmd(c, "run", "--name", "test-force-rmi", imgName, "/bin/true")
191 191
 
192
-	cli.DockerCmd(c, "rmi", "-f", image)
192
+	cli.DockerCmd(c, "rmi", "-f", imgName)
193 193
 }
194 194
 
195 195
 func (s *DockerCLIRmiSuite) TestRmiWithMultipleRepositories(c *testing.T) {
... ...
@@ -260,7 +260,7 @@ func (s *DockerCLIRmiSuite) TestRmiContainerImageNotFound(c *testing.T) {
260 260
 
261 261
 // #13422
262 262
 func (s *DockerCLIRmiSuite) TestRmiUntagHistoryLayer(c *testing.T) {
263
-	image := "tmp1"
263
+	const imgName = "tmp1"
264 264
 	// Build an image for testing.
265 265
 	dockerfile := `FROM busybox
266 266
 MAINTAINER foo
... ...
@@ -268,8 +268,8 @@ RUN echo 0 #layer0
268 268
 RUN echo 1 #layer1
269 269
 RUN echo 2 #layer2
270 270
 `
271
-	buildImageSuccessfully(c, image, build.WithoutCache, build.WithDockerfile(dockerfile))
272
-	out := cli.DockerCmd(c, "history", "-q", image).Stdout()
271
+	buildImageSuccessfully(c, imgName, build.WithoutCache, build.WithDockerfile(dockerfile))
272
+	out := cli.DockerCmd(c, "history", "-q", imgName).Stdout()
273 273
 	ids := strings.Split(out, "\n")
274 274
 	idToTag := ids[2]
275 275
 
... ...
@@ -277,7 +277,7 @@ RUN echo 2 #layer2
277 277
 	newTag := "tmp2"
278 278
 	cli.DockerCmd(c, "tag", idToTag, newTag)
279 279
 	// Create a container based on "tmp1".
280
-	cli.DockerCmd(c, "run", "-d", image, "true")
280
+	cli.DockerCmd(c, "run", "-d", imgName, "true")
281 281
 
282 282
 	// See if the "tmp2" can be untagged.
283 283
 	out = cli.DockerCmd(c, "rmi", newTag).Combined()
... ...
@@ -145,19 +145,19 @@ func (s *DockerCLIRunSuite) TestRunDetachedContainerIDPrinting(c *testing.T) {
145 145
 // the working directory should be set correctly
146 146
 func (s *DockerCLIRunSuite) TestRunWorkingDirectory(c *testing.T) {
147 147
 	dir := "/root"
148
-	image := "busybox"
148
+	const imgName = "busybox"
149 149
 	if testEnv.DaemonInfo.OSType == "windows" {
150 150
 		dir = `C:/Windows`
151 151
 	}
152 152
 
153 153
 	// First with -w
154
-	out := cli.DockerCmd(c, "run", "-w", dir, image, "pwd").Stdout()
154
+	out := cli.DockerCmd(c, "run", "-w", dir, imgName, "pwd").Stdout()
155 155
 	if strings.TrimSpace(out) != dir {
156 156
 		c.Errorf("-w failed to set working directory")
157 157
 	}
158 158
 
159 159
 	// Then with --workdir
160
-	out = cli.DockerCmd(c, "run", "--workdir", dir, image, "pwd").Stdout()
160
+	out = cli.DockerCmd(c, "run", "--workdir", dir, imgName, "pwd").Stdout()
161 161
 	if strings.TrimSpace(out) != dir {
162 162
 		c.Errorf("--workdir failed to set working directory")
163 163
 	}
... ...
@@ -166,14 +166,14 @@ func (s *DockerCLIRunSuite) TestRunWorkingDirectory(c *testing.T) {
166 166
 // pinging Google's DNS resolver should fail when we disable the networking
167 167
 func (s *DockerCLIRunSuite) TestRunWithoutNetworking(c *testing.T) {
168 168
 	count := "-c"
169
-	image := "busybox"
169
+	imgName := "busybox"
170 170
 	if testEnv.DaemonInfo.OSType == "windows" {
171 171
 		count = "-n"
172
-		image = testEnv.PlatformDefaults.BaseImage
172
+		imgName = testEnv.PlatformDefaults.BaseImage
173 173
 	}
174 174
 
175 175
 	// First using the long form --net
176
-	out, exitCode, err := dockerCmdWithError("run", "--net=none", image, "ping", count, "1", "8.8.8.8")
176
+	out, exitCode, err := dockerCmdWithError("run", "--net=none", imgName, "ping", count, "1", "8.8.8.8")
177 177
 	if err != nil && exitCode != 1 {
178 178
 		c.Fatal(out, err)
179 179
 	}
... ...
@@ -623,18 +623,18 @@ func (s *DockerCLIRunSuite) TestRunCreateVolumeWithSymlink(c *testing.T) {
623 623
 	testRequires(c, DaemonIsLinux)
624 624
 	workingDirectory, err := os.MkdirTemp("", "TestRunCreateVolumeWithSymlink")
625 625
 	assert.NilError(c, err)
626
-	image := "docker-test-createvolumewithsymlink"
626
+	const imgName = "docker-test-createvolumewithsymlink"
627 627
 
628
-	buildCmd := exec.Command(dockerBinary, "build", "-t", image, "-")
628
+	buildCmd := exec.Command(dockerBinary, "build", "-t", imgName, "-")
629 629
 	buildCmd.Stdin = strings.NewReader(`FROM busybox
630 630
 		RUN ln -s home /bar`)
631 631
 	buildCmd.Dir = workingDirectory
632 632
 	err = buildCmd.Run()
633 633
 	if err != nil {
634
-		c.Fatalf("could not build '%s': %v", image, err)
634
+		c.Fatalf("could not build '%s': %v", imgName, err)
635 635
 	}
636 636
 
637
-	_, exitCode, err := dockerCmdWithError("run", "-v", "/bar/foo", "--name", "test-createvolumewithsymlink", image, "sh", "-c", "mount | grep -q /home/foo")
637
+	_, exitCode, err := dockerCmdWithError("run", "-v", "/bar/foo", "--name", "test-createvolumewithsymlink", imgName, "sh", "-c", "mount | grep -q /home/foo")
638 638
 	if err != nil || exitCode != 0 {
639 639
 		c.Fatalf("[run] err: %v, exitcode: %d", err, exitCode)
640 640
 	}
... ...
@@ -1934,9 +1934,9 @@ func (s *DockerCLIRunSuite) TestRunCidFileCleanupIfEmpty(c *testing.T) {
1934 1934
 	tmpCidFile := path.Join(tmpDir, "cid")
1935 1935
 
1936 1936
 	// This must be an image that has no CMD or ENTRYPOINT set
1937
-	image := loadSpecialImage(c, specialimage.EmptyFS)
1937
+	imgRef := loadSpecialImage(c, specialimage.EmptyFS)
1938 1938
 
1939
-	out, _, err := dockerCmdWithError("run", "--cidfile", tmpCidFile, image)
1939
+	out, _, err := dockerCmdWithError("run", "--cidfile", tmpCidFile, imgRef)
1940 1940
 	if err == nil {
1941 1941
 		c.Fatalf("Run without command must fail. out=%s", out)
1942 1942
 	} else if !strings.Contains(out, "no command specified") {
... ...
@@ -65,7 +65,7 @@ func (s *DockerSwarmSuite) TestSwarmNetworkPluginV2(c *testing.T) {
65 65
 	d2 := s.AddDaemon(ctx, c, true, false)
66 66
 
67 67
 	// install plugin on d1 and d2
68
-	pluginName := "aragunathan/global-net-plugin:latest"
68
+	const pluginName = "aragunathan/global-net-plugin:latest"
69 69
 
70 70
 	_, err := d1.Cmd("plugin", "install", pluginName, "--grant-all-permissions")
71 71
 	assert.NilError(c, err)
... ...
@@ -74,12 +74,12 @@ func (s *DockerSwarmSuite) TestSwarmNetworkPluginV2(c *testing.T) {
74 74
 	assert.NilError(c, err)
75 75
 
76 76
 	// create network
77
-	networkName := "globalnet"
77
+	const networkName = "globalnet"
78 78
 	_, err = d1.Cmd("network", "create", "--driver", pluginName, networkName)
79 79
 	assert.NilError(c, err)
80 80
 
81 81
 	// create a global service to ensure that both nodes will have an instance
82
-	serviceName := "my-service"
82
+	const serviceName = "my-service"
83 83
 	_, err = d1.Cmd("service", "create", "--detach", "--no-resolve-image", "--name", serviceName, "--mode=global", "--network", networkName, "busybox", "top")
84 84
 	assert.NilError(c, err)
85 85
 
... ...
@@ -100,10 +100,10 @@ func (s *DockerSwarmSuite) TestSwarmNetworkPluginV2(c *testing.T) {
100 100
 
101 101
 	time.Sleep(20 * time.Second)
102 102
 
103
-	image := "busybox:latest"
103
+	const imgName = "busybox:latest"
104 104
 	// create a new global service again.
105
-	_, err = d1.Cmd("service", "create", "--detach", "--no-resolve-image", "--name", serviceName, "--mode=global", "--network", networkName, image, "top")
105
+	_, err = d1.Cmd("service", "create", "--detach", "--no-resolve-image", "--name", serviceName, "--mode=global", "--network", networkName, imgName, "top")
106 106
 	assert.NilError(c, err)
107 107
 
108
-	poll.WaitOn(c, pollCheck(c, d1.CheckRunningTaskImages(ctx), checker.DeepEquals(map[string]int{image: 1})), poll.WithTimeout(defaultReconciliationTimeout))
108
+	poll.WaitOn(c, pollCheck(c, d1.CheckRunningTaskImages(ctx), checker.DeepEquals(map[string]int{imgName: 1})), poll.WithTimeout(defaultReconciliationTimeout))
109 109
 }
... ...
@@ -469,13 +469,13 @@ func (s *DockerCLIVolumeSuite) TestVolumeCliInspectWithVolumeOpts(c *testing.T)
469 469
 func (s *DockerCLIVolumeSuite) TestDuplicateMountpointsForVolumesFrom(c *testing.T) {
470 470
 	testRequires(c, DaemonIsLinux)
471 471
 
472
-	const image = "vimage"
473
-	buildImageSuccessfully(c, image, build.WithDockerfile(`
472
+	const imgName = "vimage"
473
+	buildImageSuccessfully(c, imgName, build.WithDockerfile(`
474 474
 		FROM busybox
475 475
 		VOLUME ["/tmp/data"]`))
476 476
 
477
-	cli.DockerCmd(c, "run", "--name=data1", image, "true")
478
-	cli.DockerCmd(c, "run", "--name=data2", image, "true")
477
+	cli.DockerCmd(c, "run", "--name=data1", imgName, "true")
478
+	cli.DockerCmd(c, "run", "--name=data2", imgName, "true")
479 479
 
480 480
 	data1 := cli.DockerCmd(c, "inspect", "--format", "{{(index .Mounts 0).Name}}", "data1").Stdout()
481 481
 	data1 = strings.TrimSpace(data1)
... ...
@@ -510,13 +510,13 @@ func (s *DockerCLIVolumeSuite) TestDuplicateMountpointsForVolumesFrom(c *testing
510 510
 func (s *DockerCLIVolumeSuite) TestDuplicateMountpointsForVolumesFromAndBind(c *testing.T) {
511 511
 	testRequires(c, DaemonIsLinux)
512 512
 
513
-	const image = "vimage"
514
-	buildImageSuccessfully(c, image, build.WithDockerfile(`
513
+	const imgName = "vimage"
514
+	buildImageSuccessfully(c, imgName, build.WithDockerfile(`
515 515
                 FROM busybox
516 516
                 VOLUME ["/tmp/data"]`))
517 517
 
518
-	cli.DockerCmd(c, "run", "--name=data1", image, "true")
519
-	cli.DockerCmd(c, "run", "--name=data2", image, "true")
518
+	cli.DockerCmd(c, "run", "--name=data1", imgName, "true")
519
+	cli.DockerCmd(c, "run", "--name=data2", imgName, "true")
520 520
 
521 521
 	data1 := cli.DockerCmd(c, "inspect", "--format", "{{(index .Mounts 0).Name}}", "data1").Stdout()
522 522
 	data1 = strings.TrimSpace(data1)
... ...
@@ -552,13 +552,13 @@ func (s *DockerCLIVolumeSuite) TestDuplicateMountpointsForVolumesFromAndBind(c *
552 552
 func (s *DockerCLIVolumeSuite) TestDuplicateMountpointsForVolumesFromAndMounts(c *testing.T) {
553 553
 	testRequires(c, testEnv.IsLocalDaemon, DaemonIsLinux)
554 554
 
555
-	const image = "vimage"
556
-	buildImageSuccessfully(c, image, build.WithDockerfile(`
555
+	const imgName = "vimage"
556
+	buildImageSuccessfully(c, imgName, build.WithDockerfile(`
557 557
                 FROM busybox
558 558
                 VOLUME ["/tmp/data"]`))
559 559
 
560
-	cli.DockerCmd(c, "run", "--name=data1", image, "true")
561
-	cli.DockerCmd(c, "run", "--name=data2", image, "true")
560
+	cli.DockerCmd(c, "run", "--name=data1", imgName, "true")
561
+	cli.DockerCmd(c, "run", "--name=data2", imgName, "true")
562 562
 
563 563
 	data1 := cli.DockerCmd(c, "inspect", "--format", "{{(index .Mounts 0).Name}}", "data1").Stdout()
564 564
 	data1 = strings.TrimSpace(data1)
... ...
@@ -219,15 +219,15 @@ func TestBuildMultiStageParentConfig(t *testing.T) {
219 219
 	resp.Body.Close()
220 220
 	assert.NilError(t, err)
221 221
 
222
-	image, _, err := apiclient.ImageInspectWithRaw(ctx, imgName)
222
+	img, _, err := apiclient.ImageInspectWithRaw(ctx, imgName)
223 223
 	assert.NilError(t, err)
224 224
 
225 225
 	expected := "/foo/sub2"
226 226
 	if testEnv.DaemonInfo.OSType == "windows" {
227 227
 		expected = `C:\foo\sub2`
228 228
 	}
229
-	assert.Check(t, is.Equal(expected, image.Config.WorkingDir))
230
-	assert.Check(t, is.Contains(image.Config.Env, "WHO=parent"))
229
+	assert.Check(t, is.Equal(expected, img.Config.WorkingDir))
230
+	assert.Check(t, is.Contains(img.Config.Env, "WHO=parent"))
231 231
 }
232 232
 
233 233
 // Test cases in #36996
... ...
@@ -268,12 +268,12 @@ func TestBuildLabelWithTargets(t *testing.T) {
268 268
 	resp.Body.Close()
269 269
 	assert.NilError(t, err)
270 270
 
271
-	image, _, err := apiclient.ImageInspectWithRaw(ctx, imgName)
271
+	img, _, err := apiclient.ImageInspectWithRaw(ctx, imgName)
272 272
 	assert.NilError(t, err)
273 273
 
274 274
 	testLabels["label-a"] = "inline-a"
275 275
 	for k, v := range testLabels {
276
-		x, ok := image.Config.Labels[k]
276
+		x, ok := img.Config.Labels[k]
277 277
 		assert.Assert(t, ok)
278 278
 		assert.Assert(t, x == v)
279 279
 	}
... ...
@@ -295,12 +295,12 @@ func TestBuildLabelWithTargets(t *testing.T) {
295 295
 	resp.Body.Close()
296 296
 	assert.NilError(t, err)
297 297
 
298
-	image, _, err = apiclient.ImageInspectWithRaw(ctx, imgName)
298
+	img, _, err = apiclient.ImageInspectWithRaw(ctx, imgName)
299 299
 	assert.NilError(t, err)
300 300
 
301 301
 	testLabels["label-b"] = "inline-b"
302 302
 	for k, v := range testLabels {
303
-		x, ok := image.Config.Labels[k]
303
+		x, ok := img.Config.Labels[k]
304 304
 		assert.Assert(t, ok)
305 305
 		assert.Assert(t, x == v)
306 306
 	}
... ...
@@ -376,9 +376,9 @@ RUN cat somefile`
376 376
 	assert.NilError(t, err)
377 377
 	assert.Assert(t, is.Equal(3, len(imageIDs)))
378 378
 
379
-	image, _, err := apiclient.ImageInspectWithRaw(ctx, imageIDs[2])
379
+	img, _, err := apiclient.ImageInspectWithRaw(ctx, imageIDs[2])
380 380
 	assert.NilError(t, err)
381
-	assert.Check(t, is.Contains(image.Config.Env, "bar=baz"))
381
+	assert.Check(t, is.Contains(img.Config.Env, "bar=baz"))
382 382
 }
383 383
 
384 384
 // #35403 #36122
... ...
@@ -58,7 +58,7 @@ func TestRemoveImageGarbageCollector(t *testing.T) {
58 58
 		LayerStore: layerStore,
59 59
 	})
60 60
 
61
-	img := "test-garbage-collector"
61
+	const imgName = "test-garbage-collector"
62 62
 
63 63
 	// Build a image with multiple layers
64 64
 	dockerfile := `FROM busybox
... ...
@@ -70,13 +70,13 @@ func TestRemoveImageGarbageCollector(t *testing.T) {
70 70
 		types.ImageBuildOptions{
71 71
 			Remove:      true,
72 72
 			ForceRemove: true,
73
-			Tags:        []string{img},
73
+			Tags:        []string{imgName},
74 74
 		})
75 75
 	assert.NilError(t, err)
76 76
 	_, err = io.Copy(io.Discard, resp.Body)
77 77
 	resp.Body.Close()
78 78
 	assert.NilError(t, err)
79
-	image, _, err := client.ImageInspectWithRaw(ctx, img)
79
+	image, _, err := client.ImageInspectWithRaw(ctx, imgName)
80 80
 	assert.NilError(t, err)
81 81
 
82 82
 	// Mark latest image layer to immutable
... ...
@@ -90,7 +90,7 @@ func TestRemoveImageGarbageCollector(t *testing.T) {
90 90
 
91 91
 	// Try to remove the image, it should generate error
92 92
 	// but marking layer back to mutable before checking errors (so we don't break CI server)
93
-	_, err = client.ImageRemove(ctx, img, types.ImageRemoveOptions{})
93
+	_, err = client.ImageRemove(ctx, imgName, types.ImageRemoveOptions{})
94 94
 	attr = 0x00000000
95 95
 	argp = uintptr(unsafe.Pointer(&attr))
96 96
 	_, _, errno = syscall.Syscall(syscall.SYS_IOCTL, file.Fd(), fsflags, argp)
... ...
@@ -23,18 +23,18 @@ type f struct {
23 23
 func TestDecodeContainerConfig(t *testing.T) {
24 24
 	var (
25 25
 		fixtures []f
26
-		image    string
26
+		imgName  string
27 27
 	)
28 28
 
29 29
 	if runtime.GOOS != "windows" {
30
-		image = "ubuntu"
30
+		imgName = "ubuntu"
31 31
 		fixtures = []f{
32 32
 			{"fixtures/unix/container_config_1_14.json", strslice.StrSlice{}},
33 33
 			{"fixtures/unix/container_config_1_17.json", strslice.StrSlice{"bash"}},
34 34
 			{"fixtures/unix/container_config_1_19.json", strslice.StrSlice{"bash"}},
35 35
 		}
36 36
 	} else {
37
-		image = "windows"
37
+		imgName = "windows"
38 38
 		fixtures = []f{
39 39
 			{"fixtures/windows/container_config_1_19.json", strslice.StrSlice{"cmd"}},
40 40
 		}
... ...
@@ -53,8 +53,8 @@ func TestDecodeContainerConfig(t *testing.T) {
53 53
 				t.Fatal(err)
54 54
 			}
55 55
 
56
-			if c.Image != image {
57
-				t.Fatalf("Expected %s image, found %s", image, c.Image)
56
+			if c.Image != imgName {
57
+				t.Fatalf("Expected %s image, found %s", imgName, c.Image)
58 58
 			}
59 59
 
60 60
 			if len(c.Entrypoint) != len(f.entrypoint) {
... ...
@@ -100,13 +100,13 @@ func deleteAllImages(ctx context.Context, t testing.TB, apiclient client.ImageAP
100 100
 	images, err := apiclient.ImageList(ctx, types.ImageListOptions{})
101 101
 	assert.Check(t, err, "failed to list images")
102 102
 
103
-	for _, image := range images {
104
-		tags := tagsFromImageSummary(image)
105
-		if _, ok := protectedImages[image.ID]; ok {
103
+	for _, img := range images {
104
+		tags := tagsFromImageSummary(img)
105
+		if _, ok := protectedImages[img.ID]; ok {
106 106
 			continue
107 107
 		}
108 108
 		if len(tags) == 0 {
109
-			removeImage(ctx, t, apiclient, image.ID)
109
+			removeImage(ctx, t, apiclient, img.ID)
110 110
 			continue
111 111
 		}
112 112
 		for _, tag := range tags {
... ...
@@ -89,8 +89,8 @@ func getExistingContainers(ctx context.Context, t testing.TB, testEnv *Execution
89 89
 // ProtectImage adds the specified image(s) to be protected in case of clean
90 90
 func (e *Execution) ProtectImage(t testing.TB, images ...string) {
91 91
 	t.Helper()
92
-	for _, image := range images {
93
-		e.protectedElements.images[image] = struct{}{}
92
+	for _, img := range images {
93
+		e.protectedElements.images[img] = struct{}{}
94 94
 	}
95 95
 }
96 96