-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Issue 7555 - fixed importimage #7581
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
Conversation
pkg/cmd/cli/cmd/importimage.go
Outdated
| // TODO soltysh: what about the case where specs are only on tags? | ||
| if len(stream.Spec.DockerImageRepository) == 0 { | ||
| return fmt.Errorf("flag --all is applicable only to images with .spec.dockerImageRepository defined") | ||
| } else { |
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.
drop else
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.
Right.
|
|
||
| if all { | ||
| // importing a whole repository | ||
| // TODO soltysh: write tests to cover all the possible usecases!!! |
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.
Add a test now that covers the old behavior and new.
|
@smarterclayton I've addressed the dot comment. I don't feel comfortable with import image not being tested at all, so I agree with your comment. I'll work on creating extensive tests of the ImageStreamImport created in imageimport.go as a followup if you don't mind. |
|
Even a test-cmd test would be fine now. I'd be happy with 2 or 3 more "import-image" commands added to images.sh |
|
@smarterclayton I've reworked the image-import command to follow Complete-Validate-Run scheme and split it into testable chunks (commit 1). The bugfix and tests are in 2nd commit. ptal |
|
[test] |
|
Fixed gofmt problem. |
|
One clean run, one flake filled new one for that. @smarterclayton still waiting your signoff. |
|
Will review on Monday
|
pkg/cmd/cli/cmd/importimage.go
Outdated
| Run: func(cmd *cobra.Command, args []string) { | ||
| err := RunImportImage(f, out, cmd, args) | ||
| kcmdutil.CheckErr(err) | ||
| if err := opts.Complete(f, args, out); err != nil { |
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.
Don't force these to be usage errors, return usage errors and call CheckErr directly.
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.
Right, Complete doesn't deal with usage errors here, the only ones there are from getting default namespace or clients.
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.
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.
I see, I must have been looking at older commands before this new pattern. Will change.
|
Change looks ok, can we add a few more branch tests to hack/test-cmd.sh |
|
@smarterclayton what kind of tests are you thinking about? |
|
@smarterclayton I've fixed this one issue, I'll be working on the tests both unit and cmd as a followup. I'd like to add |
|
Let's have this one merged if you don't mind. |
|
I'd like additional test-cmd tests here before we merge this that work
before and after.
|
Covers the usecase where an image stream is found and we want to import all tags, without from being passed: Which will generally fail when trying to read image metadata from remote repository. The only use-case where this will work is when your image stream uses the name of the images provided by docker hub (eg. mysql, python, etc.)
Covers the usecase where we import single tag, from existing image stream, but we omit the tag name, assuming default Further more we set above @smarterclayton having said that I'm not sure there was correct behavior before, that I can actually address with tests. I'm ok with adding more tests and I'm currently working on, it but I don't see any before that was actually working, though maybe I'm missing something here. If so please point me to the before usecase you're talking about. edit: updated code links to current commit |
…plit the code so it's testable + added tests.
|
@smarterclayton I've addressed your comment and added more tests, ptal |
…ec for images that failed previous import.
|
Of course I forgot to update tests after changing |
|
It looks like flake from #6077 |
|
@smarterclayton comment addressed |
|
@smarterclayton test with checking no of imported tags. For your question why I've changed from importing |
|
Evaluated for origin test up to 97b0f7f |
|
Lgtm [merge]
|
|
continuous-integration/openshift-jenkins/test FAILURE (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/1754/) |
|
continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/merge_pull_requests_origin/5165/) (Image: devenv-rhel7_3586) |
|
Evaluated for origin merge up to 97b0f7f |
Fixes #7555.
@smarterclayton I've made slight modifications in the image-import command to address problems from the issue. Still there are some others I've marked as TODO for now. ptal