Documentation ¶
Overview ¶
Package tools contains various functions to help with processing of the templates
Index ¶
- Variables
- func CheckFiles(files ...string) error
- func CreateTFFilename(resourceName string, tfWorkPath string) string
- func DecorateWithMultilineHandlingFunctions(additionalFuncs map[string]any) template.FuncMap
- func Escape(str string) string
- func EscapeName(s string) (string, error)
- func EscapeQuotedStringLit(s string) string
- func Float64Ptr(f float64) *float64
- func GetEOT(str string) string
- func Int64Ptr(i int64) *int64
- func IntPtr(i int) *int
- func IsMultiline(str string) bool
- func NoNewlineAtTheEnd(str string) bool
- func RemoveLastNewline(str string) string
- func StringPtr(s string) *string
- func TerraformName(str string) string
- func ToJSON(o interface{}) (string, error)
- func ToList(l []string) string
- func ToSnakeCase(str string) string
Constants ¶
This section is empty.
Variables ¶
var PolicyAsHCL bool
PolicyAsHCL means that content of the policy will be generated using HCL instead of JSON file
Functions ¶
func CheckFiles ¶
CheckFiles verifies if all given files doesn't exist in filesystem
func CreateTFFilename ¶
CreateTFFilename creates full tf file path
func DecorateWithMultilineHandlingFunctions ¶ added in v1.10.0
DecorateWithMultilineHandlingFunctions adds necessary functions to escape multiline fields in exported terraform files.
func Escape ¶ added in v1.5.0
Escape is correcting values stored in terraform fields by escaping special characters
func EscapeName ¶ added in v0.9.0
EscapeName takes a string and makes it suitable for a tf resource instance name USAGE EXAMPLE: resource "akamai_appsec_waf_mode" "{{ escapename $policyName }}" {
func EscapeQuotedStringLit ¶ added in v0.9.0
EscapeQuotedStringLit returns escaped terraform string literal https://www.terraform.io/docs/language/expressions/strings.html#escape-sequences This function is based on https://github.com/hashicorp/hcl/blob/c7ee8b78101c33b4dfed2641d78cf5e9651eabb8/hclwrite/generate.go#L207-L246
func GetEOT ¶ added in v1.10.0
GetEOT generates unique delimiter word for heredoc, by default it is EOT
func IsMultiline ¶ added in v1.10.0
IsMultiline returns true if the input string contains at least one new line character
func NoNewlineAtTheEnd ¶ added in v1.10.0
NoNewlineAtTheEnd returns true if there is no new line character at the end of the string
func RemoveLastNewline ¶ added in v1.10.0
RemoveLastNewline removes the new line character if this is the last character in the string
func TerraformName ¶ added in v1.16.0
TerraformName is used to convert rule name into valid name of the exported data source Current implementation is not covering all the cases defined in the terraform specification https://github.com/hashicorp/hcl/blob/main/hclsyntax/spec.md#identifiers and http://unicode.org/reports/tr31/ , but only a reasonable subset.
func ToJSON ¶ added in v0.9.0
ToJSON returns a JSON representation of the given object USAGE EXAMPLE: "bypassNetworkLists": {{ tojson .BypassNetworkLists }},
func ToList ¶ added in v0.9.0
ToList returns a list as a comma delimited string USAGE EXAMPLE: security_policy_ids = [ {{ tolist .Siem.FirewallPolicyIds }} ]
func ToSnakeCase ¶ added in v1.16.0
ToSnakeCase returns name using snake case notation - SomeName -> some_name
Types ¶
This section is empty.