Merge pull request #7683 from afbjorklund/docker-pull
Only show pulling base image when actually pullingpull/7702/head
commit
786b78f390
|
@ -79,19 +79,23 @@ func DigestByGoLib(imgName string) string {
|
|||
return cf.Hex
|
||||
}
|
||||
|
||||
// WriteImageToDaemon write img to the local docker daemon
|
||||
func WriteImageToDaemon(img string) error {
|
||||
glog.Infof("Writing %s to local daemon", img)
|
||||
|
||||
// ExistsImageInDaemon if img exist in local docker daemon
|
||||
func ExistsImageInDaemon(img string) bool {
|
||||
// Check if image exists locally
|
||||
cmd := exec.Command("docker", "images", "--format", "{{.Repository}}:{{.Tag}}@{{.Digest}}")
|
||||
if output, err := cmd.Output(); err == nil {
|
||||
if strings.Contains(string(output), img) {
|
||||
glog.Infof("Found %s in local docker daemon, skipping pull", img)
|
||||
return nil
|
||||
return true
|
||||
}
|
||||
}
|
||||
// Else, pull it
|
||||
return false
|
||||
}
|
||||
|
||||
// WriteImageToDaemon write img to the local docker daemon
|
||||
func WriteImageToDaemon(img string) error {
|
||||
glog.Infof("Writing %s to local daemon", img)
|
||||
ref, err := name.ParseReference(img)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "parsing reference")
|
||||
|
|
|
@ -100,12 +100,14 @@ func doCacheBinaries(k8sVersion string) error {
|
|||
|
||||
// BeginDownloadKicArtifacts downloads the kic image + preload tarball, returns true if preload is available
|
||||
func beginDownloadKicArtifacts(g *errgroup.Group) {
|
||||
out.T(out.Pulling, "Pulling base image ...")
|
||||
glog.Info("Beginning downloading kic artifacts")
|
||||
g.Go(func() error {
|
||||
glog.Infof("Downloading %s to local daemon", kic.BaseImage)
|
||||
return image.WriteImageToDaemon(kic.BaseImage)
|
||||
})
|
||||
if !image.ExistsImageInDaemon(kic.BaseImage) {
|
||||
out.T(out.Pulling, "Pulling base image ...")
|
||||
g.Go(func() error {
|
||||
glog.Infof("Downloading %s to local daemon", kic.BaseImage)
|
||||
return image.WriteImageToDaemon(kic.BaseImage)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// WaitDownloadKicArtifacts blocks until the required artifacts for KIC are downloaded.
|
||||
|
|
Loading…
Reference in New Issue