Documentation
¶
Index ¶
- func EnsureTypedList(ctx context.Context, list types.List, elemType attr.Type) types.List
- func ExpandStringSet(set *schema.Set) []string
- func IsKnown(value attr.Value) bool
- func ListTypeAs[T any](ctx context.Context, value types.List, p path.Path, diags *diag.Diagnostics) []T
- func ListTypeToMap[T1 any, T2 any](ctx context.Context, value types.List, p path.Path, diags *diag.Diagnostics, ...) map[string]T2
- func ListTypeToSlice[T1 any, T2 any](ctx context.Context, value types.List, p path.Path, diags *diag.Diagnostics, ...) []T2
- func ListTypeToSliceString(ctx context.Context, value types.List, p path.Path, diags *diag.Diagnostics) []string
- func ListValueFrom[T any](ctx context.Context, value []T, elemType attr.Type, p path.Path, ...) types.List
- func MapToMapType[T1 any, T2 any](ctx context.Context, value map[string]T1, elemType attr.Type, p path.Path, ...) types.Map
- func MapToNormalizedType[T any](value map[string]T, p path.Path, diags *diag.Diagnostics) jsontypes.Normalized
- func MapTypeAs[T any](ctx context.Context, value types.Map, p path.Path, diags *diag.Diagnostics) map[string]T
- func MapTypeToMap[T1 any, T2 any](ctx context.Context, value types.Map, p path.Path, diags *diag.Diagnostics, ...) map[string]T2
- func MapValueFrom[T any](ctx context.Context, value map[string]T, elemType attr.Type, p path.Path, ...) types.Map
- func NonEmptyListOrDefault[T any](ctx context.Context, original types.List, elemType attr.Type, slice []T) (types.List, diag.Diagnostics)
- func NonEmptySetOrDefault[T any](ctx context.Context, original types.Set, elemType attr.Type, slice []T) (types.Set, diag.Diagnostics)
- func NonEmptyStringishPointerValue[T ~string](ptr *T) types.String
- func NonEmptyStringishValue[T ~string](value T) types.String
- func NormalizedTypeToMap[T any](value jsontypes.Normalized, p path.Path, diags *diag.Diagnostics) map[string]T
- func ObjectTypeAs[T any](ctx context.Context, value types.Object, p path.Path, diags *diag.Diagnostics) *T
- func ObjectTypeToStruct[T1 any, T2 any](ctx context.Context, value types.Object, p path.Path, diags *diag.Diagnostics, ...) *T2
- func ObjectValueFrom[T any](ctx context.Context, value *T, attrTypes map[string]attr.Type, p path.Path, ...) types.Object
- func SetTypeAs[T any](ctx context.Context, value types.Set, p path.Path, diags *diag.Diagnostics) []T
- func SetValueFrom[T any](ctx context.Context, value []T, elemType attr.Type, p path.Path, ...) types.Set
- func SliceToListType[T1 any, T2 any](ctx context.Context, value []T1, elemType attr.Type, p path.Path, ...) types.List
- func SliceToListTypeString(ctx context.Context, value []string, p path.Path, diags *diag.Diagnostics) types.List
- func StringishPointerValue[T ~string](ptr *T) types.String
- func StringishValue[T ~string](value T) types.String
- func StructToObjectType[T1 any, T2 any](ctx context.Context, value *T1, attrTypes map[string]attr.Type, p path.Path, ...) types.Object
- func TransformMap[T1 any, T2 any](_ context.Context, value map[string]T1, p path.Path, diags *diag.Diagnostics, ...) map[string]T2
- func TransformMapToSlice[T1 any, T2 any](_ context.Context, value map[string]T1, p path.Path, diags *diag.Diagnostics, ...) []T2
- func TransformObject[T1 any, T2 any](_ context.Context, value *T1, p path.Path, diags *diag.Diagnostics, ...) *T2
- func TransformSlice[T1 any, T2 any](_ context.Context, value []T1, p path.Path, diags *diag.Diagnostics, ...) []T2
- func TransformSliceToMap[T1 any, T2 any](_ context.Context, value []T1, p path.Path, diags *diag.Diagnostics, ...) map[string]T2
- func ValueStringPointer(value types.String) *string
- type Elementable
- type ListMeta
- type MapMeta
- type ObjectMeta
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EnsureTypedList ¶ added in v0.14.0
EnsureTypedList converts untyped zero-value lists to properly typed null lists. This is commonly needed during import operations where the framework may create untyped lists with DynamicPseudoType elements, which causes type conversion errors. If the list already has a proper type, it is returned unchanged.
func ExpandStringSet ¶ added in v0.14.3
func ListTypeAs ¶ added in v0.14.3
func ListTypeAs[T any](ctx context.Context, value types.List, p path.Path, diags *diag.Diagnostics) []T
ListTypeAs converts a types.List into a tfsdk aware []T.
func ListTypeToMap ¶ added in v0.14.3
func ListTypeToMap[T1 any, T2 any](ctx context.Context, value types.List, p path.Path, diags *diag.Diagnostics, iteratee func(item T1, meta ListMeta) (key string, elem T2)) map[string]T2
ListTypeToMap converts a types.List first into a tfsdk aware map[string]T1 and transforms the result into a map[string]T2.
func ListTypeToSlice ¶ added in v0.14.3
func ListTypeToSlice[T1 any, T2 any](ctx context.Context, value types.List, p path.Path, diags *diag.Diagnostics, iteratee func(item T1, meta ListMeta) T2) []T2
ListTypeToSlice converts a types.List first into a tfsdk aware []T1 and transforms the result into a []T2.
func ListTypeToSliceString ¶ added in v0.14.3
func ListTypeToSliceString(ctx context.Context, value types.List, p path.Path, diags *diag.Diagnostics) []string
ListTypeToSliceString converts a types.List into a []string. This is a shorthand ListTypeToSlice helper for strings.
func ListValueFrom ¶ added in v0.14.3
func ListValueFrom[T any](ctx context.Context, value []T, elemType attr.Type, p path.Path, diags *diag.Diagnostics) types.List
ListValueFrom converts a tfsdk aware []T to a types.List.
func MapToMapType ¶ added in v0.14.3
func MapToMapType[T1 any, T2 any](ctx context.Context, value map[string]T1, elemType attr.Type, p path.Path, diags *diag.Diagnostics, iteratee func(item T1, meta MapMeta) T2) types.Map
MapToMapType converts a tfsdk naive map[string]T1 into an types.Map of map[string]T2. This handles both structs and simple types to attr.Values.
func MapToNormalizedType ¶ added in v0.14.3
func MapToNormalizedType[T any](value map[string]T, p path.Path, diags *diag.Diagnostics) jsontypes.Normalized
MapToNormalizedType marshals a map[string]T into a jsontypes.Normalized.
func MapTypeAs ¶ added in v0.14.3
func MapTypeAs[T any](ctx context.Context, value types.Map, p path.Path, diags *diag.Diagnostics) map[string]T
MapTypeAs converts a types.Map into a tfsdk aware map[string]T.
func MapTypeToMap ¶ added in v0.14.3
func MapTypeToMap[T1 any, T2 any](ctx context.Context, value types.Map, p path.Path, diags *diag.Diagnostics, iteratee func(item T1, meta MapMeta) T2) map[string]T2
MapTypeToMap converts a types.Map first into a tfsdk aware map[string]T1 and transforms the result into a map[string]T2.
func MapValueFrom ¶ added in v0.14.3
func MapValueFrom[T any](ctx context.Context, value map[string]T, elemType attr.Type, p path.Path, diags *diag.Diagnostics) types.Map
MapValueFrom converts a tfsdk aware map[string]T to a types.Map.
func NonEmptyListOrDefault ¶ added in v0.13.1
func NonEmptySetOrDefault ¶ added in v0.13.1
func NonEmptyStringishValue ¶
func NormalizedTypeToMap ¶ added in v0.14.3
func NormalizedTypeToMap[T any](value jsontypes.Normalized, p path.Path, diags *diag.Diagnostics) map[string]T
NormalizedTypeToMap unmarshals a jsontypes.Normalized to a map[string]T.
func ObjectTypeAs ¶ added in v0.14.3
func ObjectTypeAs[T any](ctx context.Context, value types.Object, p path.Path, diags *diag.Diagnostics) *T
ObjectTypeAs converts a types.Object into a tfsdk aware T.
func ObjectTypeToStruct ¶ added in v0.14.3
func ObjectTypeToStruct[T1 any, T2 any](ctx context.Context, value types.Object, p path.Path, diags *diag.Diagnostics, transformee func(item T1, meta ObjectMeta) T2) *T2
ObjectTypeToStruct converts a types.Object first into a tfsdk aware T1 and transforms the result into a T2.
func ObjectValueFrom ¶ added in v0.14.3
func ObjectValueFrom[T any](ctx context.Context, value *T, attrTypes map[string]attr.Type, p path.Path, diags *diag.Diagnostics) types.Object
ObjectValueFrom converts a tfsdk aware T to a types.Object.
func SetTypeAs ¶ added in v0.14.3
func SetTypeAs[T any](ctx context.Context, value types.Set, p path.Path, diags *diag.Diagnostics) []T
SetTypeAs converts a types.Set into a tfsdk aware []T.
func SetValueFrom ¶ added in v0.14.3
func SliceToListType ¶ added in v0.14.3
func SliceToListType[T1 any, T2 any](ctx context.Context, value []T1, elemType attr.Type, p path.Path, diags *diag.Diagnostics, iteratee func(item T1, meta ListMeta) T2) types.List
SliceToListType converts a tfsdk naive []T1 into an types.List of []T2. This handles both structs and simple types to attr.Values.
func SliceToListTypeString ¶ added in v0.14.3
func SliceToListTypeString(ctx context.Context, value []string, p path.Path, diags *diag.Diagnostics) types.List
SliceToListTypeString converts a tfsdk naive []string into a types.List. This is a shorthand SliceToListType helper for strings.
func StringishPointerValue ¶
StringishPointerValue converts a pointer to a string-like type to a Terraform types.String value.
func StringishValue ¶
StringishValue converts a value of any string-like type T to a Terraform types.String.
func StructToObjectType ¶ added in v0.14.3
func StructToObjectType[T1 any, T2 any]( ctx context.Context, value *T1, attrTypes map[string]attr.Type, p path.Path, diags *diag.Diagnostics, transformee func(item T1, meta ObjectMeta) T2, ) types.Object
StructToObjectType converts a tfsdk naive T1 into an types.Object of T2.
func TransformMap ¶ added in v0.14.3
func TransformMap[T1 any, T2 any](_ context.Context, value map[string]T1, p path.Path, diags *diag.Diagnostics, iteratee func(item T1, meta MapMeta) T2) map[string]T2
TransformMap converts map[string]T1 to map[string]T2 via the iteratee.
func TransformMapToSlice ¶ added in v0.14.3
func TransformMapToSlice[T1 any, T2 any](_ context.Context, value map[string]T1, p path.Path, diags *diag.Diagnostics, iteratee func(item T1, meta MapMeta) T2) []T2
TransformSliceToMap converts []T1 to map[string]]T2 via the iteratee.
func TransformObject ¶ added in v0.14.3
func TransformObject[T1 any, T2 any](_ context.Context, value *T1, p path.Path, diags *diag.Diagnostics, transformee func(item T1, meta ObjectMeta) T2) *T2
TransformObject converts T1 to T2 via the transformee.
func TransformSlice ¶ added in v0.14.3
func TransformSlice[T1 any, T2 any](_ context.Context, value []T1, p path.Path, diags *diag.Diagnostics, iteratee func(item T1, meta ListMeta) T2) []T2
TransformSlice converts []T1 to []T2 via the iteratee.
func TransformSliceToMap ¶ added in v0.14.3
func TransformSliceToMap[T1 any, T2 any](_ context.Context, value []T1, p path.Path, diags *diag.Diagnostics, iteratee func(item T1, meta ListMeta) (key string, elem T2)) map[string]T2
TransformSliceToMap converts []T1 to map[string]]T2 via the iteratee.
func ValueStringPointer ¶ added in v0.14.3
ValueStringPointer returns nil if unknown, otherwise the same as value.ValueStringPointer(). Useful for computed optional fields without a default value, as these unknown values return a pointer to an empty string.
Types ¶
type Elementable ¶ added in v0.14.3
type ListMeta ¶ added in v0.14.3
type ListMeta struct {
Index int
Path path.Path
Diags *diag.Diagnostics
}
type MapMeta ¶ added in v0.14.3
type MapMeta struct {
Key string
Path path.Path
Diags *diag.Diagnostics
}
type ObjectMeta ¶ added in v0.14.3
type ObjectMeta struct {
Path path.Path
Diags *diag.Diagnostics
}