Skip to content
This repository has been archived by the owner on Dec 7, 2023. It is now read-only.

Commit

Permalink
Merge pull request #564 from darkowlzz/docker-image-import-fix
Browse files Browse the repository at this point in the history
Fix image import with runtime docker
  • Loading branch information
stealthybox authored Mar 23, 2020
2 parents 648e74a + 52056d3 commit 159d172
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
30 changes: 30 additions & 0 deletions e2e/image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,33 @@ func TestImportTinyImage(t *testing.T) {
importImgOut, importImgErr := importImgCmd.CombinedOutput()
assert.Check(t, importImgErr, fmt.Sprintf("image import: \n%q\n%s", importImgCmd.Args, importImgOut))
}

func TestDockerImportImage(t *testing.T) {
assert.Assert(t, e2eHome != "", "IGNITE_E2E_HOME should be set")

testImage := "hello-world:latest"
// Remove if the image already exists.
rmvImgCmd := exec.Command(
igniteBin,
"image", "rm", testImage,
)
// Ignore error if the image doesn't exists.
_, _ = rmvImgCmd.CombinedOutput()

// Remove image from docker image store if already exists.
rmvDockerImgCmd := exec.Command(
"docker",
"rmi", testImage,
)
// Ignore error if the image doesn't exists.
_, _ = rmvDockerImgCmd.CombinedOutput()

// Import the image.
importImgCmd := exec.Command(
igniteBin,
"--runtime=docker",
"image", "import", testImage,
)
importImgOut, importImgErr := importImgCmd.CombinedOutput()
assert.Check(t, importImgErr, fmt.Sprintf("image import: \n%q\n%s", importImgCmd.Args, importImgOut))
}
2 changes: 1 addition & 1 deletion pkg/runtime/docker/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (dc *dockerClient) PullImage(image meta.OCIImageRef) (err error) {
var rc io.ReadCloser
if rc, err = dc.client.ImagePull(context.Background(), image.Normalized(), types.ImagePullOptions{}); err == nil {
// Don't output the pull command
util.DeferErr(&err, rc.Close)
defer util.DeferErr(&err, rc.Close)
_, err = io.Copy(ioutil.Discard, rc)
}

Expand Down

0 comments on commit 159d172

Please sign in to comment.