utils

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2025 License: MPL-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DiagnosticsToString

func DiagnosticsToString(diags diag.Diagnostics) string

DiagnosticsToString converts diagnostics to a string for logging

func DynamicAttrValueToGo

func DynamicAttrValueToGo(ctx context.Context, v attr.Value) (interface{}, diag.Diagnostics)

DynamicAttrValueToGo recursively converts attr.Value to Go values for JSON serialization

func DynamicToJSONString

func DynamicToJSONString(ctx context.Context, dynamicValue types.Dynamic) (string, diag.Diagnostics)

DynamicToJSONString converts a types.Dynamic to a JSON string

func FlattenRecursive

func FlattenRecursive(ctx context.Context, prefix string, data interface{}, keyMap map[string]interface{})

FlattenRecursive flattens nested JSON structures into dot-notation keys

func GenerateKeysFromResponse

func GenerateKeysFromResponse(ctx context.Context, responseBytes []byte) (map[string]interface{}, error)

GenerateKeysFromResponse extracts keys from a GraphQL response

func GetMapKeys

func GetMapKeys(m map[string]interface{}) []string

GetMapKeys returns the keys of a map as a slice of strings

func JSONEqual

func JSONEqual(json1, json2 string) (bool, error)

JSONEqual compares two JSON strings for semantic equality, ignoring field ordering

func MapToJSONString

func MapToJSONString(ctx context.Context, mapValue types.Map) (string, diag.Diagnostics)

MapToJSONString converts a types.Map to a JSON string

func NormalizeJSONForComparison

func NormalizeJSONForComparison(jsonStr string) (string, error)

NormalizeJSONForComparison normalizes JSON by marshaling and unmarshaling to ensure consistent field ordering

func ParseGraphQLQueryFields

func ParseGraphQLQueryFields(query string) []string

ParseGraphQLQueryFields extracts field names from a GraphQL query

Types

type ResponseExtraction

type ResponseExtraction struct{}

ResponseExtraction provides utilities for extracting data from GraphQL responses

func (*ResponseExtraction) ExtractCurrentStateFromQueryResponse

func (re *ResponseExtraction) ExtractCurrentStateFromQueryResponse(ctx context.Context, queryResponse map[string]interface{}) map[string]interface{}

ExtractCurrentStateFromQueryResponse intelligently extracts the current state from a GraphQL query response using heuristics to determine the best data source

func (*ResponseExtraction) ExtractValueFromPath

func (re *ResponseExtraction) ExtractValueFromPath(data map[string]interface{}, path string) (interface{}, error)

ExtractValueFromPath extracts a value from a nested map using a dot-separated path

func (*ResponseExtraction) IsValidResourceData

func (re *ResponseExtraction) IsValidResourceData(data map[string]interface{}) bool

IsValidResourceData checks if the given data looks like a valid resource

type StateComparison

type StateComparison struct{}

StateComparison provides utilities for comparing Terraform state

func NewStateComparison

func NewStateComparison() *StateComparison

NewStateComparison creates a new StateComparison instance

func (*StateComparison) DetectFieldChanges

func (sc *StateComparison) DetectFieldChanges(ctx context.Context, desiredState map[string]interface{}, currentStateData interface{}) bool

DetectFieldChanges compares the desired state with the current platform state to determine if there are actual changes that need to be applied

func (*StateComparison) ExtractCurrentStateFromQueryResponse

func (sc *StateComparison) ExtractCurrentStateFromQueryResponse(ctx context.Context, queryResponse map[string]interface{}) map[string]interface{}

ExtractCurrentStateFromQueryResponse extracts current state from a GraphQL query response

func (*StateComparison) FindChangedFields

func (sc *StateComparison) FindChangedFields(ctx context.Context, current, previous map[string]interface{}) map[string]interface{}

FindChangedFields finds the fields that have changed between two states

func (*StateComparison) HasConfigurationChanges

func (sc *StateComparison) HasConfigurationChanges(ctx context.Context, data interface{}) bool

HasConfigurationChanges checks if there are configuration changes in the data model

func (*StateComparison) ValuesEqual

func (sc *StateComparison) ValuesEqual(desired, current interface{}) bool

ValuesEqual compares two values for equality, handling different types

Jump to

Keyboard shortcuts

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