Skip to content

Commit

Permalink
Refactors for more noticeable distinction minikube/driver cache
Browse files Browse the repository at this point in the history
  • Loading branch information
x7upLime committed Dec 9, 2022
1 parent e7b3a54 commit 5886e74
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions pkg/minikube/download/download_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func testImageToCache(t *testing.T) {
downloadNum := 0
DownloadMock = mockSleepDownload(&downloadNum)

checkImageExistsInCache = func(img string) bool { return downloadNum > 0 }
checkImageExistsInMinikubeCache = func(img string) bool { return downloadNum > 0 }

var group sync.WaitGroup
group.Add(2)
Expand All @@ -188,7 +188,7 @@ func testImageToDaemon(t *testing.T) {
downloadNum := 0
DownloadMock = mockSleepDownload(&downloadNum)

checkImageExistsInCache = func(img string) bool { return downloadNum > 0 }
checkImageExistsInMinikubeCache = func(img string) bool { return downloadNum > 0 }

var group sync.WaitGroup
group.Add(2)
Expand Down
18 changes: 9 additions & 9 deletions pkg/minikube/download/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,23 +50,23 @@ func imagePathInMinikubeCache(img string) string {
return f
}

// ImageExistsInCache if img exist in local cache directory
func ImageExistsInCache(img string) bool {
// ImageExistsInCache if img exist in local minikube cache directory
func ImageExistsInMinikubeCache(img string) bool {
f := imagePathInMinikubeCache(img)

// Check if image exists locally
klog.Infof("Checking for %s in local cache directory", img)
klog.Infof("Checking for %s in local minikube cache directory", img)
if st, err := os.Stat(f); err == nil {
if st.Size() > 0 {
klog.Infof("Found %s in local cache directory, skipping pull", img)
klog.Infof("Found %s in local minikube cache directory, skipping pull", img)
return true
}
}
// Else, pull it
return false
}

var checkImageExistsInCache = ImageExistsInCache
var checkImageExistsInMinikubeCache = ImageExistsInMinikubeCache

// ImageExistsInKICDriver
// checks for the specified image in the container engine's local cache
Expand Down Expand Up @@ -103,13 +103,13 @@ func ImageToMinikubeCache(img string) error {
return err
}

if checkImageExistsInCache(img) {
klog.Infof("%s exists in cache, skipping pull", img)
if checkImageExistsInMinikubeCache(img) {
klog.Infof("%s exists in minikube cache, skipping pull", img)
return nil
}

if err := os.MkdirAll(filepath.Dir(f), 0777); err != nil {
return errors.Wrapf(err, "making cache image directory: %s", f)
return errors.Wrapf(err, "making minikube cache image directory: %s", f)
}

if DownloadMock != nil {
Expand All @@ -120,7 +120,7 @@ func ImageToMinikubeCache(img string) error {
// buffered channel
c := make(chan v1.Update, 200)

klog.Infof("Writing %s to local cache", img)
klog.Infof("Writing %s to local minikube cache", img)
klog.V(3).Infof("Getting image %v", ref)
i, err := remote.Image(ref, remote.WithPlatform(defaultPlatform))
if err != nil {
Expand Down

0 comments on commit 5886e74

Please sign in to comment.