Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate context and user name smartly when merging config #768

Closed
yujunz opened this issue Sep 7, 2023 · 6 comments · Fixed by #956
Closed

Generate context and user name smartly when merging config #768

yujunz opened this issue Sep 7, 2023 · 6 comments · Fixed by #956
Assignees
Labels
kind/feature ategorizes issue or PR as related to a new feature.

Comments

@yujunz
Copy link

yujunz commented Sep 7, 2023

Is your feature request related to a problem? Please describe.
I'm always frustrated when merging config produces random context names, e.g.

Loading KubeConfig file: /Users/yujunz/.kube/config
Add Context: config-ktd65k9dkh
Add Context: config-9bbc58ghm5
Add Context: config-7864ft646m
Add Context: config-4hd4hd7cd7
Add Context: config-k6hh45mbt5
Add Context: config-mg6mch5976
Add Context: config-6kf6g9mbc4

and duplicated users

name: vault-user
  user:
    client-certificate: client.crt
    client-key: client
- name: vault-user-7864ft646m
  user:
    client-certificate: client.crt
    client-key: client
- name: vault-user-k6hh45mbt5
  user:
    client-certificate: client.crt
    client-key: client

Describe the solution you'd like
Format the context from cluster and user name, e.g. user@cluster or simply cluster when there is no ambiguity.

Describe alternatives you've considered
Allow user to define the format string

Additional context
N/A

@yujunz
Copy link
Author

yujunz commented Sep 8, 2023

kubecm merge ~/.kube/dev0.config ~/.kube/stg0.config ~/.kube/config
Loading KubeConfig file: /Users/yujunz/.kube/dev0.config
Add Context: dev0
Loading KubeConfig file: /Users/yujunz/.kube/stg0.config
Add Context: stg0
Loading KubeConfig file: /Users/yujunz/.kube/config
Add Context: config-4cc9fbm2f6
Add Context: config-ktd65k9dkh
Add Context: config-7d78g685c4
Add Context: config-d5btdk9gc8
Add Context: config-22h4ktfc5b
Add Context: config-5ftf6hdm4g

Currently it renames the existing context to random strings which is quite annoying.

@sunny0826
Copy link
Owner

It's a historical problem. Thanks for the feedback, I'll follow up by refactoring this part of the code.

@sunny0826 sunny0826 self-assigned this Dec 27, 2023
@sunny0826 sunny0826 added the kind/feature ategorizes issue or PR as related to a new feature. label Dec 27, 2023
@FeryET
Copy link

FeryET commented Apr 24, 2024

Is there anyway to keep the name of contexts in case of merging? I have unique context names in various files that I want to keep after merging.

@sunny0826
Copy link
Owner

Sorry this hasn't been fixed yet due to work changes, I'll try to open this up in the near future.

@sunny0826 sunny0826 removed their assignment May 20, 2024
@sunny0826
Copy link
Owner

/assign @cr7258

@cr7258
Copy link
Contributor

cr7258 commented May 20, 2024

I'll work on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature ategorizes issue or PR as related to a new feature.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants