1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/daemon/errors.go
Alexander Morozov d4a8d09d1a Do not rely on string comparison in truncindex
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
2015-11-04 11:34:05 -08:00

23 lines
555 B
Go

package daemon
import (
"strings"
derr "github.com/docker/docker/errors"
"github.com/docker/docker/graph/tags"
"github.com/docker/docker/pkg/parsers"
)
func (d *Daemon) graphNotExistToErrcode(imageName string, err error) error {
if d.Graph().IsNotExist(err, imageName) {
if strings.Contains(imageName, "@") {
return derr.ErrorCodeNoSuchImageHash.WithArgs(imageName)
}
img, tag := parsers.ParseRepositoryTag(imageName)
if tag == "" {
tag = tags.DefaultTag
}
return derr.ErrorCodeNoSuchImageTag.WithArgs(img, tag)
}
return err
}