Skip to content

Commit 92ddd47

Browse files
committed
kicbase: simplify the image loading logic
This change refactors beginDownloadKicBaseImage() a bit to achieve a more streamlined flow of logic, combining redundant blocks. In the special case of podman, it leaves image loading from cache loading from cache unimplemented and removes the confusing and unhelpful message. Signed-off-by: Michael Adam <obnox@samba.org>
1 parent 6d351f1 commit 92ddd47

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

pkg/minikube/node/cache.go

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,10 @@ func beginDownloadKicBaseImage(g *errgroup.Group, cc *config.ClusterConfig, down
135135
register.Reg.SetStep(register.PullingBaseImage)
136136
out.Step(style.Pulling, "Pulling base image {{.kicVersion}} ...", out.V{"kicVersion": kic.Version})
137137
g.Go(func() error {
138+
if cc.Driver == driver.Podman {
139+
klog.Infof("skipping load for podman driver: letting podman download.")
140+
return nil
141+
}
138142
baseImg := cc.KicBaseImage
139143
if baseImg == kic.BaseImage && len(cc.KubernetesConfig.ImageRepository) != 0 {
140144
baseImg = updateKicImageRepo(baseImg, cc.KubernetesConfig.ImageRepository)
@@ -154,25 +158,22 @@ func beginDownloadKicBaseImage(g *errgroup.Group, cc *config.ClusterConfig, down
154158
var err error
155159
for _, img := range append([]string{baseImg}, kic.FallbackImages...) {
156160

157-
if driver.IsDocker(cc.Driver) && download.ImageExistsInDaemon(img) && !downloadOnly {
158-
klog.Infof("%s exists in daemon, skipping load", img)
159-
finalImg = img
160-
return nil
161-
}
161+
if driver.IsDocker(cc.Driver) {
162+
if download.ImageExistsInDaemon(img) {
163+
klog.Infof("%s exists in daemon, skipping load", img)
164+
finalImg = img
165+
return nil
166+
}
162167

163-
klog.Infof("Downloading %s to local cache", img)
164-
err = download.ImageToCache(img)
165-
if err == nil {
166-
klog.Infof("successfully saved %s as a tarball", img)
167-
}
168-
if downloadOnly && err == nil {
169-
return nil
170-
}
168+
klog.Infof("Downloading %s to local cache", img)
169+
err = download.ImageToCache(img)
170+
if err == nil {
171+
klog.Infof("successfully saved %s as a tarball", img)
172+
}
173+
if downloadOnly {
174+
return nil
175+
}
171176

172-
if cc.Driver == driver.Podman {
173-
return fmt.Errorf("not yet implemented, see issue #8426")
174-
}
175-
if driver.IsDocker(cc.Driver) && err == nil {
176177
klog.Infof("Loading %s from local cache", img)
177178
if finalImg, err = download.CacheToDaemon(img); err == nil {
178179
klog.Infof("successfully loaded and using %s from cached tarball", img)

0 commit comments

Comments
 (0)