Merge pull request #7683 from afbjorklund/docker-pull

Only show pulling base image when actually pulling
pull/7702/head
Medya Ghazizadeh 2020-04-15 15:13:27 -07:00 committed by GitHub
commit 786b78f390
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 10 deletions

View File

@ -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")

View File

@ -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.