Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ko): Display correct tag for sideloaded images #6836

Conversation

halvards
Copy link
Contributor

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

@halvards halvards requested a review from a team as a code owner November 11, 2021 14:05
@google-cla google-cla bot added the cla: yes label Nov 11, 2021
@halvards halvards marked this pull request as draft November 11, 2021 14:08
Display the expected tag after successfully building a ko image, for
both sideloaded and published images.

Also handles the `tagPolicy.sha256` scenarios.

Fixes: GoogleContainerTools#6835
Tracking: GoogleContainerTools#6041
@codecov
Copy link

codecov bot commented Nov 11, 2021

Codecov Report

Merging #6836 (8033e5a) into main (290280e) will decrease coverage by 1.34%.
The diff coverage is 64.65%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #6836      +/-   ##
==========================================
- Coverage   70.48%   69.14%   -1.35%     
==========================================
  Files         515      547      +32     
  Lines       23150    25036    +1886     
==========================================
+ Hits        16317    17310     +993     
- Misses       5776     6563     +787     
- Partials     1057     1163     +106     
Impacted Files Coverage Δ
cmd/skaffold/app/cmd/deploy.go 52.00% <ø> (-1.85%) ⬇️
cmd/skaffold/app/cmd/dev.go 84.61% <0.00%> (ø)
cmd/skaffold/app/cmd/flags.go 91.00% <0.00%> (+0.18%) ⬆️
cmd/skaffold/app/cmd/render.go 36.66% <0.00%> (-4.72%) ⬇️
cmd/skaffold/skaffold.go 0.00% <0.00%> (ø)
cmd/skaffold/app/cmd/inspect_tests.go 62.50% <14.28%> (-1.14%) ⬇️
cmd/skaffold/app/cmd/lint.go 42.85% <42.85%> (ø)
cmd/skaffold/app/cmd/find_configs.go 48.88% <50.00%> (+0.24%) ⬆️
cmd/skaffold/app/skaffold.go 76.19% <70.00%> (-8.43%) ⬇️
cmd/skaffold/app/cmd/inspect_build_env.go 65.11% <75.00%> (+6.39%) ⬆️
... and 162 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a9d7152...8033e5a. Read the comment docs.

@halvards halvards marked this pull request as ready for review November 11, 2021 14:39
@halvards halvards added the kokoro:run runs the kokoro jobs on a PR label Nov 11, 2021
@halvards halvards changed the title fix(ko): Display correct tag fix(ko): Display correct tag for sideloaded images Nov 11, 2021
@kokoro-team kokoro-team removed the kokoro:run runs the kokoro jobs on a PR label Nov 11, 2021
fmt.Fprintln(out, imageRef.Name())

outputRef := ref
if strings.HasSuffix(ref, ":latest") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So does Ko only do use the digest for :latest?

@halvards halvards marked this pull request as draft November 25, 2021 10:38
@halvards
Copy link
Contributor Author

halvards commented Nov 25, 2021

Marking as draft until I have time to get back to this one. I think some tweaks may be needed.

halvards added a commit to halvards/skaffold that referenced this pull request Dec 3, 2021
With this change, the `ko` builder no longer prints the image name to
`stdout` by default.

Originally, this was added to the `ko` builder to mimic the behavior of
the `ko` CLI. Other Skaffold image builders do not print the image name
in this way.

The reason this is useful for existing `ko` CLI users is that some
documented workflows rely on capturing the image name from `stdout`, see
https://github.com/google/ko/blob/v0.9.3/README.md#build-an-image

After some investigation, the better option seems to be to rely on the
existing `--quiet` and `--output` Skaffold flags to format the output of
the image name(s).

This change also updates the `ko` builder documentation to show existing
`ko` CLI users how to capture the image name by providing an appropriate
Go template to `--output`.

Fixes: GoogleContainerTools#6835
Closes: GoogleContainerTools#6836
Tracking: GoogleContainerTools#6041
halvards added a commit to halvards/skaffold that referenced this pull request Dec 3, 2021
With this change, the `ko` builder no longer prints the image name to
`stdout` by default.

Originally, this was added to the `ko` builder to mimic the behavior of
the `ko` CLI. Other Skaffold image builders do not print the image name
in this way.

The reason this is useful for existing `ko` CLI users is that some
documented workflows rely on capturing the image name from `stdout`, see
https://github.com/google/ko/blob/v0.9.3/README.md#build-an-image

After some investigation, the better option seems to be to rely on the
existing `--quiet` and `--output` Skaffold flags to format the output of
the image name(s).

This change also updates the `ko` builder documentation to show existing
`ko` CLI users how to capture the image name by providing an appropriate
Go template to `--output`.

Fixes: GoogleContainerTools#6835
Closes: GoogleContainerTools#6836
Tracking: GoogleContainerTools#6041
@halvards
Copy link
Contributor Author

halvards commented Dec 6, 2021

Closing in favor of #6928

@halvards halvards closed this Dec 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ko builder sideload displays both correct and incorrect tag when using default tag policy
3 participants