-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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 to parse containerImage to get version #403
Fix to parse containerImage to get version #403
Conversation
Current coverage is
|
@@ -347,10 +347,19 @@ export default class DeployFromSettingsController { | |||
*/ | |||
getContainerImageVersion_() { | |||
/** @type {number} */ | |||
let index = (this.containerImage || '').lastIndexOf(':'); | |||
let index = (this.containerImage || '').lastIndexOf('/'); |
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.
You know what...? I think we'll never be fully correct when doing manual URI parsing. Can we maybe use library https://github.com/derek-watson/jsUri to do the URI parsing for us? You can include the library in bower and use it straight away.
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.
Or am I wrong? Can you convince me and other code readers that this algorithm works?
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.
Second test actually shows that even if version is provided in the link it will be parsed as empty string, so potential version information is lost. Moreover checking only for :
or /
or some other char will be measured only for certains cases and not fully generic.
This library is a good idea and I'd go with that.
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.
In our case there is special semantic attached to the URI. From my experience, parsers are often designed for simple http urls and are buggy for other use cases. But, we should give it a try and use this library. In any case I would be most convinced by explicit test cases. The tests in this PR are very nice, but not comprehensive to cover every possible URI
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.
Yes, can we have more test cases for this feature?
Okay, |
Awesome. Just comment when you're ready for rereview. |
I checked jsUri and docker command. 'Container image' can be set with the following value: REGISTRY can be omitted and NAME can contain '/' as delimiters for namespace. ex)
We can get 1 by parsing path
We can get 1 by parsing path. But host property is not corrected.
In this case, we need to use existing way. TAG cannot contain ':' and '/'. So it is no problem to get last '/'. cf) https://github.com/docker/docker/blob/master/image/spec/v1.md What do you think? |
I would suggest to move the uri-logic to its own class, something like dockeruri.js Add meaningful methods in context of docker. If you use a library for parsing is an implementation detail, then. |
Yeah, I like what Christoph said. Move the parsing logic to a separate file and do not use the library. In your code add implementation comments that explain why the code is correct (i.e., the way you explained this to us now). Add a few more tests and let's submit this. Review status: 0 of 2 files reviewed at latest revision, all discussions resolved. Comments from the review on Reviewable.io |
PTAL I moved logic to separate file. If you have suitable name, please tell me. |
In my environment, 'gulp format' changes many files. (Now I modified format manually..) For example)
It seems to be affected by other setting. My environment:
Where should I check? |
There may be a new formatter release. If yes, I'll quickly fix this. Review status: 0 of 4 files reviewed at latest revision, all discussions resolved. Comments from the review on Reviewable.io |
The above problem was solved. PTAL |
A few style comments and let's merge :) Review status: 0 of 4 files reviewed at latest revision, 5 unresolved discussions. src/app/frontend/common/docker/dockerimagereference.js, line 22 [r4] (raw file): src/app/frontend/common/docker/dockerimagereference.js, line 32 [r4] (raw file): src/app/frontend/common/docker/dockerimagereference.js, line 38 [r4] (raw file): src/test/frontend/common/docker/dockerimagereference_test.js, line 17 [r4] (raw file): src/test/frontend/common/docker/dockerimagereference_test.js, line 65 [r4] (raw file): Comments from the review on Reviewable.io |
I fixed it. PTAL |
Last comment PTAL. Then we can merge :) Reviewed 1 of 2 files at r1, 1 of 3 files at r2, 1 of 2 files at r5. src/app/frontend/common/docker/dockerimagereference.js, line 32 [r4] (raw file):
PTAL :) Comments from the review on Reviewable.io |
I added @type information. Review status: 3 of 4 files reviewed at latest revision, 1 unresolved discussion. src/app/frontend/common/docker/dockerimagereference.js, line 32 [r4] (raw file): Comments from the review on Reviewable.io |
I found one issue.
Is the issue fixed in this pull request? What do you think? |
I say merge this and solve the problem in a new pull request. |
Reviewed 1 of 1 files at r6. Comments from the review on Reviewable.io |
Review status: all files reviewed at latest revision, all discussions resolved, all commit checks successful. Comments from the review on Reviewable.io |
…image Fix to parse containerImage to get version
When I use private.registry:5000/nginx for container image, version label is set '5000/nginx' and it has error.
Fixed it.