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

add an option to only show context name in set cmd #48

Open
golgoth31 opened this issue Feb 5, 2023 · 5 comments · May be fixed by #49
Open

add an option to only show context name in set cmd #48

golgoth31 opened this issue Feb 5, 2023 · 5 comments · May be fixed by #49

Comments

@golgoth31
Copy link

golgoth31 commented Feb 5, 2023

Hi, thank you for your job. A cool feature should to have an option in the set cmd to only show context name.
I send you a PR in this way.

@golgoth31 golgoth31 linked a pull request Feb 5, 2023 that will close this issue
@golgoth31 golgoth31 changed the title add an option to only show cluster name in set cmd add an option to only show context name in set cmd Feb 7, 2023
@SimonTheLeg
Copy link
Owner

Hi @golgoth31 thank you for submittinga feature request and also the PR. I am currently trying to understand the idea behind this better.
Is this just related to removing the name of the cluster from the output to make it look nicer? I am imagining a situation where the cluster name is randomly generated like GKE does.
Or in the long-run do you also want the tab-completion of commands to change?

@golgoth31
Copy link
Author

Hi,
the idea is to only show the full name of the context. In GKE for example, the context name is not so random but pretty long. In the tabular view as built by default, all my context are quite the same due to truncation so almost unusable. I also should say that I don't need to know the cluster name nor the config file used.
We could had the tab completion in the future but it was not the primary use case.

@sourcedelica
Copy link

Here's an example:

$ konf set
Use the arrow keys to navigate: ↓ ↑ → ←  and / toggles search
?   Context                   | Cluster                   | File                      :
  ▸ arn:aws:eks:us-east-1:116 | arn:aws:eks:us-east-1:116 | /home/eric/.kube/konfs/st |
    arn:aws:eks:us-east-1:223 | arn:aws:eks:us-east-1:223 | /home/eric/.kube/konfs/st |
    arn:aws:eks:us-east-1:483 | arn:aws:eks:us-east-1:483 | /home/eric/.kube/konfs/st |
    arn:aws:eks:us-east-1:841 | arn:aws:eks:us-east-1:841 | /home/eric/.kube/konfs/st |
    arn:aws:eks:us-east-1:841 | arn:aws:eks:us-east-1:841 | /home/eric/.kube/konfs/st |
    dev-sandbox-usinfdevranch | dev-sandbox-usinfdevranch | /home/eric/.kube/konfs/st |
    dev-sandbox-usinfdevranch | dev-sandbox-usinfdevranch | /home/eric/.kube/konfs/st |
    dev-sandbox-usinfdevranch | dev-sandbox-usinfdevranch | /home/eric/.kube/konfs/st |
    dev-sandbox               | dev-sandbox               | /home/eric/.kube/konfs/st |
    uspttdevrafay1            | uspttdevrafay1            | /home/eric/.kube/konfs/st |

You can't tell the difference between the two rows starting with arn:aws:eks:us-east-1:841 nor the ones starting with ev-sandbox-usinfdevranch. It would be nice to show just the name of the file in the store directory (without the store directory itself since it's redundant).

@SimonTheLeg
Copy link
Owner

@sourcedelica Ah okay now I understand. Thanks for the input.

I am currently debating with myself between a couple of options, which are also combinable:

a) Implement a shortening algorithm for similar contexts and clusters
Could be something that checks of all of the contexts and clusters if a beginning substring matches and then shortens the display. For example arn:aws:eks:us-east-1:841abc and arn:aws:eks:us-east-1:841xyz have 25 characters that match and our display is 25 characters. We could then say that the min prefix length is 8 characters and the "..." is 3 characters. This results in the suffix being 14 characters. This would then result in something like this.

$ konf set
Use the arrow keys to navigate: ↓ ↑ → ←  and / toggles search
?   Context                   | Cluster                   | File                      :
  ▸ arn:aws:...-east-1:116abc | arn:aws:eks:us-east-1:116 | /home/eric/.kube/konfs/st |
    arn:aws:...-east-1:223xyz | arn:aws:eks:us-east-1:223 | /home/eric/.kube/konfs/st |

b) We could make the length of the columns configurable
I think this could make a lot of sense, so any user can choose the width that suits them best. I would need to build a config-file mechanism to make this work, but I think that is only a matter of time until config file is needed.

c) Shorten the output of the File column
We could possibly change the display to just say $KONFDIR. This would result in something like this

$ konf set
Use the arrow keys to navigate: ↓ ↑ → ←  and / toggles search
?   Context                   | Cluster                   | File                      :
  ▸ arn:aws:eks:us-east-1:116 | arn:aws:eks:us-east-1:116 | $KONFDIR/store/<name> |
    arn:aws:eks:us-east-1:223 | arn:aws:eks:us-east-1:223 | $KONFDIR/store/<name> |

Just to share my thoughts for now, I have not decided what option to pursue.

@sourcedelica
Copy link

sourcedelica commented Apr 11, 2023

Some more data points - here's the full name of a few of my EKS contexts:

arn:aws:eks:us-east-1:483401968772:cluster/ifi-teamwork-bazel-dev
arn:aws:eks:us-east-1:841942792495:cluster/platform-eks-sharedsvcs-dev
arn:aws:eks:us-east-1:841942792495:cluster/ptt-shared-prodsla-use1-dev

Here's the filenames of those in ~/.kube/konfs/store: 😄

arn-aws-eks-us-east-1-116961059470-cluster-platform-eks-workshop_arn-aws-eks-us-east-1-116961059470-cluster-platform-eks-workshop.yaml
arn-aws-eks-us-east-1-841942792495-cluster-platform-eks-sharedsvcs-dev_arn-aws-eks-us-east-1-841942792495-cluster-platform-eks-sharedsvcs-dev.yaml
arn-aws-eks-us-east-1-841942792495-cluster-ptt-shared-prodsla-use1-dev_arn-aws-eks-us-east-1-841942792495-cluster-ptt-shared-prodsla-use1-dev.yaml

For a) would it check all pairs to see which ones have common prefixes? Seems complicated.

What would work best for me is the original idea in this issue where you could have an option to only select from the full context name. The chooser would be one long column.

?   Context:
  ▸ arn:aws:eks:us-east-1:483401968772:cluster/ifi-teamwork-bazel-dev
    arn:aws:eks:us-east-1:841942792495:cluster/platform-eks-sharedsvcs-dev
    arn:aws:eks:us-east-1:841942792495:cluster/ptt-shared-prodsla-use1-dev

Re: config file - for this one it would be nice if you could select it with an environment variable. That way I could keep the super friendly konf set as the command.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants