Skip to content

"oc config use-context" should complete contexts #372

Open
@commonquail

Description

@commonquail

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    lifecycle/frozenIndicates that an issue or PR should not be auto-closed due to staleness.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions