Driver-specific completions for --log-opt

Signed-off-by: Harald Albers <github@albersweb.de>
This commit is contained in:
Harald Albers 2015-07-13 17:28:25 +02:00
Родитель e09d0febe6
Коммит faa8b658e7
1 изменённых файлов: 49 добавлений и 0 удалений

Просмотреть файл

@ -116,6 +116,25 @@ __docker_pos_first_nonflag() {
echo $counter echo $counter
} }
# Returns the value of the first option matching option_glob.
# Valid values for option_glob are option names like '--log-level' and
# globs like '--log-level|-l'
# Only positions between the command and the current word are considered.
__docker_value_of_option() {
local option_glob=$1
local counter=$((command_pos + 1))
while [ $counter -lt $cword ]; do
case ${words[$counter]} in
$option_glob )
echo ${words[$counter + 1]}
break
;;
esac
(( counter++ ))
done
}
# Transforms a multiline list of strings into a single line string # Transforms a multiline list of strings into a single line string
# with the words separated by "|". # with the words separated by "|".
# This is used to prepare arguments to __docker_pos_first_nonflag(). # This is used to prepare arguments to __docker_pos_first_nonflag().
@ -193,6 +212,26 @@ __docker_log_drivers() {
" -- "$cur" ) ) " -- "$cur" ) )
} }
__docker_log_driver_options() {
# see docs/reference/logging/index.md
case $(__docker_value_of_option --log-driver) in
fluentd)
COMPREPLY=( $( compgen -W "fluentd-address fluentd-tag" -S = -- "$cur" ) )
;;
gelf)
COMPREPLY=( $( compgen -W "gelf-address gelf-tag" -S = -- "$cur" ) )
;;
syslog)
COMPREPLY=( $( compgen -W "syslog-address syslog-facility syslog-tag" -S = -- "$cur" ) )
;;
*)
return
;;
esac
compopt -o nospace
}
# a selection of the available signals that is most likely of interest in the # a selection of the available signals that is most likely of interest in the
# context of docker containers. # context of docker containers.
__docker_signals() { __docker_signals() {
@ -240,6 +279,10 @@ _docker_docker() {
COMPREPLY=( $( compgen -W "debug info warn error fatal" -- "$cur" ) ) COMPREPLY=( $( compgen -W "debug info warn error fatal" -- "$cur" ) )
return return
;; ;;
--log-opt)
__docker_log_driver_options
return
;;
--pidfile|-p|--tlscacert|--tlscert|--tlskey) --pidfile|-p|--tlscacert|--tlscert|--tlskey)
_filedir _filedir
return return
@ -847,6 +890,7 @@ _docker_run() {
--label-file --label-file
--link --link
--log-driver --log-driver
--log-opt
--lxc-conf --lxc-conf
--mac-address --mac-address
--memory -m --memory -m
@ -955,6 +999,10 @@ _docker_run() {
__docker_log_drivers __docker_log_drivers
return return
;; ;;
--log-opt)
__docker_log_driver_options
return
;;
--net) --net)
case "$cur" in case "$cur" in
container:*) container:*)
@ -1229,6 +1277,7 @@ _docker() {
--label --label
--log-driver --log-driver
--log-level -l --log-level -l
--log-opt
--mtu --mtu
--pidfile -p --pidfile -p
--registry-mirror --registry-mirror