Skip to content

Commit

Permalink
Adds command output for KicDriver pull/load
Browse files Browse the repository at this point in the history
we only return err, because messages are already carried
by the KicDriver bin itself
  • Loading branch information
x7upLime committed Dec 10, 2022
1 parent 5886e74 commit cbfae92
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
10 changes: 7 additions & 3 deletions pkg/drivers/kic/oci/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package oci

import (
"os"
"os/exec"
"strings"

Expand All @@ -26,9 +27,12 @@ import (
// ToDriverCache
// calls OCIBIN's load command at specified path:
// loads the archived container image at provided PATH.
func ArchiveToDriverCache(ociBin, path string) (string, error) {
_, err := runCmd(exec.Command(ociBin, "load", "-i", path))
return "", err
func ArchiveToDriverCache(ociBin, path string) error {
cmd := exec.Command(ociBin, "load", "-i", path)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
err := cmd.Run()
return err
}

// IsInCache
Expand Down
12 changes: 8 additions & 4 deletions pkg/drivers/kic/oci/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,15 @@ limitations under the License.
package oci

import (
"bytes"
"os/exec"
"strings"
)

func PullImage(ociBin, img string) (bytes.Buffer, error) {
res, err := runCmd(exec.Command(ociBin, "pull", "--quiet", img))
return res.Stdout, err
func PullImage(ociBin, img string) error {
rr, err := runCmd(exec.Command(ociBin, "pull", "--quiet", img))
if strings.Contains(rr.Stdout.String(), "Loaded image:") {
return nil
}
return err

}
7 changes: 4 additions & 3 deletions pkg/minikube/download/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,7 @@ func parseImage(img string) (*name.Tag, name.Reference, error) {
// loads a locally minikube-cached container image, to the KIC-driver's cache
func CacheToKicDriver(ociBin string, img string) error {
p := imagePathInMinikubeCache(img)
resp, err := oci.ArchiveToDriverCache(ociBin, p)
klog.V(2).Infof("response: %s", resp)
err := oci.ArchiveToDriverCache(ociBin, p)
return err
}

Expand Down Expand Up @@ -230,7 +229,9 @@ func ImageToKicDriver(ociBin, img string) error {
}

klog.V(3).Infof("Pulling image %v", ref)
if _, err := oci.PullImage(ociBin, img); err != nil {
// an image pull for the digest at this point is not a bad thing..
// images are pulled by layers and we already have the biggest part
if err := oci.PullImage(ociBin, img); err != nil {
return errors.Wrap(err, "pulling remote image")
}
return nil
Expand Down

0 comments on commit cbfae92

Please sign in to comment.