Documentation
¶
Index ¶
- func CollapseListPath(m map[string]any, key, pathLabel string) diag.Diagnostics
- func EnsureMapKeys(m map[string]any, keys ...string)
- func MarshalStateMap(m map[string]any, resp *resource.UpgradeStateResponse)
- func NullifyEmptySlice(m map[string]any, keys ...string)
- func NullifyEmptyString(m map[string]any, keys ...string)
- func SetDefaultState(req resource.UpgradeStateRequest, resp *resource.UpgradeStateResponse)
- func UnmarshalStateMap(req resource.UpgradeStateRequest, resp *resource.UpgradeStateResponse) map[string]any
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CollapseListPath ¶
func CollapseListPath(m map[string]any, key, pathLabel string) diag.Diagnostics
CollapseListPath applies the singleton-list collapse rule for Terraform state upgrades at m[key]. It handles the SDK-to-Plugin-Framework migration where MaxItems:1 / SizeBetween(1,1) list blocks become SingleNestedBlock.
Semantics:
- key absent: no-op
- value nil or non-list: no-op (pass-through)
- empty list: m[key] = nil
- singleton list: m[key] = list[0]
- multi-element list: returns an error diagnostic (corrupt state)
func EnsureMapKeys ¶
EnsureMapKeys sets each key in keys to nil in m if the key is absent. Used during state upgrades to ensure the Plugin Framework can decode the JSON state even when optional blocks were omitted in the prior SDK state.
func MarshalStateMap ¶
func MarshalStateMap(m map[string]any, resp *resource.UpgradeStateResponse)
MarshalStateMap encodes m as JSON and assigns it to resp.DynamicValue.
func NullifyEmptySlice ¶
NullifyEmptySlice sets each key in keys to nil in m when the existing value is an empty slice. SDKv2 stored omitted optional TypeSet/TypeList attributes as [] rather than null; the Plugin Framework expects null.
func NullifyEmptyString ¶
NullifyEmptyString sets each key in keys to nil in m when the existing value is an empty string. SDKv2 stored omitted optional string attributes as "" rather than null; the Plugin Framework expects null, so this normalisation prevents known-empty-vs-null mismatches during state upgrades.
func SetDefaultState ¶
func SetDefaultState(req resource.UpgradeStateRequest, resp *resource.UpgradeStateResponse)
SetDefaultState sets resp.DynamicValue to the original raw state when req.RawState is non-nil. Call this at the top of a state upgrade function so that early returns leave a valid response even when no modifications are needed.
func UnmarshalStateMap ¶
func UnmarshalStateMap(req resource.UpgradeStateRequest, resp *resource.UpgradeStateResponse) map[string]any
UnmarshalStateMap decodes req.RawState.JSON into a map[string]any for use in state upgrade functions. Returns nil and sets a diagnostic error on failure.
Types ¶
This section is empty.