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

operator: add built-in 'Random' label templates #821

Merged
merged 3 commits into from
Aug 13, 2024

Conversation

fgiudici
Copy link
Member

introduce built-in random templates:

  • ${Random/UUID}
  • ${Random/Hex/[0-32]}
  • ${Random/Int/[MAXINT]}

examples:
${Random/UUID} --> e512d5ca-a765-42f2-82b7-264f37ffb329 ${Random/Hex/12} --> e512d5caa765
${Random/Int/1000} --> 199

Fixes #802

@kkaempf kkaempf added this to the Micro6.1 milestone Aug 13, 2024
@github-actions github-actions bot added the area/operator operator related changes label Aug 13, 2024
introduce built-in random templates:
* ${Random/UUID}
* ${Random/Hex/[0-32]}
* ${Random/Int/[MAXINT]}

examples:
${Random/UUID}		--> e512d5ca-a765-42f2-82b7-264f37ffb329
${Random/Hex/12}	--> e512d5caa765
${Random/Int/1000}	--> 199

Signed-off-by: Francesco Giudici <francesco.giudici@suse.com>
Signed-off-by: Francesco Giudici <francesco.giudici@suse.com>
@fgiudici fgiudici marked this pull request as ready for review August 13, 2024 09:41
@fgiudici fgiudici requested a review from a team as a code owner August 13, 2024 09:41
@github-actions github-actions bot added the area/tests test related changes label Aug 13, 2024
Copy link
Contributor

@anmazzotti anmazzotti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good with a couple of minor comments.

I also wonder if this should replace the current behavior of m-$UUID or is that already part of the PR?

pkg/templater/random.go Outdated Show resolved Hide resolved
pkg/templater/templater.go Outdated Show resolved Hide resolved
@fgiudici
Copy link
Member Author

Looks good with a couple of minor comments.

I also wonder if this should replace the current behavior of m-$UUID or is that already part of the PR?

Well, m-$UUID is still the default machineName, but yes, we can now generate custom machine names, e.g.:
machineName: cattle${Random/Int/5}-${Random/Hex/8}
that would generate hostnames (and machineinventory names) with names like:
cattle0-02401844
cattle3-1823bf5a

@fgiudici fgiudici merged commit d8bcf74 into rancher:main Aug 13, 2024
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/operator operator related changes area/tests test related changes
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

[feature] Elemental Operator Labels: add $RANDOM labels to allow inserting random values in templated labels
3 participants