2015-11-03 20:19:18 -05:00
|
|
|
package daemon
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
derr "github.com/docker/docker/errors"
|
2015-12-04 16:55:15 -05:00
|
|
|
"github.com/docker/docker/reference"
|
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-12-04 16:55:15 -05:00
|
|
|
tag := reference.DefaultTag
|
2015-11-18 17:20:54 -05:00
|
|
|
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-12-04 16:55:15 -05:00
|
|
|
if tagged, isTagged := ref.(reference.NamedTagged); isTagged {
|
2015-11-18 17:20:54 -05:00
|
|
|
tag = tagged.Tag()
|
|
|
|
}
|
|
|
|
return derr.ErrorCodeNoSuchImageTag.WithArgs(ref.Name(), tag)
|
2015-11-03 20:19:18 -05:00
|
|
|
}
|
|
|
|
return err
|
|
|
|
}
|