fix kicbase cache check

pull/11603/head
Ilya Zuyev 2021-06-07 16:37:04 -07:00
parent 04a1d1f69d
commit 557d3a5504
1 changed files with 21 additions and 4 deletions

View File

@ -168,17 +168,34 @@ func ImageToCache(img string) error {
}
}
func parseImage(img string) (*name.Tag, name.Reference, error) {
digest, err := name.NewDigest(img)
if err == nil {
tag := digest.Tag()
return &tag, digest, nil
}
_, ok := err.(*name.ErrBadName)
if !ok {
return nil, nil, errors.Wrap(err, "new ref")
}
tag, err := name.NewTag(img)
if err != nil {
return nil, nil, errors.Wrap(err, "new ref")
}
return &tag, tag, nil
}
// CacheToDaemon loads image from tarball in the local cache directory to the local docker daemon
func CacheToDaemon(img string) error {
p := imagePathInCache(img)
ref, err := name.NewDigest(img)
tag, ref, err := parseImage(img)
if err != nil {
return errors.Wrap(err, "new ref")
return nil
}
tag := ref.Tag()
i, err := tarball.ImageFromPath(p, &tag)
i, err := tarball.ImageFromPath(p, tag)
if err != nil {
return errors.Wrap(err, "tarball")
}