Skip to content

Commit 7662c08

Browse files
committed
Allow loading more than one image at a time
They need to all be cached or all be local, though. If one appears to be local, then assume that all are.
1 parent 26a5f98 commit 7662c08

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

cmd/minikube/cmd/image.go

+18-13
Original file line numberDiff line numberDiff line change
@@ -55,34 +55,39 @@ var loadImageCmd = &cobra.Command{
5555
if err != nil {
5656
exit.Error(reason.Usage, "loading profile", err)
5757
}
58-
img := args[0]
5958

6059
var local bool
6160
if imgRemote || imgDaemon {
6261
local = false
63-
} else if strings.HasPrefix(img, "/") || strings.HasPrefix(img, ".") {
64-
local = true
65-
imgDaemon = false
66-
imgRemote = false
67-
} else if _, err := os.Stat(img); err == nil {
68-
local = true
69-
imgDaemon = false
70-
imgRemote = false
7162
} else {
72-
imgDaemon = true
73-
imgRemote = true
63+
for _, img := range args {
64+
if strings.HasPrefix(img, "/") || strings.HasPrefix(img, ".") {
65+
local = true
66+
imgDaemon = false
67+
imgRemote = false
68+
} else if _, err := os.Stat(img); err == nil {
69+
local = true
70+
imgDaemon = false
71+
imgRemote = false
72+
}
73+
}
74+
75+
if !local {
76+
imgDaemon = true
77+
imgRemote = true
78+
}
7479
}
7580

7681
// Currently "image.retrieveImage" always tries to load both from daemon and from remote
7782
// There is no way to skip daemon.Image or remote.Image, for the vague "ref" string given.
7883
if imgDaemon || imgRemote {
79-
if err := machine.CacheAndLoadImages([]string{img}, []*config.Profile{profile}); err != nil {
84+
if err := machine.CacheAndLoadImages(args, []*config.Profile{profile}); err != nil {
8085
exit.Error(reason.GuestImageLoad, "Failed to load image", err)
8186
}
8287
// Load images from local files, without doing any caching or checks in container runtime
8388
// This is similar to tarball.Image but it is done by the container runtime in the cluster.
8489
} else if local {
85-
if err := machine.DoLoadImages([]string{img}, []*config.Profile{profile}, ""); err != nil {
90+
if err := machine.DoLoadImages(args, []*config.Profile{profile}, ""); err != nil {
8691
exit.Error(reason.GuestImageLoad, "Failed to load image", err)
8792
}
8893
}

0 commit comments

Comments
 (0)