hclhelpers

package
v0.1.0-beta.202309290512 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2023 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnySliceToTypedSlice

func AnySliceToTypedSlice(input any) any

AnySliceToTypedSlice determines whether input is []any and if so converts to an array of the underlying type

func AttributeToBool

func AttributeToBool(attr *hcl.Attribute, evalContext *hcl.EvalContext, allowExpression bool) (*bool, hcl.Diagnostics)

func AttributeToInt

func AttributeToInt(attr *hcl.Attribute, evalContext *hcl.EvalContext, allowExpression bool) (*int64, hcl.Diagnostics)

func AttributeToMap

func AttributeToMap(attr *hcl.Attribute, evalContext *hcl.EvalContext, allowExpression bool) (map[string]interface{}, hcl.Diagnostics)

func AttributeToString

func AttributeToString(attr *hcl.Attribute, evalContext *hcl.EvalContext, allowExpression bool) (*string, hcl.Diagnostics)

func BlocksToMap

func BlocksToMap(blocks hcl.Blocks) map[string]*hcl.Block

BlocksToMap convert an array of blocks to a map keyed by block laabel NOTE: this panics if any blocks do not have a label

func CoerceStringToGoBasedOnCtyType

func CoerceStringToGoBasedOnCtyType(input string, typ cty.Type) (interface{}, error)

func ConvertInterfaceToCtyValue

func ConvertInterfaceToCtyValue(v interface{}) (cty.Value, error)

func ConvertMapOrSliceToCtyValue

func ConvertMapOrSliceToCtyValue(data interface{}) (cty.Value, error)

func ConvertMapToCtyValue

func ConvertMapToCtyValue(v interface{}) (cty.Value, error)

func CtyToGo

func CtyToGo(v cty.Value) (val interface{}, err error)

func CtyToGoBoolSlice

func CtyToGoBoolSlice(v cty.Value) (val []bool, err error)

func CtyToGoInterfaceSlice

func CtyToGoInterfaceSlice(v cty.Value) (val []interface{}, err error)

func CtyToGoMapBool

func CtyToGoMapBool(v cty.Value) (map[string]bool, error)

func CtyToGoMapInterface

func CtyToGoMapInterface(v cty.Value) (map[string]interface{}, error)

func CtyToGoMapNumeric

func CtyToGoMapNumeric(v cty.Value) (map[string]float64, error)

func CtyToGoMapString

func CtyToGoMapString(v cty.Value) (map[string]string, error)

func CtyToGoNumericSlice

func CtyToGoNumericSlice(v cty.Value) (val []float64, err error)

func CtyToGoStringSlice

func CtyToGoStringSlice(v cty.Value) (val []string, err error)

func CtyToInt64

func CtyToInt64(val cty.Value) (*int64, hcl.Diagnostics)

func CtyToJSON

func CtyToJSON(val cty.Value) (string, error)

CtyToJSON converts a cty value to it;s JSON representation

func CtyToPostgresString

func CtyToPostgresString(v cty.Value) (valStr string, err error)

CtyToPostgresString convert a cty value into a postgres representation of the value

func CtyToString

func CtyToString(v cty.Value) (valStr string, err error)

CtyToString convert a cty value into a string representation of the value

func CtyTupleToArrayOfStrings

func CtyTupleToArrayOfStrings(val cty.Value) ([]string, error)

func CtyTypeToHclType

func CtyTypeToHclType(types ...cty.Type) string

CtyTypeToHclType converts a cty type to a hcl type accept multiple types and use the first non null and non dynamic one

func ExpressionToDepends

func ExpressionToDepends(expr hcl.Expression, validDependsOnTypes []string) ([]string, hcl.Diagnostics)

func ExpressionsEqual

func ExpressionsEqual(expr1, expr2 hcl.Expression) bool

func FindChildBlocks

func FindChildBlocks(parentBlock *hcl.Block, blockType string) hcl.Blocks

func FindFirstChildBlock

func FindFirstChildBlock(parentBlock *hcl.Block, blockType string) *hcl.Block

func GetFirstBlockOfType

func GetFirstBlockOfType(blocks hcl.Blocks, blockType string) *hcl.Block

func GoToPostgresString

func GoToPostgresString(v any) (string, error)

GoToPostgresString convert a go value into a postgres representation of the value

func GoTypeMatchesCtyType

func GoTypeMatchesCtyType(val interface{}, ctyType cty.Type) bool

func QuotePostgresBytes

func QuotePostgresBytes(buf []byte) string

QuotePostgresBytes taken from github.com/jackc/pgx/v5@v4.17.2/internal/sanitize/sanitize.go

func QuotePostgresString

func QuotePostgresString(str string) string

QuotePostgresString taken from github.com/jackc/pgx/v5@v4.17.2/internal/sanitize/sanitize.go

func ResourceNameFromTraversal

func ResourceNameFromTraversal(resourceType string, traversal hcl.Traversal) (string, bool)

ResourceNameFromTraversal converts a traversal to the name of the referenced resource We must take into account possible mod-name as first traversal element

func ToTypedSlice

func ToTypedSlice[T any](input []any) []T

ToTypedSlice converts []any to []T

func TraversalAsString

func TraversalAsString(traversal hcl.Traversal) string

TraversalAsString converts a traversal to a path string (if an absolute traversal is passed - convert to relative)

func TraversalAsStringSlice

func TraversalAsStringSlice(traversal hcl.Traversal) []string

TraversalAsStringSlice converts a traversal to a path string (if an absolute traversal is passed - convert to relative)

func TraversalsEqual

func TraversalsEqual(t1, t2 hcl.Traversal) bool

Types

This section is empty.

Jump to

Keyboard shortcuts

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