-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moves interactions with kicDriver's bin inside oci driver package
- Loading branch information
Showing
2 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package oci | ||
|
||
import ( | ||
"os/exec" | ||
"strings" | ||
|
||
"k8s.io/minikube/pkg/minikube/image" | ||
) | ||
|
||
// 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 | ||
} | ||
|
||
// IsInCache | ||
// searches in OCIBIN's cache for the IMG; returns true if found. no error handling | ||
func IsImageInCache(ociBin, img string) (bool) { | ||
res, err := runCmd(exec.Command(ociBin, "images", "--format", "{{.Repository}}:{{.Tag}}@{{.Digest}}")) | ||
if err != nil { | ||
// only the docker binary seems to have this issue.. | ||
// the docker.io/ substring is cut from the output and formatting doesn't help | ||
if ociBin == Docker { | ||
img = image.TrimDockerIO(img) | ||
} | ||
|
||
if strings.Contains(res.Stdout.String(), img){ | ||
return true | ||
} | ||
} | ||
|
||
return false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package oci | ||
|
||
import ( | ||
"os/exec" | ||
"bytes" | ||
) | ||
|
||
func PullImage(ociBin, img string) (bytes.Buffer, error) { | ||
res, err := runCmd(exec.Command(ociBin, "pull", "--quiet", img)) | ||
return res.Stdout, err | ||
} |