github.com/hashicorp/hcl/v2@v2.20.0/ext/userfunc/README.md (about) 1 # HCL User Functions Extension 2 3 This HCL extension allows a calling application to support user-defined 4 functions. 5 6 Functions are defined via a specific block type, like this: 7 8 ```hcl 9 function "add" { 10 params = [a, b] 11 result = a + b 12 } 13 14 function "list" { 15 params = [] 16 variadic_param = items 17 result = items 18 } 19 ``` 20 21 The extension is implemented as a pre-processor for `cty.Body` objects. Given 22 a body that may contain functions, the `DecodeUserFunctions` function searches 23 for blocks that define functions and returns a functions map suitable for 24 inclusion in a `hcl.EvalContext`. It also returns a new `cty.Body` that 25 contains the remainder of the content from the given body, allowing for 26 further processing of remaining content. 27 28 For more information, see [the godoc reference](https://pkg.go.dev/github.com/hashicorp/hcl/v2/ext/userfunc?tab=doc).