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 ¶
DecorateWithMultilineHandlingFunctions adds necessary functions to escape multiline fields in exported terraform files.
func EscapeName ¶
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 ¶
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 IsMultiline ¶
IsMultiline returns true if the input string contains at least one new line character
func NoNewlineAtTheEnd ¶
NoNewlineAtTheEnd returns true if there is no new line character at the end of the string
func RemoveLastNewline ¶
RemoveLastNewline removes the new line character if this is the last character in the string
func TerraformName ¶
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 ¶
ToJSON returns a JSON representation of the given object USAGE EXAMPLE: "bypassNetworkLists": {{ tojson .BypassNetworkLists }},
func ToList ¶
ToList returns a list as a comma-delimited string USAGE EXAMPLE: security_policy_ids = [ {{ tolist .Siem.FirewallPolicyIDs }} ]
func ToSnakeCase ¶
ToSnakeCase returns name using snake case notation - SomeName -> some_name
Types ¶
This section is empty.