Documentation
¶
Index ¶
- func AssertSameType[T attr.Value](expected T, other attr.Value) (T, bool, diag.Diagnostics)
- func BoolDefault(value *types.Bool, def bool) bool
- func BoolFromMap(m map[string]any, key string) types.Bool
- func CollectionToSliceStringPtr(ctx context.Context, value Elementable, p path.Path, diags *diag.Diagnostics) *[]string
- func ConvertSettingsKeyToTFFieldKey(settingKey string) string
- func Deref[T any](value *T) T
- func DerefOrElse(val *string, def string) string
- func DiffStringSlices(before, after []string) (added, removed []string)
- func DurationToElasticsearchTimeoutString(d time.Duration) string
- func ElasticDateTimeToMillis(v any) (int64, bool)
- func ElasticDateTimeToStringValue(v any) types.String
- func ElasticsearchDurationToString(d estypes.Duration) types.String
- func EnsureTypedList(ctx context.Context, list types.List, elemType attr.Type) types.List
- func FlattenMap(m map[string]any) map[string]any
- func FlipMap[K comparable, V comparable](m map[K]V) map[V]K
- func Float32PointerToFloat64Value(v *float32) types.Float64
- func Float32PointerToInt64Pointer(v *float32) *int64
- func Float32Ptr(v float64) *float32
- func Float64FromMap(m map[string]any, key string) types.Float64
- func Float64PointerValue(value types.Float64) *float64
- func FormatStrictDateTime(t time.Time) string
- func Int64Pointer(v types.Int64) *int64
- func Int64ToFloat32Ptr(v types.Int64) *float32
- func IntPointerToInt64Value(v *int) types.Int64
- func IsEmpty(v any) bool
- func IsEmptyJSONObject(s string) bool
- func IsKnown(value attr.Value) bool
- func Itol(value *int) *int64
- func JSONBytesEqual(a, b []byte) (bool, error)
- func ListToStringsMust(list types.List) []string
- 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 Ltoi(value *int64) *int
- func MapRef[K comparable, T any, M ~map[K]T](value M) *M
- func MapToMapType[T1 any, T2 any](ctx context.Context, value map[string]T1, elemType attr.Type, p path.Path, ...) types.Map
- 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 MarshalToNormalized(v any, p path.Path, diags *diag.Diagnostics) jsontypes.Normalized
- 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 NonEmptyStringOrNull(s *string) types.String
- func NonEmptyStringPtr(s string) *string
- func NonEmptyStringishPointerValue[T ~string](ptr *T) types.String
- func NonEmptyStringishValue[T ~string](value T) types.String
- func NonNilSlice[T any](s []T) []T
- func NonZero[T comparable](v T, fallback T) T
- func NormalizeJSONScalar(v any) any
- 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 OptionalBool(value types.Bool) *bool
- func OptionalInt(value types.Int64) *int
- func OptionalString(value types.String) *string
- func PointerInterfaceMapFromAnyMap(input map[string]any) map[string]*any
- func PtrEqual[T comparable](a, b *T) bool
- func PtrEqualOrOmitted[T comparable](value *T, expected T) bool
- func SetAtPath(obj map[string]any, segments []string, value any)
- func SetBoolInMap(m map[string]any, key string, val types.Bool)
- func SetFromAPIStringsPreserveKnownEmpty[T ~string](ctx context.Context, apiValue *[]T, dest types.Set) (types.Set, diag.Diagnostics)
- func SetStringInMap(m map[string]any, key string, val types.String)
- 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 SliceNilIfEmpty[T any, S ~[]T](value S) *S
- func SliceRef[T any, S ~[]T](value S) *S
- 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 StringDefault(value *types.String, def string) string
- func StringElements(value elementCollection, diags *diag.Diagnostics) []string
- func StringFromMap(m map[string]any, key string) types.String
- func StringSetOrNull(ctx context.Context, src []string) (types.Set, diag.Diagnostics)
- func StringSliceValue(v []string) []types.String
- func StringToHash(s string) (*string, error)
- func StringTypableEqual[T attr.Type](o attr.Type) bool
- func StringTypableValueFromTerraform(ctx context.Context, stringType basetypes.StringType, ...) (attr.Value, error)
- func StringValuableEqual[T attr.Value](self basetypes.StringValue, o attr.Value, ...) bool
- func StringishPointerValue[T ~string](ptr *T) types.String
- func StringishToPointer[T ~string](v types.String) *T
- func StringishValue[T ~string](value T) types.String
- func StringsToListMust(strs []string) types.List
- func StructToObjectType[T1 any, T2 any](ctx context.Context, value *T1, attrTypes map[string]attr.Type, p path.Path, ...) types.Object
- func TimeToStringValue(t time.Time) types.String
- 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 TrimmedStringishPointerValue[T ~string](ptr *T) types.String
- func TrimmedStringishValue[T ~string](value T) types.String
- func UnmarshalJSONDiag[T any](data string, errSummary string) (T, diag.Diagnostics)
- func UnmarshalJSONForSemanticEquals[T any](raw string) (T, diag.Diagnostics)
- func ValueStringPointer(value types.String) *string
- func ValueStringSlice(v []types.String) []string
- func WalkJSON(v any, leaf func(any) any) any
- type Elementable
- type ListMeta
- type MapMeta
- type ObjectMeta
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertSameType ¶ added in v0.16.4
AssertSameType type-asserts other to the concrete type of expected (T), for use at the top of a XSemanticEquals method (StringSemanticEquals, ListSemanticEquals, MapSemanticEquals, ObjectSemanticEquals, SetSemanticEquals, Float64SemanticEquals, ...). The terraform-plugin-framework contract for these methods guarantees other is normally the same concrete type as the receiver; this centralizes the "unexpected value type" diagnostic raised on the rare occasion that guarantee doesn't hold.
func BoolDefault ¶ added in v0.16.4
BoolDefault resolves value to its known bool. When value is null or unknown, it writes types.BoolValue(def) back into *value (so plan/state stay consistent) and returns def; otherwise it returns value.ValueBool() unchanged.
func BoolFromMap ¶ added in v0.16.2
BoolFromMap extracts a bool from a map[string]any by key, returning types.BoolNull() when the map is nil, the key is absent, or the value is not a bool.
func CollectionToSliceStringPtr ¶ added in v0.16.5
func CollectionToSliceStringPtr(ctx context.Context, value Elementable, p path.Path, diags *diag.Diagnostics) *[]string
CollectionToSliceStringPtr extracts a *[]string from an optional list/set attribute, returning nil when the collection is null or unknown. A known-but-empty collection yields a pointer to an empty slice, preserving the null/unknown vs. empty distinction consistently across collection kinds.
func ConvertSettingsKeyToTFFieldKey ¶ added in v0.15.2
ConvertSettingsKeyToTFFieldKey maps a dotted Elasticsearch settings key to the Terraform attribute name used in flattened blocks (dots → underscores).
func Deref ¶ added in v0.15.0
func Deref[T any](value *T) T
Deref returns the value referenced by the given pointer. If the pointer is nil, a zero value is returned.
func DerefOrElse ¶ added in v0.15.0
DerefOrElse returns the value pointed to by val if it is non-nil and non-empty, otherwise it returns def. It is the inverse of NonEmptyStringPtr.
func DiffStringSlices ¶ added in v0.16.4
DiffStringSlices partitions after relative to before into added and removed elements, keyed by string equality. Both returned slices are sorted for deterministic output.
func DurationToElasticsearchTimeoutString ¶ added in v0.16.4
DurationToElasticsearchTimeoutString converts a time.Duration to an Elasticsearch timeout string for use with typed API builder methods that accept a string timeout. Sub-millisecond values are expressed in nanoseconds (e.g. "500nanos"); all other values are expressed in milliseconds (e.g. "5000ms"), matching legacy esapi behavior.
func ElasticDateTimeToMillis ¶ added in v0.16.2
ElasticDateTimeToMillis converts any Elastic DateTime representation to Unix milliseconds. Handles float64, int64, int, uint64, json.Number, and RFC3339 strings. Returns (0, false) for nil, empty, or unparseable values.
estypes.DateTime is defined as `type DateTime any` (a named interface); its concrete value is unwrapped by Go's interface-boxing rules before the type switch, so DateTime(float64) is handled by the float64 case and DateTime(string) by the string case.
func ElasticDateTimeToStringValue ¶ added in v0.16.2
ElasticDateTimeToStringValue converts an Elastic DateTime (passed as any) to a types.String in ISO 8601 format. Returns types.StringNull() for nil, zero, empty, or unparseable values. Accepts any value; callers typically pass estypes.DateTime which is `type DateTime any`.
func ElasticsearchDurationToString ¶ added in v0.16.2
ElasticsearchDurationToString converts an estypes.Duration to a Terraform types.String. Returns types.StringNull() when d is nil.
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 FlattenMap ¶ added in v0.15.0
FlattenMap recursively flattens a nested map into a single-level map with dot-separated keys. For example, {"index": {"key": 1}} becomes {"index.key": 1}.
func FlipMap ¶ added in v0.15.0
func FlipMap[K comparable, V comparable](m map[K]V) map[V]K
FlipMap returns a new map with keys and values swapped.
func Float32PointerToFloat64Value ¶ added in v0.16.2
Float32PointerToFloat64Value converts a *float32 to a types.Float64, returning types.Float64Null() when the pointer is nil.
func Float32PointerToInt64Pointer ¶ added in v0.16.3
Float32PointerToInt64Pointer converts a *float32 to a *int64, truncating any fractional part. Intended for numeric API fields that represent whole-number counts (e.g. a maximum series/points-to-plot value).
func Float32Ptr ¶ added in v0.15.0
Float32Ptr converts a float64 to a *float32.
func Float64FromMap ¶ added in v0.16.2
Float64FromMap extracts a float64 from a map[string]any by key, returning types.Float64Null() when the map is nil, the key is absent, or the value is not a float64/int/int64.
func Float64PointerValue ¶ added in v0.15.0
Float64PointerValue returns nil if unknown, otherwise the same as value.ValueFloat64Pointer().
func FormatStrictDateTime ¶ added in v0.15.0
FormatStrictDateTime formats a time.Time as ISO 8601 strict date-time with milliseconds.
func Int64Pointer ¶ added in v0.16.2
Int64Pointer returns a pointer to the int64 value when set, or nil when null or unknown.
func Int64ToFloat32Ptr ¶ added in v0.16.3
Int64ToFloat32Ptr converts a types.Int64 to a *float32, returning nil when null or unknown.
func IntPointerToInt64Value ¶ added in v0.16.2
IntPointerToInt64Value converts a *int to a types.Int64, returning types.Int64Null() when the pointer is nil.
func IsEmpty ¶ added in v0.15.0
IsEmpty reports whether v is a zero-like value: zero number, blank string, empty slice/map, or nil.
func IsEmptyJSONObject ¶ added in v0.16.2
IsEmptyJSONObject reports whether s is a semantically-empty JSON object — either whitespace-only, the literal `{}`, or any JSON object that unmarshals to a zero-length, non-nil map. It returns false for non-empty objects, arrays, scalars, the JSON literal `null`, and invalid JSON.
func JSONBytesEqual ¶ added in v0.15.0
JSONBytesEqual reports whether the JSON in two byte slices is semantically equivalent.
func ListToStringsMust ¶ added in v0.16.3
ListToStringsMust extracts a []string from a types.List of string elements. Null or unknown lists return nil. This is a Must-style variant that panics on non-string elements; use ListTypeToSliceString for safe, diagnostic-based extraction.
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 []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 MapRef ¶ added in v0.15.0
func MapRef[K comparable, T any, M ~map[K]T](value M) *M
MapRef takes the reference of the given map value. If the value is nil, it returns nil rather than a pointer to nil.
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 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 MarshalToNormalized ¶ added in v0.16.2
func MarshalToNormalized(v any, p path.Path, diags *diag.Diagnostics) jsontypes.Normalized
MarshalToNormalized marshals v to a jsontypes.Normalized value.
- If v is nil, a nil pointer/map/slice/channel/function stored inside an interface{}, or marshals to JSON null, it returns jsontypes.NewNormalizedNull().
- On a marshal error it appends an attribute error at p to diags and returns jsontypes.NewNormalizedNull().
func NonEmptyListOrDefault ¶ added in v0.13.1
func NonEmptyListOrDefault[T any](ctx context.Context, original types.List, elemType attr.Type, slice []T) (types.List, diag.Diagnostics)
NonEmptyListOrDefault returns the original list if slice is empty, otherwise converts slice into a types.List.
func NonEmptySetOrDefault ¶ added in v0.13.1
func NonEmptySetOrDefault[T any](ctx context.Context, original types.Set, elemType attr.Type, slice []T) (types.Set, diag.Diagnostics)
NonEmptySetOrDefault returns the original set if slice is empty, otherwise converts slice into a types.Set.
func NonEmptyStringOrNull ¶ added in v0.16.2
NonEmptyStringOrNull returns types.StringValue(*s) when s is non-nil and non-empty, and types.StringNull() otherwise. Use for API fields that use an empty string to signal absence.
func NonEmptyStringPtr ¶ added in v0.15.0
NonEmptyStringPtr returns a pointer to s, or nil if s is empty.
func NonEmptyStringishValue ¶
func NonNilSlice ¶ added in v0.15.0
func NonNilSlice[T any](s []T) []T
NonNilSlice returns an empty slice if s is nil. Guarantees that json.Marshal and terraform parameters will not treat the empty slice as null.
func NonZero ¶ added in v0.16.2
func NonZero[T comparable](v T, fallback T) T
NonZero returns v if it is not the zero value for T; otherwise it returns fallback.
func NormalizeJSONScalar ¶ added in v0.15.2
NormalizeJSONScalar recursively walks a decoded JSON value and converts string-encoded JSON booleans and null back to their native Go types. "true" → bool(true), "false" → bool(false), "null" → nil. All other values are returned unchanged.
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 OptionalBool ¶ added in v0.16.1
OptionalBool returns a pointer to the bool value when set, or nil when null or unknown.
func OptionalInt ¶ added in v0.16.2
OptionalInt returns a pointer to the int value when set, or nil when null or unknown. Use when the target API field expects *int rather than *int64.
func OptionalString ¶ added in v0.16.1
OptionalString returns a non-nil pointer only when the value is known and non-empty. Returns nil when the value is null, unknown, or an empty string. Use for optional API string fields where empty string and absent are equivalent.
func PointerInterfaceMapFromAnyMap ¶ added in v0.15.0
PointerInterfaceMapFromAnyMap converts a map[string]any to map[string]*any by taking pointers to each value. This is needed when constructing API request bodies that require pointer values.
func PtrEqual ¶ added in v0.16.4
func PtrEqual[T comparable](a, b *T) bool
PtrEqual reports whether a and b point to equal values, treating nil pointers as equal to each other and unequal to any non-nil pointer.
func PtrEqualOrOmitted ¶ added in v0.16.5
func PtrEqualOrOmitted[T comparable](value *T, expected T) bool
PtrEqualOrOmitted reports whether value equals expected, treating a nil value (an omitted field) as matching any expected default.
func SetAtPath ¶ added in v0.16.5
SetAtPath sets value at the given sequence of keys within obj, creating intermediate map[string]any nodes as needed. If an intermediate segment already holds a non-map value (or nil), it is replaced with a new map so the walk can continue. A nil or empty segments slice is a no-op.
func SetBoolInMap ¶ added in v0.16.2
SetBoolInMap sets a bool field in the map if the value is known and non-null.
func SetFromAPIStringsPreserveKnownEmpty ¶ added in v0.16.5
func SetFromAPIStringsPreserveKnownEmpty[T ~string](ctx context.Context, apiValue *[]T, dest types.Set) (types.Set, diag.Diagnostics)
SetFromAPIStringsPreserveKnownEmpty converts an optional API string slice into a types.Set of strings. Kibana returns nil/[] interchangeably for an empty set, so a nil or empty apiValue collapses dest to Null only when dest was Unknown; all Known destinations (including Known-empty, e.g. `attr = []` from config) are preserved as-is to avoid "produced inconsistent result after apply" diffs on read-after-apply. T must be a string kind (~string).
func SetStringInMap ¶ added in v0.16.2
SetStringInMap sets a string field in the map if the value is known and non-null.
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 SetValueFrom[T any](ctx context.Context, value []T, elemType attr.Type, p path.Path, diags *diag.Diagnostics) types.Set
SetValueFrom converts a tfsdk aware []T to a types.Set.
func SliceNilIfEmpty ¶ added in v0.15.0
func SliceNilIfEmpty[T any, S ~[]T](value S) *S
SliceNilIfEmpty takes the reference of the given slice value. If the value is nil or empty, it returns nil rather than a pointer to an empty slice.
func SliceRef ¶ added in v0.15.0
func SliceRef[T any, S ~[]T](value S) *S
SliceRef takes the reference of the given slice value. If the value is nil, it returns nil rather than a pointer to nil.
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 StringDefault ¶ added in v0.16.4
StringDefault resolves value to its known string. When value is null or unknown, it writes types.StringValue(def) back into *value (so plan/state stay consistent) and returns def; otherwise it returns value.ValueString() unchanged.
func StringElements ¶ added in v0.16.5
func StringElements(value elementCollection, diags *diag.Diagnostics) []string
StringElements extracts the string values from a types.List or types.Set of strings. Returns nil for a null/unknown collection and appends an error diagnostic for any element that is not a types.String or is null/unknown.
func StringFromMap ¶ added in v0.16.2
StringFromMap extracts a string from a map[string]any by key, returning types.StringNull() when the map is nil, the key is absent, or the value is not a string.
func StringSetOrNull ¶ added in v0.16.2
StringSetOrNull converts a []string to a types.Set. Returns a null string set when src is empty so that unset attributes are stored as null in state.
func StringSliceValue ¶ added in v0.16.2
StringSliceValue converts []string to []types.String.
func StringToHash ¶ added in v0.15.0
StringToHash computes a SHA-1 hash of s and returns the hex-encoded result as a pointer.
func StringTypableEqual ¶ added in v0.16.4
StringTypableEqual implements the Equal method shared by every custom basetypes.StringTypable type in this package that embeds basetypes.StringType: since basetypes.StringType carries no distinguishing state, equality between two instances of T reduces to asserting o to that same concrete type.
func StringTypableValueFromTerraform ¶ added in v0.16.4
func StringTypableValueFromTerraform( ctx context.Context, stringType basetypes.StringType, valueFromString func(context.Context, basetypes.StringValue) (basetypes.StringValuable, diag.Diagnostics), in tftypes.Value, ) (attr.Value, error)
StringTypableValueFromTerraform implements the ValueFromTerraform adapter shared by every custom basetypes.StringTypable type in this codebase: it converts the raw tftypes.Value into a basetypes.StringValue via stringType, then delegates to valueFromString (normally the receiver's own ValueFromString method) to produce the final attr.Value.
func StringValuableEqual ¶ added in v0.16.4
func StringValuableEqual[T attr.Value](self basetypes.StringValue, o attr.Value, embeddedOf func(T) basetypes.StringValue) bool
StringValuableEqual implements the Equal method shared by every custom basetypes.StringValuable type in this package that embeds basetypes.StringValue: it asserts o to the same concrete type T, then delegates to the embedded StringValue's own Equal. embeddedOf extracts the embedded basetypes.StringValue from a T (normally a field access, e.g. func(d Duration) basetypes.StringValue { return d.StringValue }).
func StringishPointerValue ¶
StringishPointerValue converts a pointer to a string-like type to a Terraform types.String value.
func StringishToPointer ¶ added in v0.16.1
StringishToPointer converts a types.String to a typed string-enum pointer, returning nil for null, unknown, or empty-string values.
func StringishValue ¶
StringishValue converts a value of any string-like type T to a Terraform types.String.
func StringsToListMust ¶ added in v0.16.3
StringsToListMust converts a []string to a types.List of string elements. The result is always valid; an empty or nil slice produces an empty list. This is a Must-style variant that panics on error; use SliceToListTypeString for safe, diagnostic-based conversion.
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 TimeToStringValue ¶ added in v0.15.0
TimeToStringValue formats a time.Time to ISO 8601 format and returns a types.StringValue.
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
TransformMapToSlice converts map[string]T1 to []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 TrimmedStringishPointerValue ¶ added in v0.16.3
TrimmedStringishPointerValue converts a pointer to a string-like type to a Terraform types.String, returning types.StringNull() when the pointer is nil or the trimmed string is empty.
func TrimmedStringishValue ¶ added in v0.16.5
TrimmedStringishValue converts a value of any string-like type T to a Terraform types.String, returning types.StringNull() when the trimmed value is empty.
func UnmarshalJSONDiag ¶ added in v0.16.3
func UnmarshalJSONDiag[T any](data string, errSummary string) (T, diag.Diagnostics)
UnmarshalJSONDiag unmarshals a JSON string into T, returning a single-element Diagnostics slice on error instead of a raw error value.
func UnmarshalJSONForSemanticEquals ¶ added in v0.16.4
func UnmarshalJSONForSemanticEquals[T any](raw string) (T, diag.Diagnostics)
UnmarshalJSONForSemanticEquals unmarshals raw JSON into a value of type T, centralizing the "Semantic Equality Check Error" diagnostic raised on failure across XSemanticEquals implementations that decode JSON-typed values before comparing them structurally.
func ValueStringPointer ¶ added in v0.14.3
ValueStringPointer returns nil when the value is unknown or null, and &"" when empty. Use for computed optional fields that must distinguish null from empty string at the API level. For fields where empty string means "not set", prefer OptionalString instead.
func ValueStringSlice ¶ added in v0.16.2
ValueStringSlice converts []types.String to []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
}