hcl/ext/userfunc
Martin Atkins 6c4344623b Unfold the "hcl" directory up into the root
The main HCL package is more visible this way, and so it's easier than
having to pick it out from dozens of other package directories.
2019-09-09 16:08:19 -07:00
..
README.md Change module path to github.com/hashicorp/hcl/v2 2019-09-09 15:46:40 -07:00
decode.go Unfold the "hcl" directory up into the root 2019-09-09 16:08:19 -07:00
decode_test.go Unfold the "hcl" directory up into the root 2019-09-09 16:08:19 -07:00
doc.go Update doc comments and readmes for zcl -> HCL. 2017-09-11 16:56:31 -07:00
public.go Unfold the "hcl" directory up into the root 2019-09-09 16:08:19 -07:00

README.md

HCL User Functions Extension

This HCL extension allows a calling application to support user-defined functions.

Functions are defined via a specific block type, like this:

function "add" {
  params = [a, b]
  result = a + b
}

function "list" {
  params         = []
  variadic_param = items
  result         = items
}

The extension is implemented as a pre-processor for cty.Body objects. Given a body that may contain functions, the DecodeUserFunctions function searches for blocks that define functions and returns a functions map suitable for inclusion in a hcl.EvalContext. It also returns a new cty.Body that contains the remainder of the content from the given body, allowing for further processing of remaining content.

For more information, see the godoc reference.