hcl/ext/userfunc
Martin Atkins 0dc3a6015c Rename the ancillary packages from "zcl" to "hcl".
The main "zcl" package requires a bit more care because of how many
callers it has and because of its two subpackages, so we'll take care
of that one separately.
2017-09-11 16:00:31 -07:00
..
decode_test.go Adjust import paths for hashicorp/hcl2 repo 2017-09-11 15:38:42 -07:00
decode.go Rename the ancillary packages from "zcl" to "hcl". 2017-09-11 16:00:31 -07:00
doc.go ext/userfunc: extension for user-defined functions 2017-07-25 18:34:56 -07:00
public.go Adjust import paths for hashicorp/hcl2 repo 2017-09-11 15:38:42 -07:00
README.md ext/userfunc: extension for user-defined functions 2017-07-25 18:34:56 -07:00

zcl User Functions Extension

This zcl 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
}

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 zcl.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.