Skip to content

Commit

Permalink
Merge pull request #4518 from thaJeztah/23.0_backport_docker-cli-slow…
Browse files Browse the repository at this point in the history
…s-bash-init

[23.0 backport] Stop slowing bash init by caching plugins path slowly
  • Loading branch information
thaJeztah committed Aug 23, 2023
2 parents fa6e4ac + 8f67e81 commit 92955ed
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions contrib/completion/bash/docker
Original file line number Diff line number Diff line change
Expand Up @@ -1142,7 +1142,10 @@ __docker_complete_user_group() {
fi
}

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

__docker_complete_plugin() {
local path=$1
Expand Down Expand Up @@ -5503,7 +5506,7 @@ _docker() {
# Create completion functions for all registered plugins
local known_plugin_commands=()
local plugin_name=""
for plugin_path in ${DOCKER_PLUGINS_PATH//:/ }; do
for plugin_path in $(__docker_plugins_path); do
plugin_name=$(basename "$plugin_path" | sed 's/ *$//')
plugin_name=${plugin_name#docker-}
plugin_name=${plugin_name%%.*}
Expand Down

0 comments on commit 92955ed

Please sign in to comment.