Skip to content

Commit 0a72edd

Browse files
committed
Fix failing test
1 parent f4728b4 commit 0a72edd

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

cmd/nerdctl/builder/builder_build_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,30 +76,30 @@ CMD ["echo", "nerdctl-build-test-string"]`, testutil.CommonImage)
7676
Expected: test.Expects(0, nil, test.Equals("nerdctl-build-test-string\n")),
7777
},
7878
{
79-
Description: "Successfully build with output docker, main tag still works",
79+
Description: "Successfully build with output image, main tag still works",
8080
Setup: func(data test.Data, helpers test.Helpers) {
81-
helpers.Ensure("build", data.Get("buildCtx"), "-t", data.Identifier(), "--output=type=docker,name="+data.Identifier("ignored"))
81+
helpers.Ensure("build", data.Get("buildCtx"), "-t", data.Identifier(), "--output=type=image,name="+data.Identifier("ignored"))
8282
},
8383
Command: func(data test.Data, helpers test.Helpers) test.TestableCommand {
84-
return helpers.Command("run", "--rm", data.Identifier("ignored"))
84+
return helpers.Command("run", "--rm", data.Identifier())
8585
},
8686
Cleanup: func(data test.Data, helpers test.Helpers) {
8787
helpers.Anyhow("rmi", "-f", data.Identifier())
8888
},
8989
Expected: test.Expects(0, nil, test.Equals("nerdctl-build-test-string\n")),
9090
},
9191
{
92-
Description: "Successfully build with output docker, name cannot be used",
92+
Description: "Successfully build with output docker, named image",
9393
Setup: func(data test.Data, helpers test.Helpers) {
94-
helpers.Ensure("build", data.Get("buildCtx"), "-t", data.Identifier(), "--output=type=docker,name="+data.Identifier("ignored"))
94+
helpers.Ensure("build", data.Get("buildCtx"), "--output=type=docker,name="+data.Identifier())
9595
},
9696
Command: func(data test.Data, helpers test.Helpers) test.TestableCommand {
97-
return helpers.Command("run", "--rm", data.Identifier("ignored"))
97+
return helpers.Command("run", "--rm", data.Identifier())
9898
},
9999
Cleanup: func(data test.Data, helpers test.Helpers) {
100100
helpers.Anyhow("rmi", "-f", data.Identifier())
101101
},
102-
Expected: test.Expects(-1, nil, nil),
102+
Expected: test.Expects(0, nil, test.Equals("nerdctl-build-test-string\n")),
103103
},
104104
},
105105
}

pkg/cmd/builder/build.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -263,10 +263,7 @@ func generateBuildctlArgs(ctx context.Context, client *containerd.Client, option
263263
if err != nil {
264264
return result, err
265265
}
266-
// Update the output with the the image name if it is not already set
267-
if !strings.Contains(output, "name=") {
268-
output += ",name=" + parsedReference.String()
269-
}
266+
output += ",name=" + parsedReference.String()
270267

271268
// pick the first tag and add it to output
272269
for idx, tag := range tags {

0 commit comments

Comments
 (0)