Description
kubectl config use-context
can complete contexts. oc config use-context
cannot. Being able to complete contexts would be quite helpful in its own right, but especially so since oc login
clobbers kubeconfig contexts while simultaneously oc
breaks kubectl
's ability to complete contexts.
One way to accomplish this would be to piggy-back kubectl
's context completion by adding.
oc_config_use-context | oc_config_rename-context)
__kubectl_config_get_contexts
return
;;
to __custom_func
, and optionally
flags_with_completion+=("--context")
flags_completion+=("__kubectl_config_get_contexts")
after every
flags+=("--context=")
The downside to that approach is the dependency on kubectl
completion, without which you get something like
$ oc config use-context <tab>__kubectl_config_get_contexts: command not found
oc create clusterrolebinding
already delegates to __kubectl_get_resource_clusterrule
so there is precedence, however, I'd personally consider contexts to be a far more prominent concept than cluster role bindings.
In a similar vein, clusters and users could be completed with __kubectl_config_get_clusters
and __kubectl_config_get_users
.
An even simpler way to resolve this is to resolve #371 and declare these completions outside of oc
's scope.