2015-11-04 04:19:18 +03:00
|
|
|
package daemon
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
derr "github.com/docker/docker/errors"
|
2015-12-05 00:55:15 +03:00
|
|
|
"github.com/docker/docker/reference"
|
2015-11-04 04:19:18 +03:00
|
|
|
)
|
|
|
|
|
2015-11-19 01:20:54 +03:00
|
|
|
func (d *Daemon) imageNotExistToErrcode(err error) error {
|
|
|
|
if dne, isDNE := err.(ErrImageDoesNotExist); isDNE {
|
|
|
|
if strings.Contains(dne.RefOrID, "@") {
|
|
|
|
return derr.ErrorCodeNoSuchImageHash.WithArgs(dne.RefOrID)
|
2015-11-04 04:19:18 +03:00
|
|
|
}
|
2015-12-05 00:55:15 +03:00
|
|
|
tag := reference.DefaultTag
|
2015-11-19 01:20:54 +03:00
|
|
|
ref, err := reference.ParseNamed(dne.RefOrID)
|
|
|
|
if err != nil {
|
|
|
|
return derr.ErrorCodeNoSuchImageTag.WithArgs(dne.RefOrID, tag)
|
2015-11-04 04:19:18 +03:00
|
|
|
}
|
2015-12-05 00:55:15 +03:00
|
|
|
if tagged, isTagged := ref.(reference.NamedTagged); isTagged {
|
2015-11-19 01:20:54 +03:00
|
|
|
tag = tagged.Tag()
|
|
|
|
}
|
|
|
|
return derr.ErrorCodeNoSuchImageTag.WithArgs(ref.Name(), tag)
|
2015-11-04 04:19:18 +03:00
|
|
|
}
|
|
|
|
return err
|
|
|
|
}
|