github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/website/content/docs/job-specification/hcl2/functions/uuid/uuidv5.mdx (about)

     1  ---
     2  layout: docs
     3  page_title: uuidv5 - Functions - Configuration Language
     4  description: |-
     5    The uuidv5 function generates a uuid v5 string representation of the value in
     6    the specified namespace.
     7  ---
     8  
     9  # `uuidv5` Function
    10  
    11  `uuidv5` generates a _name-based_ UUID, as described in [RFC 4122 section
    12  4.3](https://tools.ietf.org/html/rfc4122#section-4.3), also known as a "version
    13  5" UUID.
    14  
    15  ```hcl
    16  uuidv5(namespace, name)
    17  ```
    18  
    19  Unlike the pseudo-random UUIDs generated by [`uuidv4`](/docs/job-specification/hcl2/functions/uuid/uuidv4),
    20  name-based UUIDs derive from namespace and an name, producing the same UUID
    21  value every time if the namespace and name are unchanged.
    22  
    23  Name-based UUID namespaces are themselves UUIDs, but for readability this
    24  function accepts some keywords as aliases for the namespaces that were assigned
    25  by RFC 4122:
    26  
    27  | Keyword  | Namespace ID                           | Name format                                                                  |
    28  | -------- | -------------------------------------- | ---------------------------------------------------------------------------- |
    29  | `"dns"`  | `6ba7b810-9dad-11d1-80b4-00c04fd430c8` | A fully-qualified DNS domain name.                                           |
    30  | `"url"`  | `6ba7b811-9dad-11d1-80b4-00c04fd430c8` | Any valid URL as defined in [RFC 3986](https://tools.ietf.org/html/rfc3986). |
    31  | `"oid"`  | `6ba7b812-9dad-11d1-80b4-00c04fd430c8` | An [ISO/IEC object identifier](https://oidref.com/)                          |
    32  | `"x500"` | `6ba7b814-9dad-11d1-80b4-00c04fd430c8` | [X.500 Distinguished Name](https://tools.ietf.org/html/rfc1779)              |
    33  
    34  To use any other namespace not included in the above table, pass its assigned
    35  namespace ID directly in the first argument in the usual UUID string format.
    36  
    37  ## Examples
    38  
    39  Use the namespace keywords where possible, to make the intent more obvious to
    40  a future reader:
    41  
    42  ```shell-session
    43  > uuidv5("dns", "nomadproject.io")
    44  d2616d48-e1cb-5b87-8a8c-46355decc76a
    45  
    46  > uuidv5("url", "https://nomadproject.io/")
    47  a1572394-3948-5251-b0c7-b4ded43587b4
    48  
    49  > uuidv5("oid", "1.3.6.1.4")
    50  af9d40a5-7a36-5c07-b23a-851cd99fbfa5
    51  
    52  > uuidv5("x500", "CN=Example,C=GB")
    53  84e09961-4aa4-57f8-95b7-03edb1073253
    54  ```
    55  
    56  The namespace keywords treated as equivalent to their corresponding namespace
    57  UUIDs, and in some special cases it may be more appropriate to use the
    58  UUID form:
    59  
    60  ```shell-session
    61  > uuidv5("6ba7b810-9dad-11d1-80b4-00c04fd430c8", "nomadproject.io")
    62  d2616d48-e1cb-5b87-8a8c-46355decc76a
    63  ```
    64  
    65  If you wish to use a namespace defined outside of RFC 4122, using the namespace
    66  UUID is required because no corresponding keyword is available:
    67  
    68  ```shell-session
    69  > uuidv5("743ac3c0-3bf7-4a5b-9e6c-59360447c757", "LIBS:diskfont.library")
    70  ede1a974-df7e-5f17-84b9-76208818b2c8
    71  ```
    72  
    73  When using raw UUID namespaces, consider including a comment alongside the
    74  expression that indicates which namespace this represents in a
    75  human-significant manner, such as by reference to the standard that defined it.
    76  
    77  ## Related Functions
    78  
    79  - [`uuidv4`](/docs/job-specification/hcl2/functions/uuid/uuidv4), which generates pseudorandom UUIDs.