github.com/terramate-io/tf@v0.0.0-20230830114523-fce866b4dfcd/lang/funcs/descriptions.go (about)

     1  // Copyright (c) HashiCorp, Inc.
     2  // SPDX-License-Identifier: MPL-2.0
     3  
     4  package funcs
     5  
     6  import "github.com/zclconf/go-cty/cty/function"
     7  
     8  type descriptionEntry struct {
     9  	// Description is a description for the function.
    10  	Description string
    11  
    12  	// ParamDescription argument must match the number of parameters of the
    13  	// function. If the function has a VarParam then that counts as one
    14  	// parameter. The given descriptions will be assigned in order starting
    15  	// with the positional arguments in their declared order, followed by the
    16  	// variadic parameter if any.
    17  	ParamDescription []string
    18  }
    19  
    20  // DescriptionList is a consolidated list containing all descriptions for all
    21  // functions available within Terraform. A function's description should point
    22  // to the matching entry in this list.
    23  //
    24  // We keep this as a single list, so we can quickly review descriptions within
    25  // a single file and copy the whole list to other projects, like
    26  // terraform-schema.
    27  var DescriptionList = map[string]descriptionEntry{
    28  	"abs": {
    29  		Description:      "`abs` returns the absolute value of the given number. In other words, if the number is zero or positive then it is returned as-is, but if it is negative then it is multiplied by -1 to make it positive before returning it.",
    30  		ParamDescription: []string{""},
    31  	},
    32  	"abspath": {
    33  		Description:      "`abspath` takes a string containing a filesystem path and converts it to an absolute path. That is, if the path is not absolute, it will be joined with the current working directory.",
    34  		ParamDescription: []string{""},
    35  	},
    36  	"alltrue": {
    37  		Description:      "`alltrue` returns `true` if all elements in a given collection are `true` or `\"true\"`. It also returns `true` if the collection is empty.",
    38  		ParamDescription: []string{""},
    39  	},
    40  	"anytrue": {
    41  		Description:      "`anytrue` returns `true` if any element in a given collection is `true` or `\"true\"`. It also returns `false` if the collection is empty.",
    42  		ParamDescription: []string{""},
    43  	},
    44  	"base64decode": {
    45  		Description:      "`base64decode` takes a string containing a Base64 character sequence and returns the original string.",
    46  		ParamDescription: []string{""},
    47  	},
    48  	"base64encode": {
    49  		Description:      "`base64encode` applies Base64 encoding to a string.",
    50  		ParamDescription: []string{""},
    51  	},
    52  	"base64gzip": {
    53  		Description:      "`base64gzip` compresses a string with gzip and then encodes the result in Base64 encoding.",
    54  		ParamDescription: []string{""},
    55  	},
    56  	"base64sha256": {
    57  		Description:      "`base64sha256` computes the SHA256 hash of a given string and encodes it with Base64. This is not equivalent to `base64encode(sha256(\"test\"))` since `sha256()` returns hexadecimal representation.",
    58  		ParamDescription: []string{""},
    59  	},
    60  	"base64sha512": {
    61  		Description:      "`base64sha512` computes the SHA512 hash of a given string and encodes it with Base64. This is not equivalent to `base64encode(sha512(\"test\"))` since `sha512()` returns hexadecimal representation.",
    62  		ParamDescription: []string{""},
    63  	},
    64  	"basename": {
    65  		Description:      "`basename` takes a string containing a filesystem path and removes all except the last portion from it.",
    66  		ParamDescription: []string{""},
    67  	},
    68  	"bcrypt": {
    69  		Description: "`bcrypt` computes a hash of the given string using the Blowfish cipher, returning a string in [the _Modular Crypt Format_](https://passlib.readthedocs.io/en/stable/modular_crypt_format.html) usually expected in the shadow password file on many Unix systems.",
    70  		ParamDescription: []string{
    71  			"",
    72  			"The `cost` argument is optional and will default to 10 if unspecified.",
    73  		},
    74  	},
    75  	"can": {
    76  		Description:      "`can` evaluates the given expression and returns a boolean value indicating whether the expression produced a result without any errors.",
    77  		ParamDescription: []string{""},
    78  	},
    79  	"ceil": {
    80  		Description:      "`ceil` returns the closest whole number that is greater than or equal to the given value, which may be a fraction.",
    81  		ParamDescription: []string{""},
    82  	},
    83  	"chomp": {
    84  		Description:      "`chomp` removes newline characters at the end of a string.",
    85  		ParamDescription: []string{""},
    86  	},
    87  	"chunklist": {
    88  		Description: "`chunklist` splits a single list into fixed-size chunks, returning a list of lists.",
    89  		ParamDescription: []string{
    90  			"",
    91  			"The maximum length of each chunk. All but the last element of the result is guaranteed to be of exactly this size.",
    92  		},
    93  	},
    94  	"cidrhost": {
    95  		Description: "`cidrhost` calculates a full host IP address for a given host number within a given IP network address prefix.",
    96  		ParamDescription: []string{
    97  			"`prefix` must be given in CIDR notation, as defined in [RFC 4632 section 3.1](https://tools.ietf.org/html/rfc4632#section-3.1).",
    98  			"`hostnum` is a whole number that can be represented as a binary integer with no more than the number of digits remaining in the address after the given prefix.",
    99  		},
   100  	},
   101  	"cidrnetmask": {
   102  		Description: "`cidrnetmask` converts an IPv4 address prefix given in CIDR notation into a subnet mask address.",
   103  		ParamDescription: []string{
   104  			"`prefix` must be given in CIDR notation, as defined in [RFC 4632 section 3.1](https://tools.ietf.org/html/rfc4632#section-3.1).",
   105  		},
   106  	},
   107  	"cidrsubnet": {
   108  		Description: "`cidrsubnet` calculates a subnet address within given IP network address prefix.",
   109  		ParamDescription: []string{
   110  			"`prefix` must be given in CIDR notation, as defined in [RFC 4632 section 3.1](https://tools.ietf.org/html/rfc4632#section-3.1).",
   111  			"`newbits` is the number of additional bits with which to extend the prefix.",
   112  			"`netnum` is a whole number that can be represented as a binary integer with no more than `newbits` binary digits, which will be used to populate the additional bits added to the prefix."},
   113  	},
   114  	"cidrsubnets": {
   115  		Description: "`cidrsubnets` calculates a sequence of consecutive IP address ranges within a particular CIDR prefix.",
   116  		ParamDescription: []string{
   117  			"`prefix` must be given in CIDR notation, as defined in [RFC 4632 section 3.1](https://tools.ietf.org/html/rfc4632#section-3.1).",
   118  			"",
   119  		},
   120  	},
   121  	"coalesce": {
   122  		Description:      "`coalesce` takes any number of arguments and returns the first one that isn't null or an empty string.",
   123  		ParamDescription: []string{""},
   124  	},
   125  	"coalescelist": {
   126  		Description: "`coalescelist` takes any number of list arguments and returns the first one that isn't empty.",
   127  		ParamDescription: []string{
   128  			"List or tuple values to test in the given order.",
   129  		},
   130  	},
   131  	"compact": {
   132  		Description:      "`compact` takes a list of strings and returns a new list with any empty string elements removed.",
   133  		ParamDescription: []string{""},
   134  	},
   135  	"concat": {
   136  		Description:      "`concat` takes two or more lists and combines them into a single list.",
   137  		ParamDescription: []string{""},
   138  	},
   139  	"contains": {
   140  		Description:      "`contains` determines whether a given list or set contains a given single value as one of its elements.",
   141  		ParamDescription: []string{"", ""},
   142  	},
   143  	"csvdecode": {
   144  		Description:      "`csvdecode` decodes a string containing CSV-formatted data and produces a list of maps representing that data.",
   145  		ParamDescription: []string{""},
   146  	},
   147  	"dirname": {
   148  		Description:      "`dirname` takes a string containing a filesystem path and removes the last portion from it.",
   149  		ParamDescription: []string{""},
   150  	},
   151  	"distinct": {
   152  		Description:      "`distinct` takes a list and returns a new list with any duplicate elements removed.",
   153  		ParamDescription: []string{""},
   154  	},
   155  	"element": {
   156  		Description:      "`element` retrieves a single element from a list.",
   157  		ParamDescription: []string{"", ""},
   158  	},
   159  	"endswith": {
   160  		Description:      "`endswith` takes two values: a string to check and a suffix string. The function returns true if the first string ends with that exact suffix.",
   161  		ParamDescription: []string{"", ""},
   162  	},
   163  	"file": {
   164  		Description:      "`file` reads the contents of a file at the given path and returns them as a string.",
   165  		ParamDescription: []string{""},
   166  	},
   167  	"filebase64": {
   168  		Description:      "`filebase64` reads the contents of a file at the given path and returns them as a base64-encoded string.",
   169  		ParamDescription: []string{""},
   170  	},
   171  	"filebase64sha256": {
   172  		Description:      "`filebase64sha256` is a variant of `base64sha256` that hashes the contents of a given file rather than a literal string.",
   173  		ParamDescription: []string{""},
   174  	},
   175  	"filebase64sha512": {
   176  		Description:      "`filebase64sha512` is a variant of `base64sha512` that hashes the contents of a given file rather than a literal string.",
   177  		ParamDescription: []string{""},
   178  	},
   179  	"fileexists": {
   180  		Description:      "`fileexists` determines whether a file exists at a given path.",
   181  		ParamDescription: []string{""},
   182  	},
   183  	"filemd5": {
   184  		Description:      "`filemd5` is a variant of `md5` that hashes the contents of a given file rather than a literal string.",
   185  		ParamDescription: []string{""},
   186  	},
   187  	"fileset": {
   188  		Description:      "`fileset` enumerates a set of regular file names given a path and pattern. The path is automatically removed from the resulting set of file names and any result still containing path separators always returns forward slash (`/`) as the path separator for cross-system compatibility.",
   189  		ParamDescription: []string{"", ""},
   190  	},
   191  	"filesha1": {
   192  		Description:      "`filesha1` is a variant of `sha1` that hashes the contents of a given file rather than a literal string.",
   193  		ParamDescription: []string{""},
   194  	},
   195  	"filesha256": {
   196  		Description:      "`filesha256` is a variant of `sha256` that hashes the contents of a given file rather than a literal string.",
   197  		ParamDescription: []string{""},
   198  	},
   199  	"filesha512": {
   200  		Description:      "`filesha512` is a variant of `sha512` that hashes the contents of a given file rather than a literal string.",
   201  		ParamDescription: []string{""},
   202  	},
   203  	"flatten": {
   204  		Description:      "`flatten` takes a list and replaces any elements that are lists with a flattened sequence of the list contents.",
   205  		ParamDescription: []string{""},
   206  	},
   207  	"floor": {
   208  		Description:      "`floor` returns the closest whole number that is less than or equal to the given value, which may be a fraction.",
   209  		ParamDescription: []string{""},
   210  	},
   211  	"format": {
   212  		Description:      "The `format` function produces a string by formatting a number of other values according to a specification string. It is similar to the `printf` function in C, and other similar functions in other programming languages.",
   213  		ParamDescription: []string{"", ""},
   214  	},
   215  	"formatdate": {
   216  		Description:      "`formatdate` converts a timestamp into a different time format.",
   217  		ParamDescription: []string{"", ""},
   218  	},
   219  	"formatlist": {
   220  		Description:      "`formatlist` produces a list of strings by formatting a number of other values according to a specification string.",
   221  		ParamDescription: []string{"", ""},
   222  	},
   223  	"indent": {
   224  		Description: "`indent` adds a given number of spaces to the beginnings of all but the first line in a given multi-line string.",
   225  		ParamDescription: []string{
   226  			"Number of spaces to add after each newline character.",
   227  			"",
   228  		},
   229  	},
   230  	"index": {
   231  		Description:      "`index` finds the element index for a given value in a list.",
   232  		ParamDescription: []string{"", ""},
   233  	},
   234  	"join": {
   235  		Description: "`join` produces a string by concatenating together all elements of a given list of strings with the given delimiter.",
   236  		ParamDescription: []string{
   237  			"Delimiter to insert between the given strings.",
   238  			"One or more lists of strings to join.",
   239  		},
   240  	},
   241  	"jsondecode": {
   242  		Description:      "`jsondecode` interprets a given string as JSON, returning a representation of the result of decoding that string.",
   243  		ParamDescription: []string{""},
   244  	},
   245  	"jsonencode": {
   246  		Description:      "`jsonencode` encodes a given value to a string using JSON syntax.",
   247  		ParamDescription: []string{""},
   248  	},
   249  	"keys": {
   250  		Description: "`keys` takes a map and returns a list containing the keys from that map.",
   251  		ParamDescription: []string{
   252  			"The map to extract keys from. May instead be an object-typed value, in which case the result is a tuple of the object attributes.",
   253  		},
   254  	},
   255  	"length": {
   256  		Description:      "`length` determines the length of a given list, map, or string.",
   257  		ParamDescription: []string{""},
   258  	},
   259  	"list": {
   260  		Description:      "The `list` function is no longer available. Prior to Terraform v0.12 it was the only available syntax for writing a literal list inside an expression, but Terraform v0.12 introduced a new first-class syntax.",
   261  		ParamDescription: []string{""},
   262  	},
   263  	"log": {
   264  		Description:      "`log` returns the logarithm of a given number in a given base.",
   265  		ParamDescription: []string{"", ""},
   266  	},
   267  	"lookup": {
   268  		Description:      "`lookup` retrieves the value of a single element from a map, given its key. If the given key does not exist, the given default value is returned instead.",
   269  		ParamDescription: []string{"", "", ""},
   270  	},
   271  	"lower": {
   272  		Description:      "`lower` converts all cased letters in the given string to lowercase.",
   273  		ParamDescription: []string{""},
   274  	},
   275  	"map": {
   276  		Description:      "The `map` function is no longer available. Prior to Terraform v0.12 it was the only available syntax for writing a literal map inside an expression, but Terraform v0.12 introduced a new first-class syntax.",
   277  		ParamDescription: []string{""},
   278  	},
   279  	"matchkeys": {
   280  		Description:      "`matchkeys` constructs a new list by taking a subset of elements from one list whose indexes match the corresponding indexes of values in another list.",
   281  		ParamDescription: []string{"", "", ""},
   282  	},
   283  	"max": {
   284  		Description:      "`max` takes one or more numbers and returns the greatest number from the set.",
   285  		ParamDescription: []string{""},
   286  	},
   287  	"md5": {
   288  		Description:      "`md5` computes the MD5 hash of a given string and encodes it with hexadecimal digits.",
   289  		ParamDescription: []string{""},
   290  	},
   291  	"merge": {
   292  		Description:      "`merge` takes an arbitrary number of maps or objects, and returns a single map or object that contains a merged set of elements from all arguments.",
   293  		ParamDescription: []string{""},
   294  	},
   295  	"min": {
   296  		Description:      "`min` takes one or more numbers and returns the smallest number from the set.",
   297  		ParamDescription: []string{""},
   298  	},
   299  	"nonsensitive": {
   300  		Description:      "`nonsensitive` takes a sensitive value and returns a copy of that value with the sensitive marking removed, thereby exposing the sensitive value.",
   301  		ParamDescription: []string{""},
   302  	},
   303  	"one": {
   304  		Description:      "`one` takes a list, set, or tuple value with either zero or one elements. If the collection is empty, `one` returns `null`. Otherwise, `one` returns the first element. If there are two or more elements then `one` will return an error.",
   305  		ParamDescription: []string{""},
   306  	},
   307  	"parseint": {
   308  		Description:      "`parseint` parses the given string as a representation of an integer in the specified base and returns the resulting number. The base must be between 2 and 62 inclusive.",
   309  		ParamDescription: []string{"", ""},
   310  	},
   311  	"pathexpand": {
   312  		Description:      "`pathexpand` takes a filesystem path that might begin with a `~` segment, and if so it replaces that segment with the current user's home directory path.",
   313  		ParamDescription: []string{""},
   314  	},
   315  	"pow": {
   316  		Description:      "`pow` calculates an exponent, by raising its first argument to the power of the second argument.",
   317  		ParamDescription: []string{"", ""},
   318  	},
   319  	"range": {
   320  		Description:      "`range` generates a list of numbers using a start value, a limit value, and a step value.",
   321  		ParamDescription: []string{""},
   322  	},
   323  	"regex": {
   324  		Description:      "`regex` applies a [regular expression](https://en.wikipedia.org/wiki/Regular_expression) to a string and returns the matching substrings.",
   325  		ParamDescription: []string{"", ""},
   326  	},
   327  	"regexall": {
   328  		Description:      "`regexall` applies a [regular expression](https://en.wikipedia.org/wiki/Regular_expression) to a string and returns a list of all matches.",
   329  		ParamDescription: []string{"", ""},
   330  	},
   331  	"replace": {
   332  		Description:      "`replace` searches a given string for another given substring, and replaces each occurrence with a given replacement string.",
   333  		ParamDescription: []string{"", "", ""},
   334  	},
   335  	"reverse": {
   336  		Description:      "`reverse` takes a sequence and produces a new sequence of the same length with all of the same elements as the given sequence but in reverse order.",
   337  		ParamDescription: []string{""},
   338  	},
   339  	"rsadecrypt": {
   340  		Description:      "`rsadecrypt` decrypts an RSA-encrypted ciphertext, returning the corresponding cleartext.",
   341  		ParamDescription: []string{"", ""},
   342  	},
   343  	"sensitive": {
   344  		Description:      "`sensitive` takes any value and returns a copy of it marked so that Terraform will treat it as sensitive, with the same meaning and behavior as for [sensitive input variables](/language/values/variables#suppressing-values-in-cli-output).",
   345  		ParamDescription: []string{""},
   346  	},
   347  	"setintersection": {
   348  		Description:      "The `setintersection` function takes multiple sets and produces a single set containing only the elements that all of the given sets have in common. In other words, it computes the [intersection](https://en.wikipedia.org/wiki/Intersection_\\(set_theory\\)) of the sets.",
   349  		ParamDescription: []string{"", ""},
   350  	},
   351  	"setproduct": {
   352  		Description: "The `setproduct` function finds all of the possible combinations of elements from all of the given sets by computing the [Cartesian product](https://en.wikipedia.org/wiki/Cartesian_product).",
   353  		ParamDescription: []string{
   354  			"The sets to consider. Also accepts lists and tuples, and if all arguments are of list or tuple type then the result will preserve the input ordering",
   355  		},
   356  	},
   357  	"setsubtract": {
   358  		Description:      "The `setsubtract` function returns a new set containing the elements from the first set that are not present in the second set. In other words, it computes the [relative complement](https://en.wikipedia.org/wiki/Complement_\\(set_theory\\)#Relative_complement) of the second set.",
   359  		ParamDescription: []string{"", ""},
   360  	},
   361  	"setunion": {
   362  		Description:      "The `setunion` function takes multiple sets and produces a single set containing the elements from all of the given sets. In other words, it computes the [union](https://en.wikipedia.org/wiki/Union_\\(set_theory\\)) of the sets.",
   363  		ParamDescription: []string{"", ""},
   364  	},
   365  	"sha1": {
   366  		Description:      "`sha1` computes the SHA1 hash of a given string and encodes it with hexadecimal digits.",
   367  		ParamDescription: []string{""},
   368  	},
   369  	"sha256": {
   370  		Description:      "`sha256` computes the SHA256 hash of a given string and encodes it with hexadecimal digits.",
   371  		ParamDescription: []string{""},
   372  	},
   373  	"sha512": {
   374  		Description:      "`sha512` computes the SHA512 hash of a given string and encodes it with hexadecimal digits.",
   375  		ParamDescription: []string{""},
   376  	},
   377  	"signum": {
   378  		Description:      "`signum` determines the sign of a number, returning a number between -1 and 1 to represent the sign.",
   379  		ParamDescription: []string{""},
   380  	},
   381  	"slice": {
   382  		Description:      "`slice` extracts some consecutive elements from within a list.",
   383  		ParamDescription: []string{"", "", ""},
   384  	},
   385  	"sort": {
   386  		Description:      "`sort` takes a list of strings and returns a new list with those strings sorted lexicographically.",
   387  		ParamDescription: []string{""},
   388  	},
   389  	"split": {
   390  		Description:      "`split` produces a list by dividing a given string at all occurrences of a given separator.",
   391  		ParamDescription: []string{"", ""},
   392  	},
   393  	"startswith": {
   394  		Description:      "`startswith` takes two values: a string to check and a prefix string. The function returns true if the string begins with that exact prefix.",
   395  		ParamDescription: []string{"", ""},
   396  	},
   397  	"strcontains": {
   398  		Description:      "`strcontains` takes two values: a string to check and an expected substring. The function returns true if the string has the substring contained within it.",
   399  		ParamDescription: []string{"", ""},
   400  	},
   401  	"strrev": {
   402  		Description:      "`strrev` reverses the characters in a string. Note that the characters are treated as _Unicode characters_ (in technical terms, Unicode [grapheme cluster boundaries](https://unicode.org/reports/tr29/#Grapheme_Cluster_Boundaries) are respected).",
   403  		ParamDescription: []string{""},
   404  	},
   405  	"substr": {
   406  		Description:      "`substr` extracts a substring from a given string by offset and (maximum) length.",
   407  		ParamDescription: []string{"", "", ""},
   408  	},
   409  	"sum": {
   410  		Description:      "`sum` takes a list or set of numbers and returns the sum of those numbers.",
   411  		ParamDescription: []string{""},
   412  	},
   413  	"templatefile": {
   414  		Description:      "`templatefile` reads the file at the given path and renders its content as a template using a supplied set of template variables.",
   415  		ParamDescription: []string{"", ""},
   416  	},
   417  	"textdecodebase64": {
   418  		Description:      "`textdecodebase64` function decodes a string that was previously Base64-encoded, and then interprets the result as characters in a specified character encoding.",
   419  		ParamDescription: []string{"", ""},
   420  	},
   421  	"textencodebase64": {
   422  		Description:      "`textencodebase64` encodes the unicode characters in a given string using a specified character encoding, returning the result base64 encoded because Terraform language strings are always sequences of unicode characters.",
   423  		ParamDescription: []string{"", ""},
   424  	},
   425  	"timeadd": {
   426  		Description:      "`timeadd` adds a duration to a timestamp, returning a new timestamp.",
   427  		ParamDescription: []string{"", ""},
   428  	},
   429  	"timecmp": {
   430  		Description:      "`timecmp` compares two timestamps and returns a number that represents the ordering of the instants those timestamps represent.",
   431  		ParamDescription: []string{"", ""},
   432  	},
   433  	"timestamp": {
   434  		Description:      "`timestamp` returns a UTC timestamp string in [RFC 3339](https://tools.ietf.org/html/rfc3339) format.",
   435  		ParamDescription: []string{},
   436  	},
   437  	"plantimestamp": {
   438  		Description:      "`plantimestamp` returns a UTC timestamp string in [RFC 3339](https://tools.ietf.org/html/rfc3339) format, fixed to a constant time representing the time of the plan.",
   439  		ParamDescription: []string{},
   440  	},
   441  	"title": {
   442  		Description:      "`title` converts the first letter of each word in the given string to uppercase.",
   443  		ParamDescription: []string{""},
   444  	},
   445  	"tobool": {
   446  		Description:      "`tobool` converts its argument to a boolean value.",
   447  		ParamDescription: []string{""},
   448  	},
   449  	"tolist": {
   450  		Description:      "`tolist` converts its argument to a list value.",
   451  		ParamDescription: []string{""},
   452  	},
   453  	"tomap": {
   454  		Description:      "`tomap` converts its argument to a map value.",
   455  		ParamDescription: []string{""},
   456  	},
   457  	"tonumber": {
   458  		Description:      "`tonumber` converts its argument to a number value.",
   459  		ParamDescription: []string{""},
   460  	},
   461  	"toset": {
   462  		Description:      "`toset` converts its argument to a set value.",
   463  		ParamDescription: []string{""},
   464  	},
   465  	"tostring": {
   466  		Description:      "`tostring` converts its argument to a string value.",
   467  		ParamDescription: []string{""},
   468  	},
   469  	"transpose": {
   470  		Description:      "`transpose` takes a map of lists of strings and swaps the keys and values to produce a new map of lists of strings.",
   471  		ParamDescription: []string{""},
   472  	},
   473  	"trim": {
   474  		Description: "`trim` removes the specified set of characters from the start and end of the given string.",
   475  		ParamDescription: []string{
   476  			"",
   477  			"A string containing all of the characters to trim. Each character is taken separately, so the order of characters is insignificant.",
   478  		},
   479  	},
   480  	"trimprefix": {
   481  		Description:      "`trimprefix` removes the specified prefix from the start of the given string. If the string does not start with the prefix, the string is returned unchanged.",
   482  		ParamDescription: []string{"", ""},
   483  	},
   484  	"trimspace": {
   485  		Description:      "`trimspace` removes any space characters from the start and end of the given string.",
   486  		ParamDescription: []string{""},
   487  	},
   488  	"trimsuffix": {
   489  		Description:      "`trimsuffix` removes the specified suffix from the end of the given string.",
   490  		ParamDescription: []string{"", ""},
   491  	},
   492  	"try": {
   493  		Description:      "`try` evaluates all of its argument expressions in turn and returns the result of the first one that does not produce any errors.",
   494  		ParamDescription: []string{""},
   495  	},
   496  	"type": {
   497  		Description:      "`type` returns the type of a given value.",
   498  		ParamDescription: []string{""},
   499  	},
   500  	"upper": {
   501  		Description:      "`upper` converts all cased letters in the given string to uppercase.",
   502  		ParamDescription: []string{""},
   503  	},
   504  	"urlencode": {
   505  		Description:      "`urlencode` applies URL encoding to a given string.",
   506  		ParamDescription: []string{""},
   507  	},
   508  	"uuid": {
   509  		Description:      "`uuid` generates a unique identifier string.",
   510  		ParamDescription: []string{},
   511  	},
   512  	"uuidv5": {
   513  		Description:      "`uuidv5` generates a _name-based_ UUID, as described in [RFC 4122 section 4.3](https://tools.ietf.org/html/rfc4122#section-4.3), also known as a \"version 5\" UUID.",
   514  		ParamDescription: []string{"", ""},
   515  	},
   516  	"values": {
   517  		Description:      "`values` takes a map and returns a list containing the values of the elements in that map.",
   518  		ParamDescription: []string{""},
   519  	},
   520  	"yamldecode": {
   521  		Description:      "`yamldecode` parses a string as a subset of YAML, and produces a representation of its value.",
   522  		ParamDescription: []string{""},
   523  	},
   524  	"yamlencode": {
   525  		Description:      "`yamlencode` encodes a given value to a string using [YAML 1.2](https://yaml.org/spec/1.2/spec.html) block syntax.",
   526  		ParamDescription: []string{""},
   527  	},
   528  	"zipmap": {
   529  		Description:      "`zipmap` constructs a map from a list of keys and a corresponding list of values.",
   530  		ParamDescription: []string{"", ""},
   531  	},
   532  }
   533  
   534  // WithDescription looks up the description for a given function and uses
   535  // go-cty's WithNewDescriptions to replace the function's description and
   536  // parameter descriptions.
   537  func WithDescription(name string, f function.Function) function.Function {
   538  	desc, ok := DescriptionList[name]
   539  	if !ok {
   540  		return f
   541  	}
   542  
   543  	// Will panic if ParamDescription doesn't match the number of parameters
   544  	// the function expects
   545  	return f.WithNewDescriptions(desc.Description, desc.ParamDescription)
   546  }