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