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

ko apply doesn't error out when import path is incorrect #10

Closed
dprotaso opened this issue May 30, 2018 · 9 comments
Closed

ko apply doesn't error out when import path is incorrect #10

dprotaso opened this issue May 30, 2018 · 9 comments

Comments

@dprotaso
Copy link
Contributor

I mistyped a package name when specifying my container image. This caused ko to apply a yaml configuration with an non-existent image.

It would be nice if ko checked if the images I'm applying exist in my image registry and error out if they do not.

@jonjohnsonjr
Copy link
Collaborator

What do you mean by "exist in my image registry"? Most of the time I would think those images don't exist in your registry until you run ko apply, no?

@imjasonh
Copy link
Member

It sounds like the issue is that if my YAML includes something like:

image: gihtub.com/user/repo/cmd/foo  # <-- typo!

Then ko resolve will not build an image for that incorrect importpath, and instead will pass it through to the resolved output, where the image will fail to be pulled, because it doesn't exist.

@dprotaso is that an accurate rephrasing of the issue?

@dprotaso
Copy link
Contributor Author

dprotaso commented May 31, 2018 via email

@mattmoor
Copy link
Collaborator

tl;dr I'm certainly open to suggestions, but I'm unsure of how to robustly handle this.

There is certainly an angle here where we could introduce schema-sensitivity and special cases certain common patterns (e.g. .spec.image), but there are other patterns it would miss (e.g. sidecar images passed by flags).

One interesting case would be: what if I'm using ko apply -f foo.yaml, but the image: ... of foo.yaml is a pre-published image (NOT an import path)? Perhaps ko is a nop for this resource, or perhaps it is an instance of the latter example above (the image reference is a flag).

My guiding principle with ko has been to bias towards go idioms, but I'm not sure the go tool's DevX is much better (it would fail on a dependency not found, as we're failing on a container not found).

Does that make sense? WDYT?

@jonjohnsonjr
Copy link
Collaborator

This would complicate things, but we could log a warning if the edit distance of an image: string is <= 2 away from something in $GOPATH/src but skipped by ko?

We could also just do:
log.Printf("Skipping %q because no match found under %q", imageRef, src)

If you're using a pre-published image, no harm in logging that. If you expect ko to publish everything, you might see that?

Maybe even a --strict flag?

I went back and forth with dgageot on something similar... maybe we could adopt skaffold's strategy? Anything with an explicit tag/digest is expected to be skipped, but importpaths would not have those, so we could error on any reference with an implicit identifier that isn't ko-buildable. See some discussion in GoogleContainerTools/skaffold#565.

@jonjohnsonjr jonjohnsonjr transferred this issue from google/go-containerregistry Mar 21, 2019
@jonjohnsonjr
Copy link
Collaborator

Fixed by #58

@vickynarang01
Copy link

I am getting an error on firing this command: ko resolve -f deployment.yaml
Screenshot 2021-09-03 at 1 46 44 PM

Attached a deployment yaml here for reference and the output of the command.
Screenshot 2021-09-03 at 1 51 15 PM

Error: error processing import paths in "deployment.yaml": error resolving image references: found strict reference but ko://github.com/vickynarang01/helloworld is not a valid import path: no required module provides package github.com/vickynarang01/helloworld; to add it:

Don't understand what's wrong here

@imjasonh
Copy link
Member

imjasonh commented Sep 3, 2021

There are a few things that could cause this:

  • Is the repo checked out in your $GOPATH?
  • I see the repo isn't using go modules, running go mod init github.com/vickynarang01/helloworld then ko resolve again should help.

@vickynarang01
Copy link

Thanks a tonne @imjasonh this issue is now resolved I have checked this into a new repository - https://github.com/vickynarang01/go-ko

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants