Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
e78d7749
Commit
e78d7749
authored
Apr 04, 2016
by
Dr. Stefan Schimanski
Committed by
Dr. Stefan Schimanski
Jun 28, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add awareness of more override flags in bash-completion
parent
f3359fe1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
20 deletions
+25
-20
cmd.go
pkg/kubectl/cmd/cmd.go
+25
-20
No files found.
pkg/kubectl/cmd/cmd.go
View file @
e78d7749
...
...
@@ -32,30 +32,35 @@ import (
const
(
bash_completion_func
=
`# call kubectl get $1,
__kubectl_namespace_flag()
__kubectl_override_flag_list=(kubeconfig cluster user context namespace server)
__kubectl_override_flags()
{
local ret two_word_ns
ret=""
two_word_ns=false
local ${__kubectl_override_flag_list[*]} two_word_of of
for w in "${words[@]}"; do
if [
"$two_word_ns" = true
]; then
ret="--namespace=${w}
"
two_word_
ns=false
if [
-n "${two_word_of}"
]; then
eval "${two_word_of}=\"--${two_word_of}=\${w}\"
"
two_word_
of=
continue
fi
case "${w}" in
--namespace=*)
ret=${w}
;;
--namespace)
two_word_ns=true
;;
--all-namespaces)
ret=${w}
;;
esac
for of in "${__kubectl_override_flag_list[@]}"; do
case "${w}" in
--${of}=*)
eval "${of}=\"--${of}=\${w}\""
;;
--${of})
two_word_of="${of}"
;;
esac
done
if [ "${w}" == "--all-namespaces" ]; then
namespace="--all-namespaces"
fi
done
for of in "${__kubectl_override_flag_list[@]}"; do
if eval "test -n \"\$${of}\""; then
eval "echo \${${of}}"
fi
done
echo $ret
}
__kubectl_get_namespaces()
...
...
@@ -72,7 +77,7 @@ __kubectl_parse_get()
local template
template="{{ range .items }}{{ .metadata.name }} {{ end }}"
local kubectl_out
if kubectl_out=$(kubectl get $(__kubectl_
namespace_flag
) -o template --template="${template}" "$1" 2>/dev/null); then
if kubectl_out=$(kubectl get $(__kubectl_
override_flags
) -o template --template="${template}" "$1" 2>/dev/null); then
COMPREPLY=( $( compgen -W "${kubectl_out[*]}" -- "$cur" ) )
fi
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment