tools

package
v2.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 5, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package tools contains various functions to help with processing of the templates

Index

Constants

This section is empty.

Variables

View Source
var PolicyAsHCL bool

PolicyAsHCL means that content of the policy will be generated using HCL instead of JSON file

Functions

func CheckFiles

func CheckFiles(files ...string) error

CheckFiles verifies if all given files doesn't exist in filesystem

func CreateTFFilename

func CreateTFFilename(resourceName string, tfWorkPath string) string

CreateTFFilename creates full tf file path

func DecorateWithMultilineHandlingFunctions

func DecorateWithMultilineHandlingFunctions(additionalFuncs map[string]any) template.FuncMap

DecorateWithMultilineHandlingFunctions adds necessary functions to escape multiline fields in exported terraform files.

func Escape

func Escape(str string) string

Escape is correcting values stored in terraform fields by escaping special characters

func EscapeName

func EscapeName(s string) (string, error)

EscapeName takes a string and makes it suitable for a tf resource instance name USAGE EXAMPLE: resource "akamai_appsec_waf_mode" "{{ escapename $policyName }}" {

func Float64Ptr

func Float64Ptr(f float64) *float64

Float64Ptr returns the address of the float64

func GetEOT

func GetEOT(str string) string

GetEOT generates unique delimiter word for heredoc, by default it is EOT

func Int64Ptr

func Int64Ptr(i int64) *int64

Int64Ptr returns the address of the int64

func IntPtr

func IntPtr(i int) *int

IntPtr returns the address of the int

func IsMultiline

func IsMultiline(str string) bool

IsMultiline returns true if the input string contains at least one new line character

func NoNewlineAtTheEnd

func NoNewlineAtTheEnd(str string) bool

NoNewlineAtTheEnd returns true if there is no new line character at the end of the string

func RemoveLastNewline

func RemoveLastNewline(str string) string

RemoveLastNewline removes the new line character if this is the last character in the string

func StringPtr

func StringPtr(s string) *string

StringPtr returns the address of the string

func TerraformName

func TerraformName(str string) string

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

func ToJSON(o interface{}) (string, error)

ToJSON returns a JSON representation of the given object USAGE EXAMPLE: "bypassNetworkLists": {{ tojson .BypassNetworkLists }},

func ToList

func ToList(l []string) string

ToList returns a list as a comma-delimited string USAGE EXAMPLE: security_policy_ids = [ {{ tolist .Siem.FirewallPolicyIDs }} ]

func ToSnakeCase

func ToSnakeCase(str string) string

ToSnakeCase returns name using snake case notation - SomeName -> some_name

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL