mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-05 15:37:24 +00:00
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 ```
This commit is contained in:
@@ -67,15 +67,6 @@ __kubectl_override_flags()
|
||||
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_parse_config "contexts"
|
||||
@@ -119,6 +110,11 @@ __kubectl_get_resource()
|
||||
__kubectl_parse_get "${nouns[${#nouns[@]} -1]}"
|
||||
}
|
||||
|
||||
__kubectl_get_resource_namespace()
|
||||
{
|
||||
__kubectl_parse_get "namespace"
|
||||
}
|
||||
|
||||
__kubectl_get_resource_pod()
|
||||
{
|
||||
__kubectl_parse_get "pod"
|
||||
@@ -247,7 +243,7 @@ __custom_func() {
|
||||
|
||||
var (
|
||||
bash_completion_flags = map[string]string{
|
||||
"namespace": "__kubectl_get_namespaces",
|
||||
"namespace": "__kubectl_get_resource_namespace",
|
||||
"context": "__kubectl_config_get_contexts",
|
||||
"cluster": "__kubectl_config_get_clusters",
|
||||
"user": "__kubectl_config_get_users",
|
||||
|
||||
Reference in New Issue
Block a user