-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstdlib.go
56 lines (50 loc) · 1.53 KB
/
stdlib.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
package tfvars_parser
import (
hcl "github.com/hashicorp/hcl/v2"
"github.com/zclconf/go-cty/cty/function"
"github.com/zclconf/go-cty/cty/function/stdlib"
)
// a subset of functions used in terraform
// that can be used when simplifying during conversion
var evalContext = hcl.EvalContext{
Functions: map[string]function.Function{
// numeric
"abs": stdlib.AbsoluteFunc,
"ceil": stdlib.CeilFunc,
"floor": stdlib.FloorFunc,
"log": stdlib.LogFunc,
"max": stdlib.MaxFunc,
"min": stdlib.MinFunc,
"parseint": stdlib.ParseIntFunc,
"pow": stdlib.PowFunc,
"signum": stdlib.SignumFunc,
// string
"chomp": stdlib.ChompFunc,
"format": stdlib.FormatFunc,
"formatlist": stdlib.FormatListFunc,
"indent": stdlib.IndentFunc,
"join": stdlib.JoinFunc,
"split": stdlib.SplitFunc,
"strrev": stdlib.ReverseFunc,
"trim": stdlib.TrimFunc,
"trimprefix": stdlib.TrimPrefixFunc,
"trimsuffix": stdlib.TrimSuffixFunc,
"trimspace": stdlib.TrimSpaceFunc,
// collections
"chunklist": stdlib.ChunklistFunc,
"concat": stdlib.ConcatFunc,
"distinct": stdlib.DistinctFunc,
"flatten": stdlib.FlattenFunc,
"length": stdlib.LengthFunc,
"merge": stdlib.MergeFunc,
"reverse": stdlib.ReverseListFunc,
"sort": stdlib.SortFunc,
// encoding
"csvdecode": stdlib.CSVDecodeFunc,
"jsondecode": stdlib.JSONDecodeFunc,
"jsonencode": stdlib.JSONEncodeFunc,
// time
"formatdate": stdlib.FormatDateFunc,
"timeadd": stdlib.TimeAddFunc,
},
}