mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-21 10:09:07 +00:00
Merge pull request #12 from riyazdf/img-not-found-err
Use IsErrNotFound to tighten err handling
This commit is contained in:
commit
0b149e7c83
@ -9,6 +9,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
log "github.com/Sirupsen/logrus"
|
log "github.com/Sirupsen/logrus"
|
||||||
|
"github.com/docker/docker/client"
|
||||||
)
|
)
|
||||||
|
|
||||||
// This uses Docker to convert a Docker image into a tarball. It would be an improvement if we
|
// This uses Docker to convert a Docker image into a tarball. It would be an improvement if we
|
||||||
@ -102,16 +103,20 @@ func imageTar(image, prefix string, tw *tar.Writer, trust bool, pull bool) error
|
|||||||
}
|
}
|
||||||
container, err := dockerCreate(image)
|
container, err := dockerCreate(image)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// most likely we need to pull the image if this failed
|
// if the image wasn't found, pull it down. Bail on other errors.
|
||||||
log.Infof("Pull image: %s", image)
|
if client.IsErrNotFound(err) {
|
||||||
err := dockerPull(image, trust)
|
log.Infof("Pull image: %s", image)
|
||||||
if err != nil {
|
err := dockerPull(image, trust)
|
||||||
return fmt.Errorf("Could not pull image %s: %v", image, err)
|
if err != nil {
|
||||||
}
|
return fmt.Errorf("Could not pull image %s: %v", image, err)
|
||||||
container, err = dockerCreate(image)
|
}
|
||||||
if err != nil {
|
container, err = dockerCreate(image)
|
||||||
return fmt.Errorf("Failed to docker create image %s: %v", image, err)
|
if err != nil {
|
||||||
|
return fmt.Errorf("Failed to docker create image %s: %v", image, err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return fmt.Errorf("Failed to create docker image %s: %v", image, err)
|
||||||
|
|
||||||
}
|
}
|
||||||
contents, err := dockerExport(container)
|
contents, err := dockerExport(container)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user