Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit 4bd45eb

Browse files
committed
Add specific error message for image tag cmd
Add a specific and more understandable error message when trying to tag a non existing image or with an non existing tag. Signed-off-by: Yves Brissaud <[email protected]>
1 parent 81e475c commit 4bd45eb

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

e2e/images_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,20 @@ a-simple-app:latest simple
141141
Err: `could not parse 'b@simple-app' as a valid reference: invalid reference format`,
142142
})
143143

144+
// with unexisting source image
145+
dockerAppImageTag("b-simple-app", "target")
146+
icmd.RunCmd(cmd).Assert(t, icmd.Expected{
147+
ExitCode: 1,
148+
Err: `could not tag 'b-simple-app': no such application image`,
149+
})
150+
151+
// with unexisting source tag
152+
dockerAppImageTag("a-simple-app:not-a-tag", "target")
153+
icmd.RunCmd(cmd).Assert(t, icmd.Expected{
154+
ExitCode: 1,
155+
Err: `could not tag 'a-simple-app:not-a-tag': no such application image`,
156+
})
157+
144158
// tag image with only names
145159
dockerAppImageTag("a-simple-app", "b-simple-app")
146160
icmd.RunCmd(cmd).Assert(t, icmd.Success)

internal/commands/image/tag.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,11 @@ func readBundle(name string, bundleStore store.BundleStore) (*bundle.Bundle, err
4949
return nil, err
5050
}
5151

52-
return bundleStore.Read(cnabRef)
52+
bundle, err := bundleStore.Read(cnabRef)
53+
if err != nil {
54+
return nil, fmt.Errorf("could not tag '%s': no such application image", name)
55+
}
56+
return bundle, nil
5357
}
5458

5559
func storeBundle(bundle *bundle.Bundle, name string, bundleStore store.BundleStore) error {

0 commit comments

Comments
 (0)