Skip to content

Commit 8f67e81

Browse files
guss77thaJeztah
authored andcommitted
Stop slowing bash init by caching plugins path slowly
Fixes issue #3889 by only loading docker plugins path when needed: if it is fast enough than it shouldn't be a problem to do this on demand; OTOH if it is slow then we shouldn't do this during *every* bash session initialization, regardless if docker completion will be needed or not. Signed-off-by: Oded Arbel <[email protected]> (cherry picked from commit 1da67be) Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 7e32d44 commit 8f67e81

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

contrib/completion/bash/docker

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,7 +1142,10 @@ __docker_complete_user_group() {
11421142
fi
11431143
}
11441144

1145-
DOCKER_PLUGINS_PATH=$(docker info --format '{{range .ClientInfo.Plugins}}{{.Path}}:{{end}}')
1145+
__docker_plugins_path() {
1146+
local docker_plugins_path=$(docker info --format '{{range .ClientInfo.Plugins}}{{.Path}}:{{end}}')
1147+
echo "${docker_plugins_path//:/ }"
1148+
}
11461149

11471150
__docker_complete_plugin() {
11481151
local path=$1
@@ -5503,7 +5506,7 @@ _docker() {
55035506
# Create completion functions for all registered plugins
55045507
local known_plugin_commands=()
55055508
local plugin_name=""
5506-
for plugin_path in ${DOCKER_PLUGINS_PATH//:/ }; do
5509+
for plugin_path in $(__docker_plugins_path); do
55075510
plugin_name=$(basename "$plugin_path" | sed 's/ *$//')
55085511
plugin_name=${plugin_name#docker-}
55095512
plugin_name=${plugin_name%%.*}

0 commit comments

Comments
 (0)