package terraform

import (
	"github.com/hashicorp/terraform/lang/funcs"
	"github.com/zclconf/go-cty/cty/function"
	"github.com/zclconf/go-cty/cty/function/stdlib"
)

// Functions is
func Functions(baseDir string) map[string]function.Function {
	return map[string]function.Function{
		"abs":          stdlib.AbsoluteFunc,
		"basename":     funcs.BasenameFunc,
		"base64decode": funcs.Base64DecodeFunc,
		"base64encode": funcs.Base64EncodeFunc,
		"base64gzip":   funcs.Base64GzipFunc,
		"base64sha256": funcs.Base64Sha256Func,
		"base64sha512": funcs.Base64Sha512Func,
		"bcrypt":       funcs.BcryptFunc,
		"ceil":         funcs.CeilFunc,
		"chomp":        funcs.ChompFunc,
		"cidrhost":     funcs.CidrHostFunc,
		"cidrnetmask":  funcs.CidrNetmaskFunc,
		"cidrsubnet":   funcs.CidrSubnetFunc,
		"coalesce":     stdlib.CoalesceFunc,
		"coalescelist": funcs.CoalesceListFunc,
		"compact":      funcs.CompactFunc,
		"concat":       stdlib.ConcatFunc,
		"contains":     funcs.ContainsFunc,
		"csvdecode":    stdlib.CSVDecodeFunc,
		"dirname":      funcs.DirnameFunc,
		"distinct":     funcs.DistinctFunc,
		"element":      funcs.ElementFunc,
		"chunklist":    funcs.ChunklistFunc,
		"file":         funcs.MakeFileFunc(baseDir, false),
		"fileexists":   funcs.MakeFileExistsFunc(baseDir),
		"filebase64":   funcs.MakeFileFunc(baseDir, true),
		"flatten":      funcs.FlattenFunc,
		"floor":        funcs.FloorFunc,
		"format":       stdlib.FormatFunc,
		"formatlist":   stdlib.FormatListFunc,
		"indent":       funcs.IndentFunc,
		"index":        funcs.IndexFunc,
		"join":         funcs.JoinFunc,
		"jsondecode":   stdlib.JSONDecodeFunc,
		"jsonencode":   stdlib.JSONEncodeFunc,
		"keys":         funcs.KeysFunc,
		"length":       funcs.LengthFunc,
		"list":         funcs.ListFunc,
		"log":          funcs.LogFunc,
		"lookup":       funcs.LookupFunc,
		"lower":        stdlib.LowerFunc,
		"map":          funcs.MapFunc,
		"matchkeys":    funcs.MatchkeysFunc,
		"max":          stdlib.MaxFunc,
		"md5":          funcs.Md5Func,
		"merge":        funcs.MergeFunc,
		"min":          stdlib.MinFunc,
		"pathexpand":   funcs.PathExpandFunc,
		"pow":          funcs.PowFunc,
		"replace":      funcs.ReplaceFunc,
		"rsadecrypt":   funcs.RsaDecryptFunc,
		"sha1":         funcs.Sha1Func,
		"sha256":       funcs.Sha256Func,
		"sha512":       funcs.Sha512Func,
		"signum":       funcs.SignumFunc,
		"slice":        funcs.SliceFunc,
		"sort":         funcs.SortFunc,
		"split":        funcs.SplitFunc,
		"substr":       stdlib.SubstrFunc,
		"timestamp":    funcs.TimestampFunc,
		"timeadd":      funcs.TimeAddFunc,
		"title":        funcs.TitleFunc,
		"transpose":    funcs.TransposeFunc,
		"trimspace":    funcs.TrimSpaceFunc,
		"upper":        stdlib.UpperFunc,
		"urlencode":    funcs.URLEncodeFunc,
		"uuid":         funcs.UUIDFunc,
		"values":       funcs.ValuesFunc,
		"zipmap":       funcs.ZipmapFunc,
	}
}
