"oc config use-context" should complete contexts
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 247
- Forks
- 475
- Avg merge
- 4d 9h
- Merged PRs (30d)
- 11
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the shell completion definition for __custom_func and the existing oc config use-context and rename-context handlers. Compare the available kubectl context-completion helpers and account for the dependency concern described in the issue. Done means oc config use-context offers context candidates without producing a missing-command error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- shell
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100