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}') ) 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() { __docker_local_interfaces() {
command -v ip >/dev/null 2>&1 || return 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() { __docker_complete_local_interfaces() {
local additional_interface local additional_interface
if [ "$1" = "--add" ] ; then if [ "$1" = "--add" ] ; then
additional_interface="$2" additional_interface="$2"
shift 2
fi 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 # __docker_complete_capabilities_addable completes Linux capabilities which are
@ -1962,9 +1984,11 @@ _docker_daemon() {
--iptables=false --iptables=false
--ipv6 --ipv6
--live-restore --live-restore
--no-new-privileges
--raw-logs --raw-logs
--selinux-enabled --selinux-enabled
--userland-proxy=false --userland-proxy=false
--version -v
" "
local options_with_args=" local options_with_args="
$global_options_with_args $global_options_with_args
@ -1980,9 +2004,12 @@ _docker_daemon() {
--cluster-store-opt --cluster-store-opt
--config-file --config-file
--containerd --containerd
--cpu-rt-period
--cpu-rt-runtime
--data-root --data-root
--default-gateway --default-gateway
--default-gateway-v6 --default-gateway-v6
--default-runtime
--default-shm-size --default-shm-size
--default-ulimit --default-ulimit
--dns --dns
@ -2001,6 +2028,7 @@ _docker_daemon() {
--log-opt --log-opt
--max-concurrent-downloads --max-concurrent-downloads
--max-concurrent-uploads --max-concurrent-uploads
--metrics-addr
--mtu --mtu
--oom-score-adjust --oom-score-adjust
--pidfile -p --pidfile -p
@ -2009,6 +2037,7 @@ _docker_daemon() {
--shutdown-timeout --shutdown-timeout
--storage-driver -s --storage-driver -s
--storage-opt --storage-opt
--swarm-default-advertise-addr
--userland-proxy-path --userland-proxy-path
--userns-remap --userns-remap
" "
@ -2130,10 +2159,20 @@ _docker_daemon() {
__docker_complete_log_options __docker_complete_log_options
return return
;; ;;
--metrics-addr)
__docker_complete_local_ips
__docker_append_to_completions ":"
__docker_nospace
return
;;
--seccomp-profile) --seccomp-profile)
_filedir json _filedir json
return return
;; ;;
--swarm-default-advertise-addr)
__docker_complete_local_interfaces
return
;;
--userns-remap) --userns-remap)
__docker_complete_user_group __docker_complete_user_group
return return