From b0da432005e3e47b8c889911b74bb1cbe2d73aec Mon Sep 17 00:00:00 2001 From: Halvard Skogsrud Date: Fri, 12 Nov 2021 01:02:22 +1100 Subject: [PATCH] fix(ko): Display correct tag Display the expected tag after successfully building a ko image, for both sideloaded and published images. Also handles the `tagPolicy.sha256` scenarios. Fixes: #6835 Tracking: #6041 --- pkg/skaffold/build/ko/build.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/skaffold/build/ko/build.go b/pkg/skaffold/build/ko/build.go index 7d826d9254f..0ba062347bf 100644 --- a/pkg/skaffold/build/ko/build.go +++ b/pkg/skaffold/build/ko/build.go @@ -52,7 +52,13 @@ func (b *Builder) Build(ctx context.Context, out io.Writer, a *latestV1.Artifact if err != nil { return "", fmt.Errorf("could not build and publish ko image %q: %w", a.ImageName, err) } - fmt.Fprintln(out, imageRef.Name()) + + outputRef := ref + if strings.HasSuffix(ref, ":latest") { + // handle tagPolicy sha256 + outputRef = imageRef.Name() + } + fmt.Fprintln(out, outputRef) return b.getImageIdentifier(ctx, imageRef, ref) }