From 6594d5d6558437d4cdb11a72eda175ead407ec75 Mon Sep 17 00:00:00 2001 From: Valentin Rothberg Date: Wed, 24 Jun 2020 14:44:42 +0200 Subject: podman untag: error if tag doesn't exist Throw an error if a specified tag does not exist. Also make sure that the user input is normalized as we already do for `podman tag`. To prevent regressions, add a set of end-to-end and systemd tests. Last but not least, update the docs and add bash completions. Signed-off-by: Valentin Rothberg --- libpod/image/image.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'libpod/image/image.go') diff --git a/libpod/image/image.go b/libpod/image/image.go index d81f7e911..83e7467e9 100644 --- a/libpod/image/image.go +++ b/libpod/image/image.go @@ -559,15 +559,24 @@ func (i *Image) TagImage(tag string) error { return nil } -// UntagImage removes a tag from the given image +// UntagImage removes the specified tag from the image. +// If the tag does not exist, ErrNoSuchTag is returned. func (i *Image) UntagImage(tag string) error { if err := i.reloadImage(); err != nil { return err } + + // Normalize the tag as we do with TagImage. + ref, err := NormalizedTag(tag) + if err != nil { + return err + } + tag = ref.String() + var newTags []string tags := i.Names() if !util.StringInSlice(tag, tags) { - return nil + return errors.Wrapf(ErrNoSuchTag, "%q", tag) } for _, t := range tags { if tag != t { -- cgit v1.2.3-54-g00ecf