helper

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2024 License: MPL-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CombineBlock

func CombineBlock(blocks []*hclwrite.Block, output *hclwrite.Block, isForEach bool) map[string][]hclwrite.Tokens

CombineBlock combines `blocks` and update its result to `output` block, and return the difference in a map(key is attribute name, value is a list of attribute values)

func GetForEachConstants

func GetForEachConstants(instances []types.Instance, items map[string][]hclwrite.Tokens) string

GetForEachConstants converts a map of difference to hcl object

func GetIdPattern

func GetIdPattern(id string) (string, error)

func GetResourceBlock

func GetResourceBlock(workingDirectory, targetAddress string) (*hclwrite.Block, error)

GetResourceBlock searches tf files in working directory and return `targetAddress` block

func GetTokensForExpression

func GetTokensForExpression(expression string) hclwrite.Tokens

GetTokensForExpression convert a literal value to hclwrite.Tokens

func GetValueFromExpression

func GetValueFromExpression(tokens hclwrite.Tokens) interface{}

func GetValuePropMap

func GetValuePropMap(block *hclwrite.Block, prefix string) map[string]string

GetValuePropMap returns a map from literal value to reference

func InjectReference

func InjectReference(block *hclwrite.Block, refs []types.Reference) *hclwrite.Block

InjectReference replaces `block`'s literal value with reference provided by `refs`

func IsArrayWithSameValue

func IsArrayWithSameValue(arr []string) bool

IsArrayWithSameValue returns true if all elements in `arr` are identical

func ListHclFiles

func ListHclFiles(workingDirectory string) []fs.DirEntry

func ParseHclArray

func ParseHclArray(attrValue string) []string

ParseHclArray parse `attrValue` to an array, example `attrValue` `["a", "b", 0]` will return ["\"a\"", "\"b\"", "0"]

func Prefix

func Prefix(arr []string) string

Prefix returns the longest common prefix of all elements in `arr`

func ReplaceGenericOutputs

func ReplaceGenericOutputs(workingDirectory string, outputs []types.Output) error

ReplaceGenericOutputs searches tf files in working directory and replace generic resource's output with new address

func ReplaceResourceBlock

func ReplaceResourceBlock(workingDirectory, targetAddress string, newBlock *hclwrite.Block) error

ReplaceResourceBlock searches tf files in working directory and replace `targetAddress` block with `newBlock`

func Suffix

func Suffix(arr []string) string

Suffix returns the longest common suffix of all elements in `arr`

func ToHclSearchReplace

func ToHclSearchReplace(input interface{}, search []string, replacement []string) (string, bool)

ToHclSearchReplace generates hcl expression from `input`

func UpdateMigratedResourceBlock

func UpdateMigratedResourceBlock(workingDirectory string, resources []types.GenericUpdateResource) error

UpdateMigratedResourceBlock searches tf files in working directory and update generic patch resource's target

Types

This section is empty.

Jump to

Keyboard shortcuts

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