Uh oh!
There was an error while loading. Please reload this page.
make compose plugin detection in bash completion work on Mac OS - #3392
Conversation
@albers Hello, could you take some action on this? |
Uh oh!
There was an error while loading. Please reload this page.
6ca1804 to
3efc8d3Compare
albers
left a comment
There was a problem hiding this comment.
Sorry, there's still one thing to do with your PR: please sign off the commit, see the failing DCO check.
3efc8d3 to
d37fc04Comparevarp
commented
Dec 24, 2021
@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
commented
Dec 26, 2021
@thaJeztah PTAL |
| } | ||
| 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.
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.
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" ] ;thenecho 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" ] ;thenecho YES;fi# prints "YES"There was a problem hiding this comment.
@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.
@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.
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"
Signed-off-by: Vardan Pogosian <vardan.pogosyan@gmail.com>
d37fc04 to
77b1031Compare
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)