-
Notifications
You must be signed in to change notification settings - Fork 2.1k
make compose plugin detection in bash completion work on Mac OS #3392
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
make compose plugin detection in bash completion work on Mac OS #3392
Conversation
|
@albers Hello, could you take some action on this? |
6ca1804 to
3efc8d3
Compare
albers
left a comment
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, thanks.
albers
left a comment
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.
Sorry, there's still one thing to do with your PR: please sign off the commit, see the failing DCO check.
3efc8d3 to
d37fc04
Compare
|
@albers done. The commit now has sign |
Codecov Report
@@ Coverage Diff @@
## master #3392 +/- ##
=======================================
Coverage 56.35% 56.35%
=======================================
Files 304 304
Lines 26830 26830
=======================================
Hits 15121 15121
Misses 10789 10789
Partials 920 920 |
albers
left a comment
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
|
@thaJeztah PTAL |
thaJeztah
left a comment
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.
contrib/completion/bash/docker
Outdated
| } | ||
|
|
||
| COMPOSE_PLUGIN_PATH=$(docker info --format '{{json .ClientInfo.Plugins}}' | sed -n 's/.*"Path":"\([^"]\+docker-compose\)".*/\1/p') | ||
| COMPOSE_PLUGIN_PATH=$(docker info --format '{{json .ClientInfo.Plugins}}' | sed -n -E 's/.*"Path":"([^"]+docker-compose)".*/\1/p') |
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 was wondering if we could do it with --format alone, and (while the syntax is a bit awkward), looks like it's possible when combining range and if eq;
docker info --format '{{range .ClientInfo.Plugins}}{{if eq .Name "compose"}}{{.Path}}{{end}}{{end}}'
/usr/local/lib/docker/cli-plugins/docker-composeThe script would then look like;
COMPOSE_PLUGIN_PATH=$(docker info --format '{{range .ClientInfo.Plugins}}{{if eq .Name "compose"}}{{.Path}}{{end}}{{end}}')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's one small difference; the docker info --format always prints a newline, whereas the sed variant does not; if I replace compose with nosuch (to mimic a situation where the compose plugin is not installed);
docker info --format '{{range .ClientInfo.Plugins}}{{if eq .Name "nosuch"}}{{.Path}}{{end}}{{end}}'
# prints an empty line
docker info --format '{{json .ClientInfo.Plugins}}' | sed -n -E 's/.*"Path":"([^"]+docker-nosuch)".*/\1/p'
# doesn't print an empty lineBut I don't think that's a problem as the script checks if $COMPOSE_PLUGIN_PATH contains a valid path, and that still looks to work ok with that;
# for the "nosuch" plugin:
COMPOSE_PLUGIN_PATH=$(docker info --format '{{range .ClientInfo.Plugins}}{{if eq .Name "nosuch"}}{{.Path}}{{end}}{{end}}')
if [ -f "$COMPOSE_PLUGIN_PATH" ] ; then echo YES; fi
# doesn't print anything
# for the "compose" plugin:
COMPOSE_PLUGIN_PATH=$(docker info --format '{{range .ClientInfo.Plugins}}{{if eq .Name "compose"}}{{.Path}}{{end}}{{end}}')
if [ -f "$COMPOSE_PLUGIN_PATH" ] ; then echo YES; fi
# prints "YES"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.
@thaJeztah Your suggestion has the advantage that it accesses the information in a structured way (i.e. by .Name) instead of text based operations that rely on naming conventions.
So I think we should go this way.
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.
@albers Should do I bring a new PR and decline this one with the solution suggested by @thaJeztah or just force push a new commit and change the PR description and the name?
I'm asking because the PR already has approves and assigned milestone.
As a compromise, I could bring suggestions by @thaJeztah in a new PR for the next milestone (not the assigned one - 21.xx)
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 think it's best to force-push and then update the PR title to a more intention revealing wording, something like "make compose plugin detection in bash completion work on Mac OS"
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.
@albers It's done
Signed-off-by: Vardan Pogosian <vardan.pogosyan@gmail.com>
d37fc04 to
77b1031
Compare
albers
left a comment
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, thanks @varp
thaJeztah
left a comment
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, thank you!!
Signed-off-by: Vardan Pogosian vardan.pogosyan@gmail.com
- What I did
Replaced sed invocation with Go templates invocations
- How I did it
Replaced sed invocation with Go templates invocations
- How to verify it
Install docker-compose 2.2.2 as a plugin for docker CLI on Mac OS X and try to auto-complete
docker comp<tab>. It will auto-complete todocker compose- Description for the changelog
Made sed invocation, used at COMPOSER_PLUGIN_PATH detection (for BASH completion) compatible with POSIX 1003.2 RE to properly work on OS X.
- A picture of a cute animal (not mandatory but encouraged)