-
Notifications
You must be signed in to change notification settings - Fork 581
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
(MODULES-4188) Add UUID generation function #700
Conversation
|
|
||
| $uuid = uuid_generate($::fqdn) | ||
|
|
||
| The seed is optional. If given it must be a string. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should mention if the seed should be numeric, hex, or an arbitrary string.
| seed = nil | ||
| fqdn = args[0] | ||
| elsif args.length == 2 | ||
| fqdn = args[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically it doesn't have to be an FQDN so it should be called input_string or something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this was a holdover from the older FQDN specific code
| end | ||
|
|
||
| # The UUID for our namespace (6ba7b810-9dad-11d1-80b4-00c04fd430c8) | ||
| ns_uuid = "\x0b\x7a\x81\xff\xdb\x8d\x42\xfe\x8d\x9f\x76\x8e\xa5\xb8\xed\x1a" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This UUID name space ID is only for prefixing FQDNs and as this is an "uuid_generate puppet function arbitrary string" UUID, we should create a new namespace specifically for this function (I imagine anything will do).
As per RFC-4122:
Allocate a UUID to use as a "name space ID" for all UUIDs generated from names in that name space; see Appendix C for some pre-defined values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I'm thinking of adding two functions: one for an arbitrary uuid from a string and seed, which would use our own custom namespace, one for the FQDN following RFC-4122. Sound good?
|
|
||
| hash_input = ns_uuid + fqdn | ||
| unless seed.nil? | ||
| hash_input += "\x00" + seed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the seed can be any string, why prefix with '\x00'?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TBH I'm not sure about this bit, I was leveraging an existing bit of code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would need to change here?
* Generates UUID based on a given FQDN string and the DNS namespace (6ba7b810-9dad-11d1-80b4-00c04fd430c8)
753f25a
to
0e684d8
Compare
optional seed