Merge pull request #4517 from thaJeztah/24.0_backport_docker-cli-slows-bash-init

[24.0 backport] Stop slowing bash init by caching plugins path slowly
This commit is contained in:
Sebastiaan van Stijn 2023-08-23 14:04:35 +02:00 committed by GitHub
commit 98ffe42d84
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 2 deletions

View File

@ -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
@ -5504,7 +5507,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%%.*}