oc login should avoid clobbering kubeconfig contexts
@tchap is already working on this.
Since Jan 16, 2026.
- Dominant language
- Go
- Stars
- 247
- Forks
- 475
- Avg merge
- 4d 9h
- Merged PRs (30d)
- 11
Description
Default behavior of oc login https://openshift.example.com --username=thelonelyghost --password='hunter2' is to do the following:
- Setup a new (or if exists, update) cluster in the kubeconfig by the name of
openshift-example-com:443 - Setup a new (or if exists, update) user in the kubeconfig by the name of
thelonelyghost/openshift-example-com:443 - Setup a new (or if exists, update) context in the kubeconfig by the name of
default/openshift-example-com:443/thelonelyghost. - Set the current context to be
default/openshift-example-com:443/thelonelyghost
This is fine for initial setup, but periodically I'm forced to login again to refresh the bearer token stored in the user section of the kubeconfig. When I do that, I must run the same oc login command again. Here's the problem:
If I re-run that command, it clobbers any changes I've made to human-facing names of the cluster, the context, or the user that have zero functional effect on the file. If I renamed the default/openshift-example-com:443/thelonelyghost context to be more user-friendly, such as company-prod, logging in again adds an additional context of default/openshift-example-com:443/thelonelyghost back again. It does not update credentials in-place, it adds them if they're not named exactly what is expected.
I've written a tool in python named oc-replacement to re-authenticate in-place as I desire, but it would be much more desirable for this to be default behavior or even an option with the oc command line tool.
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.
Assessment
This issue has not been assessed yet.