-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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): Default repo for pushing ko://
images
#7010
Conversation
Codecov Report
@@ Coverage Diff @@
## main #7010 +/- ##
==========================================
- Coverage 70.48% 68.79% -1.70%
==========================================
Files 515 554 +39
Lines 23150 25695 +2545
==========================================
+ Hits 16317 17676 +1359
- Misses 5776 6820 +1044
- Partials 1057 1199 +142
Continue to review full report at Codecov.
|
When using the `ko://` scheme prefix for the Skaffold image name, the rest of the image name, following the prefix, is a Go import path. This import path maps to the Git repository (typically), and won't match an image registry name (e.g., `ko://github.com/org/repo` vs `gcr.io/project_id`). With this change, if _all_ of the following are true, the build results in an error that instructs the user to set the default repo: - the image name in `skaffold.yaml` uses the `ko://` prefix; and - the Skaffold default repo is _not_ set; and - the image is being pushed to a registry (rather than sideloaded to a Docker daemon). Fixes: GoogleContainerTools#6933 Tracking: GoogleContainerTools#6041
@@ -37,6 +37,9 @@ import ( | |||
// identifier. The image identifier is the tag or digest for pushed images, or | |||
// the docker image ID for sideloaded images. | |||
func (b *Builder) Build(ctx context.Context, out io.Writer, a *latestV1.Artifact, ref string) (string, error) { | |||
if b.pushImages && strings.HasPrefix(ref, build.StrictScheme) { | |||
return "", fmt.Errorf("default repo must be set when using the 'ko://' prefix and pushing to a registry: %s, see https://skaffold.dev/docs/environment/image-registries/", a.ImageName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: perhaps this information should be on the docs page as well - eg: NOTE: the ko builder requires using the default repo flag as ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @aaron-prindle, good point. I just pushed another commit to update the docs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Document that `ko` builder users who use the `ko://` prefix must set the default repo if pushing images to a registry. Related: GoogleContainerTools#6933 Tracking: GoogleContainerTools#6041
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm. I wonder if in the future it would be better to have this validation be done at the beginning of execution failure sooner for the user
When using the
ko://
scheme prefix for the Skaffold image name, the rest of the image name that follows the prefix, is a Go import path.This import path maps to the Git repository location (typically), and won't match an image registry name (e.g.,
ko://github.com/org/repo
vsgcr.io/project_id
). Currently, the result is a hard-to-understand error resulting from a failed push to the non-existent host calledko
(see #6933).With this change, if all of the following are true, the build results in an error that instructs the user to set the default repo:
skaffold.yaml
uses theko://
prefix; andFixes: #6933
Tracking: #6041