Simplify logic

Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>
pull/6472/head
Marc Khouzam 5 years ago
parent d50e2a3134
commit 2db09189f4

@ -89,19 +89,22 @@ __helm_get_namespaces()
fi
}
__helm_list_releases()
__helm_binary_name()
{
__helm_debug "${FUNCNAME[0]}: c is $c words[c] is ${words[c]}"
local out filter helm_binary
# Use ^ to map from the start of the release name
filter="^${words[c]}"
local helm_binary
helm_binary="${words[0]}"
__helm_debug "${FUNCNAME[0]}: helm_binary is ${helm_binary}"
echo ${helm_binary}
}
# Use eval in case helm_binary or __helm_override_flags contains a variable (e.g., $HOME/bin/h3)
if out=$(eval ${helm_binary} list $(__helm_override_flags) -a -q -m 1000 -f ${filter} 2>/dev/null); then
__helm_list_releases()
{
__helm_debug "${FUNCNAME[0]}: c is $c words[c] is ${words[c]}"
local out filter
# Use ^ to map from the start of the release name
filter="^${words[c]}"
# Use eval in case helm_binary_name or __helm_override_flags contains a variable (e.g., $HOME/bin/h3)
if out=$(eval $(__helm_binary_name) list $(__helm_override_flags) -a -q -m 1000 -f ${filter} 2>/dev/null); then
COMPREPLY=( $( compgen -W "${out[*]}" -- "$cur" ) )
fi
}
@ -109,13 +112,9 @@ __helm_list_releases()
__helm_list_repos()
{
__helm_debug "${FUNCNAME[0]}: c is $c words[c] is ${words[c]}"
local out helm_binary
helm_binary="${words[0]}"
__helm_debug "${FUNCNAME[0]}: helm_binary is ${helm_binary}"
# Use eval in case helm_binary contains a variable (e.g., $HOME/bin/h3)
if out=$(eval ${helm_binary} repo list 2>/dev/null | tail +2 | cut -f1); then
local out
# Use eval in case helm_binary_name contains a variable (e.g., $HOME/bin/h3)
if out=$(eval $(__helm_binary_name) repo list 2>/dev/null | tail +2 | cut -f1); then
COMPREPLY=( $( compgen -W "${out[*]}" -- "$cur" ) )
fi
}
@ -123,13 +122,9 @@ __helm_list_repos()
__helm_list_plugins()
{
__helm_debug "${FUNCNAME[0]}: c is $c words[c] is ${words[c]}"
local out helm_binary
helm_binary="${words[0]}"
__helm_debug "${FUNCNAME[0]}: helm_binary is ${helm_binary}"
# Use eval in case helm_binary contains a variable (e.g., $HOME/bin/h3)
if out=$(eval ${helm_binary} plugin list 2>/dev/null | tail +2 | cut -f1); then
local out
# Use eval in case helm_binary_name contains a variable (e.g., $HOME/bin/h3)
if out=$(eval $(__helm_binary_name) plugin list 2>/dev/null | tail +2 | cut -f1); then
COMPREPLY=( $( compgen -W "${out[*]}" -- "$cur" ) )
fi
}

Loading…
Cancel
Save