diff --git a/pkg/skaffold/runner/runner.go b/pkg/skaffold/runner/runner.go index 11d187222b0..913cd725705 100644 --- a/pkg/skaffold/runner/runner.go +++ b/pkg/skaffold/runner/runner.go @@ -293,34 +293,53 @@ func (r *SkaffoldRunner) Run(ctx context.Context, out io.Writer, artifacts []*la return nil } +type tagErr struct { + tag string + err error +} + // imageTags generates tags for a list of artifacts func (r *SkaffoldRunner) imageTags(ctx context.Context, out io.Writer, artifacts []*latest.Artifact) (tag.ImageTags, error) { start := time.Now() color.Default.Fprintln(out, "Generating tags...") - tags := make(tag.ImageTags, len(artifacts)) + tagErrs := make([]chan tagErr, len(artifacts)) + + for i := range artifacts { + tagErrs[i] = make(chan tagErr, 1) + + i := i + go func() { + tag, err := r.Tagger.GenerateFullyQualifiedImageName(artifacts[i].Workspace, artifacts[i].ImageName) + tagErrs[i] <- tagErr{tag: tag, err: err} + }() + } + + imageTags := make(tag.ImageTags, len(artifacts)) + + for i, artifact := range artifacts { + imageName := artifact.ImageName + color.Default.Fprintf(out, " - %s -> ", imageName) - for _, artifact := range artifacts { select { case <-ctx.Done(): return nil, context.Canceled - default: - imageName := artifact.ImageName - color.Default.Fprintf(out, " - %s -> ", imageName) - tag, err := r.Tagger.GenerateFullyQualifiedImageName(artifact.Workspace, imageName) + case tagErr := <-tagErrs[i]: + tag := tagErr.tag + err := tagErr.err if err != nil { return nil, errors.Wrapf(err, "generating tag for %s", imageName) } fmt.Fprintln(out, tag) - tags[imageName] = tag + imageTags[imageName] = tag } } color.Default.Fprintln(out, "Tags generated in", time.Since(start)) - return tags, nil + return imageTags, nil } // BuildAndTest builds artifacts and runs tests on built artifacts