-
Notifications
You must be signed in to change notification settings - Fork 486
/
root_eval_context.go
76 lines (73 loc) · 2.83 KB
/
root_eval_context.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package flow
import (
"github.com/grafana/agent/pkg/flow/internal/funcs"
"github.com/hashicorp/hcl/v2"
"github.com/zclconf/go-cty/cty/function"
"github.com/zclconf/go-cty/cty/function/stdlib"
)
// rootEvalContext is a set of global variables and functions which will be
// available to all expressions in HCL.
//
// controller.Loader creates a child of this context which includes values for
// running components.
var rootEvalContext = &hcl.EvalContext{
// NOTE(rfratto): Terraform doesn't delimit multiple words in function names,
// but we use snake_case.
Functions: map[string]function.Function{
"abs": stdlib.AbsoluteFunc,
"ceil": stdlib.CeilFunc,
"chomp": stdlib.ChompFunc,
"coalesce_list": stdlib.CoalesceListFunc,
"compact": stdlib.CompactFunc,
"concat": stdlib.ConcatFunc,
"contains": stdlib.ContainsFunc,
"csv_decode": stdlib.CSVDecodeFunc,
"distinct": stdlib.DistinctFunc,
"element": stdlib.ElementFunc,
"env": funcs.EnvFunc,
"chunk_list": stdlib.ChunklistFunc,
"flatten": stdlib.FlattenFunc,
"floor": stdlib.FloorFunc,
"format": stdlib.FormatFunc,
"format_date": stdlib.FormatDateFunc,
"format_list": stdlib.FormatListFunc,
"indent": stdlib.IndentFunc,
// TODO(rfratto): stdlib's IndexFunc and Terraform's IndexFunc are
// incompatible; we probably want to emulate the latter to not surprise
// people.
"join": stdlib.JoinFunc,
"json_decode": stdlib.JSONDecodeFunc,
"json_encode": stdlib.JSONEncodeFunc,
"keys": stdlib.KeysFunc,
"log": stdlib.LogFunc,
"lower": stdlib.LowerFunc,
"max": stdlib.MaxFunc,
"merge": stdlib.MergeFunc,
"min": stdlib.MinFunc,
"parse_int": stdlib.ParseIntFunc,
"pow": stdlib.PowFunc,
"range": stdlib.RangeFunc,
"regex": stdlib.RegexFunc,
"regex_all": stdlib.RegexAllFunc,
"reverse": stdlib.ReverseListFunc,
"set_intersection": stdlib.SetIntersectionFunc,
"set_product": stdlib.SetProductFunc,
"set_subtract": stdlib.SetSubtractFunc,
"set_union": stdlib.SetUnionFunc,
"number_sign": stdlib.SignumFunc,
"slice": stdlib.SliceFunc,
"sort": stdlib.SortFunc,
"split": stdlib.SplitFunc,
"string_reverse": stdlib.ReverseFunc,
"substr": stdlib.SubstrFunc,
"time_add": stdlib.TimeAddFunc,
"title": stdlib.TitleFunc,
"trim": stdlib.TrimFunc,
"trim_prefix": stdlib.TrimPrefixFunc,
"trim_space": stdlib.TrimSpaceFunc,
"trim_suffix": stdlib.TrimSuffixFunc,
"upper": stdlib.UpperFunc,
"values": stdlib.ValuesFunc,
"zipmap": stdlib.ZipmapFunc,
},
}