c8d/push: Return error when repository has no tags

In case of `docker push -a`, we need to return an error if there is no
image for the given repository.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
This commit is contained in:
Paweł Gronowski 2023-10-30 10:52:36 +01:00
parent f44b085da6
commit cd95cd0671
No known key found for this signature in database
GPG key ID: B85EFCFE26DEF92A

View file

@ -53,6 +53,10 @@ func (i *ImageService) PushImage(ctx context.Context, sourceRef reference.Named,
return err
}
if len(imgs) == 0 {
return fmt.Errorf("An image does not exist locally with the tag: %s", reference.FamiliarName(sourceRef))
}
for _, img := range imgs {
named, err := reference.ParseNamed(img.Name)
if err != nil {