package
0.0.0-20191002203319-fb75b3253c80
Repository: https://github.com/hashicorp/hcl2.git
Documentation: pkg.go.dev

# README

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.

# Functions

DecodeUserFunctions looks for blocks of the given type in the given body and, for each one found, interprets it as a custom function definition.

# Type aliases

A ContextFunc is a callback used to produce the base EvalContext for running a particular set of functions.