Skip to content

Commit

Permalink
Adds docker-agnostic image pull logic
Browse files Browse the repository at this point in the history
This a simpler version of the ImageToDaemon;
here the docker save/load logic is thrown away since its already carried
inside the previous calls to ImageToMinikubeCache and CacheToKicdriver.
This function's only concern is to pull the specified image from
remote thus using the proper digest.
  • Loading branch information
x7upLime committed Dec 6, 2022
1 parent 132c8e1 commit 0ed0966
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions pkg/minikube/download/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,43 @@ func CacheToDaemon(img string) error {
return err
}

// ImageToKicDriver
// Makes a direct pull of the specified image to the kicdriver's cache
// maintaining reference to the image digest.
func ImageToKicDriver(ociBin, img string) error {
_, ref, err := parseImage(img)
if err != nil {
return err
}

fileLock := filepath.Join(detect.KICCacheDir(), path.Base(img)+".d.lock")
fileLock = localpath.SanitizeCacheDir(fileLock)
releaser, err := lockDownload(fileLock)
if releaser != nil {
defer releaser.Release()
}
if err != nil {
return err
}

if ImageExistsInKicDriver(ociBin, img) {
klog.Infof("%s exists in KicDriver, skipping pull", img)
return nil
}


if DownloadMock != nil {
klog.Infof("Mock download: %s -> daemon", img)
return DownloadMock(img, "daemon")
}

klog.V(3).Infof("Pulling image %v", ref)
if _, err := oci.PullImage(ociBin, img); err != nil {
return errors.Wrap(err, "pulling remote image")
}
return nil
}

// ImageToDaemon downloads img (if not present in daemon) and writes it to the local docker daemon
func ImageToDaemon(img string) error {
fileLock := filepath.Join(detect.KICCacheDir(), path.Base(img)+".d.lock")
Expand Down

0 comments on commit 0ed0966

Please sign in to comment.