Commit 4b4e9197 authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #48274 from superbrothers/fix-to-override-kubectl-flags

Automatic merge from submit-queue (batch tested with PRs 48381, 48274) Fix completions for --namespace to override kubectl flags **What this PR does / why we need it**: This PR fixes completions for --namespace to override kubectl flags. Due to not using __kubectl_parse_get, __kubectl_get_namespaces doesn't support to override kubectl flags. **Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes # **Special notes for your reviewer**: **Release note**: ```release-note NONE ```
parents 0049dd07 4cdc5247
...@@ -67,15 +67,6 @@ __kubectl_override_flags() ...@@ -67,15 +67,6 @@ __kubectl_override_flags()
done done
} }
__kubectl_get_namespaces()
{
local template kubectl_out
template="{{ range .items }}{{ .metadata.name }} {{ end }}"
if kubectl_out=$(kubectl get -o template --template="${template}" namespace 2>/dev/null); then
COMPREPLY=( $( compgen -W "${kubectl_out[*]}" -- "$cur" ) )
fi
}
__kubectl_config_get_contexts() __kubectl_config_get_contexts()
{ {
__kubectl_parse_config "contexts" __kubectl_parse_config "contexts"
...@@ -119,6 +110,11 @@ __kubectl_get_resource() ...@@ -119,6 +110,11 @@ __kubectl_get_resource()
__kubectl_parse_get "${nouns[${#nouns[@]} -1]}" __kubectl_parse_get "${nouns[${#nouns[@]} -1]}"
} }
__kubectl_get_resource_namespace()
{
__kubectl_parse_get "namespace"
}
__kubectl_get_resource_pod() __kubectl_get_resource_pod()
{ {
__kubectl_parse_get "pod" __kubectl_parse_get "pod"
...@@ -247,7 +243,7 @@ __custom_func() { ...@@ -247,7 +243,7 @@ __custom_func() {
var ( var (
bash_completion_flags = map[string]string{ bash_completion_flags = map[string]string{
"namespace": "__kubectl_get_namespaces", "namespace": "__kubectl_get_resource_namespace",
"context": "__kubectl_config_get_contexts", "context": "__kubectl_config_get_contexts",
"cluster": "__kubectl_config_get_clusters", "cluster": "__kubectl_config_get_clusters",
"user": "__kubectl_config_get_users", "user": "__kubectl_config_get_users",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment