2015-11-03 20:19:18 -05:00
|
|
|
package daemon
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
|
2015-11-18 17:20:54 -05:00
|
|
|
"github.com/docker/distribution/reference"
|
2015-11-03 20:19:18 -05:00
|
|
|
derr "github.com/docker/docker/errors"
|
2015-11-18 17:20:54 -05:00
|
|
|
tagpkg "github.com/docker/docker/tag"
|
2015-11-03 20:19:18 -05:00
|
|
|
)
|
|
|
|
|
2015-11-18 17:20:54 -05: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-03 20:19:18 -05:00
|
|
|
}
|
2015-11-18 17:20:54 -05:00
|
|
|
tag := tagpkg.DefaultTag
|
|
|
|
ref, err := reference.ParseNamed(dne.RefOrID)
|
|
|
|
if err != nil {
|
|
|
|
return derr.ErrorCodeNoSuchImageTag.WithArgs(dne.RefOrID, tag)
|
2015-11-03 20:19:18 -05:00
|
|
|
}
|
2015-11-18 17:20:54 -05:00
|
|
|
if tagged, isTagged := ref.(reference.Tagged); isTagged {
|
|
|
|
tag = tagged.Tag()
|
|
|
|
}
|
|
|
|
return derr.ErrorCodeNoSuchImageTag.WithArgs(ref.Name(), tag)
|
2015-11-03 20:19:18 -05:00
|
|
|
}
|
|
|
|
return err
|
|
|
|
}
|