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

GenerateName like helper function for naming ephemeral resources #295

Open
shlokc9 opened this issue Aug 24, 2024 · 0 comments · May be fixed by #296
Open

GenerateName like helper function for naming ephemeral resources #295

shlokc9 opened this issue Aug 24, 2024 · 0 comments · May be fixed by #296
Labels
enhancement New feature or request go Pull requests that update Go code good first issue Good for newcomers help wanted Extra attention is needed

Comments

@shlokc9
Copy link
Contributor

shlokc9 commented Aug 24, 2024

Description

In kubestr we create a number of ephemeral resources like Pods, PVCs, etc. that get cleaned up after the command execution. However, while naming these resources in code, developers generally append names of an existing resource to a hardcoded string. To associate the ephemeral resource with the existing resource.

Example

While writing a new command one might have to define a temporary PVC using an existing PVC named application-persistent-volume-claim. And if the hardcoded string defined here is ephemeral-persistent-volume-claim the resultant temporary PVC could be named ephemeral-persistent-volume-claim-for-application-persistent-volume-claim.

Problem

This temporary PVC name is 73 characters long and it is not considered a good practice to have string names with more than 64 characters.

Proposed Changes

This could be resolved with a helper function that hashes names longer than 64 characters and then replaces the last 5 characters of the 64 character name with the first 5 characters (base 64) of the hash. Developers can then call this helper function to shorten the names of the ephemeral resources they create.

As part of this issue, please also make sure to update the names of ephemeral resources for all existing commands. By calling the new helper function instead of passing a string name.

@shlokc9 shlokc9 added enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed go Pull requests that update Go code labels Aug 24, 2024
myrachanto added a commit to myrachanto/kubestr that referenced this issue Aug 24, 2024
…f it exceeds maxResourceNameLength of 64
@myrachanto myrachanto linked a pull request Aug 24, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request go Pull requests that update Go code good first issue Good for newcomers help wanted Extra attention is needed
Development

Successfully merging a pull request may close this issue.

1 participant