Use go-containerregistry library instead of docker CLI
parent
0033381049
commit
173666d203
|
@ -34,6 +34,7 @@ import (
|
|||
v1 "github.com/google/go-containerregistry/pkg/v1"
|
||||
"github.com/google/go-containerregistry/pkg/v1/daemon"
|
||||
"github.com/google/go-containerregistry/pkg/v1/remote"
|
||||
"github.com/google/go-containerregistry/pkg/v1/tarball"
|
||||
"github.com/pkg/errors"
|
||||
"k8s.io/minikube/pkg/minikube/constants"
|
||||
"k8s.io/minikube/pkg/minikube/localpath"
|
||||
|
@ -100,11 +101,18 @@ func LoadFromTarball(img string) error {
|
|||
p := filepath.Join(constants.ImageCacheDir, img)
|
||||
p = localpath.SanitizeCacheDir(p)
|
||||
|
||||
cmd := exec.Command("docker", "load", "-i", p)
|
||||
if output, err := cmd.CombinedOutput(); err != nil {
|
||||
return errors.Wrapf(err, "%s", string(output))
|
||||
tag, err := name.NewTag(Tag(img))
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "new tag")
|
||||
}
|
||||
return nil
|
||||
|
||||
i, err := tarball.ImageFromPath(p, &tag)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "tarball")
|
||||
}
|
||||
|
||||
_, err = daemon.Write(tag, i)
|
||||
return err
|
||||
}
|
||||
|
||||
// Tag returns just the image with the tag
|
||||
|
|
|
@ -128,10 +128,10 @@ func beginDownloadKicBaseImage(g *errgroup.Group, cc *config.ClusterConfig, down
|
|||
for _, img := range append([]string{cc.KicBaseImage}, kic.FallbackImages...) {
|
||||
if err := image.LoadFromTarball(img); err == nil {
|
||||
glog.Infof("successfully loaded %s from cached tarball", img)
|
||||
finalImg = img
|
||||
// strip the digest from the img before saving it in the config
|
||||
// because loading an image from tarball to daemon doesn't load the digest
|
||||
finalImg = image.Tag(img)
|
||||
return nil
|
||||
} else {
|
||||
fmt.Println("Failed to load tarball:", err)
|
||||
}
|
||||
glog.Infof("Downloading %s to local daemon", img)
|
||||
err := image.WriteImageToDaemon(img)
|
||||
|
|
Loading…
Reference in New Issue