Merge pull request #282 from albers/completion-daemon-updates

Updates to bash completion for `dockerd`
This commit is contained in:
Victor Vieux 2017-07-04 16:42:10 +02:00 committed by GitHub
commit 42a31ff8c1
1 changed files with 41 additions and 2 deletions

View File

@ -636,18 +636,40 @@ __docker_complete_resolved_hostname() {
COMPREPLY=( $(host 2>/dev/null "${cur%:}" | awk '/has address/ {print $4}') )
}
# __docker_local_interfaces returns a list of the names and addresses of all
# local network interfaces.
# If `--ip-only` is passed as a first argument, only addresses are returned.
__docker_local_interfaces() {
command -v ip >/dev/null 2>&1 || return
ip addr show scope global 2>/dev/null | sed -n 's| \+inet \([0-9.]\+\).* \([^ ]\+\)|\1 \2|p'
local format
if [ "$1" = "--ip-only" ] ; then
format='\1'
shift
else
format='\1 \2'
fi
ip addr show scope global 2>/dev/null | sed -n "s| \+inet \([0-9.]\+\).* \([^ ]\+\)|$format|p"
}
# __docker_complete_local_interfaces applies completion of the names and addresses of all
# local network interfaces based on the current value of `$cur`.
# An additional value can be added to the possible completions with an `--add` argument.
__docker_complete_local_interfaces() {
local additional_interface
if [ "$1" = "--add" ] ; then
additional_interface="$2"
shift 2
fi
COMPREPLY=( $( compgen -W "$(__docker_local_interfaces) $additional_interface" -- "$cur" ) )
COMPREPLY=( $( compgen -W "$(__docker_local_interfaces "$@") $additional_interface" -- "$cur" ) )
}
# __docker_complete_local_ips applies completion of the addresses of all local network
# interfaces based on the current value of `$cur`.
__docker_complete_local_ips() {
__docker_complete_local_interfaces --ip-only
}
# __docker_complete_capabilities_addable completes Linux capabilities which are
@ -1962,9 +1984,11 @@ _docker_daemon() {
--iptables=false
--ipv6
--live-restore
--no-new-privileges
--raw-logs
--selinux-enabled
--userland-proxy=false
--version -v
"
local options_with_args="
$global_options_with_args
@ -1980,9 +2004,12 @@ _docker_daemon() {
--cluster-store-opt
--config-file
--containerd
--cpu-rt-period
--cpu-rt-runtime
--data-root
--default-gateway
--default-gateway-v6
--default-runtime
--default-shm-size
--default-ulimit
--dns
@ -2001,6 +2028,7 @@ _docker_daemon() {
--log-opt
--max-concurrent-downloads
--max-concurrent-uploads
--metrics-addr
--mtu
--oom-score-adjust
--pidfile -p
@ -2009,6 +2037,7 @@ _docker_daemon() {
--shutdown-timeout
--storage-driver -s
--storage-opt
--swarm-default-advertise-addr
--userland-proxy-path
--userns-remap
"
@ -2130,10 +2159,20 @@ _docker_daemon() {
__docker_complete_log_options
return
;;
--metrics-addr)
__docker_complete_local_ips
__docker_append_to_completions ":"
__docker_nospace
return
;;
--seccomp-profile)
_filedir json
return
;;
--swarm-default-advertise-addr)
__docker_complete_local_interfaces
return
;;
--userns-remap)
__docker_complete_user_group
return