Conversation
051951e to
25f4c9d
Compare
|
off-topic: I know CLI is being ripped out (#32694) from moby/moby, but what is the "current" approach to update the CLI code? It seems we need to continue to update moby/moby/cli "for a while", and Docker employees eventually cherry-pick up them into docker/docker-cli? |
|
This unfortunately isn't the first time we've had inconsistencies in how names/IDs are resolved. I'd really like to see us create a package that defines the canonical approach. It could take a set of names and IDs as input, and either match one of them or return an appropriate error. Note that the PR description (but not the code itself) is incorrect: it says that partial name matches are part of the correct order. In fact, we don't do partial name resolution. |
cli/command/service/ps.go
Outdated
There was a problem hiding this comment.
Here we're choosing the first service whose ID matches the prefix, and ignoring the others. I think we should error out if the prefix is ambiguous. There are several places in the code where we do this, and again, I think in the long term it would be a good idea to consolidate the code in a central package.
There was a problem hiding this comment.
I agree we need to have a standard solution. I was actually considering to error out if matches > 1; this will complicate the logic a bit, because we'll have to check number of matches per keyword, and possibly de-duplicate the keywords (e.g. docker service ps foo foo)
10fc3ef to
0044194
Compare
|
@aaronlehmann updated the PR. It's a bit ugly (lots of logic in there), but I think this addresses all situations |
cli/command/service/ps.go
Outdated
There was a problem hiding this comment.
This should go above, with "strings"
There was a problem hiding this comment.
oh cr*p, it was automatically inserted by my editor. thx for catching
cli/command/service/ps.go
Outdated
There was a problem hiding this comment.
Feel free to ignore this, but I try to avoid using Sprintf for simple string concatenation. With the + operator, there isn't a chance of proving the wrong number or type of arguments to Sprintf.
There was a problem hiding this comment.
heh, I actually had that at first, but wasn't sure if we liked plain concatting. I'll change
cli/command/service/ps.go
Outdated
There was a problem hiding this comment.
Seems like matches could just be a boolean, since we only care about whether there was a previous match or not. But it's fine either way.
|
Overall LGTM The failures seem unrelated |
The docker CLI matches objects either by ID _prefix_ or a full name match, but not partial name matches. The correct order of resolution is; - Full ID match (a name should not be able to mask an ID) - Full name - ID-prefix This patch changes the way services are matched. Also change to use the first matching service, if there's a full match (by ID or Name) instead of continue looking for other possible matches. Error handling changed; - Do not error early if multiple services were requested and one or more services were not found. Print the services that were not found after printing those that _were_ found instead - Print an error if ID-prefix matching is ambiguous Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
0044194 to
4242aec
Compare
|
Addressed nits :) |
|
Please reopen to docker/CLI? |
|
opened docker/cli#72 for the CLI side, I'll bump the CLI version and remove those changes here |
|
@thaJeztah: Is this needed to fix the test now that the CLI behavior has changed? |
|
@aaronlehmann the CLI in this repo still uses an older version, but we need to update it. Problem is currently that I don't know how to get the 17.06 CLI in. I think the plan is to fixate the CLI to 17.06-GA for integration tests, but given that https://github.com/docker/cli does not have a tag or branch for 17.06, we cannot get it from there; it needs to be fetched from https://github.com/docker/docker-ce, but that means getting the entire "docker" repository (which is big), so not idea. |
|
Actually, thinking if #33684 will pass, because it will be running against the old CLI |
|
Nevermind, it doesn't assume the CLI changes yet |
That is mind-boggling.
|
All cherry-picking is done in docker/docker-ce, so that no branches had to be maintained for the individual repos
After 17.06-GA we won't accept new integration tests that use the Docker CLI (at least, not in this repository), the 17.06 CLI will be used for the existing tests, to catch regressions. Newer versions may be used in a e2e test-suite managed by Docker, Inc., but that's not a responsibility in this repo |
What is wrong with having branches in I think cherry-picking in It also has the disadvantage that you pointed out where there is no revision in
This doesn't answer my question of why the cli must be fixed at that particular version, instead of, say, master from |
|
This was merged in We'll need to port this cli test to an API test |
The docker CLI matches objects either by ID prefix
or a full name match, but not partial name matches.
The correct order of resolution is;
This patch changes the way services are matched.
Also change to use the first matching service, if there's a full match (by ID or Name) instead of continue looking for other possible matches.
Error handling changed;
fixes #32556
With this patch applied;
Given these services
Match by name no longer does a "prefix" match
Full name match "trumps" partial ID match;
Ambiguous ID-prefix produces an error
Don't error out on first non-existing service, but print errors at the end