attr

package
v0.35.0-alpha Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2025 License: MPL-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetObjectAttr

func GetObjectAttr(obj basetypes.ObjectValue, name string, defaultValue attr.Value) attr.Value

GetObjectAttr safely retrieves an attribute from an object by name. Returns the default value if the object is null, unknown, or the attribute doesn't exist.

func ListNullIfEmpty

func ListNullIfEmpty(elementType attr.Type, values []attr.Value) types.List

ListNullIfEmpty returns ListNull if the slice is empty, otherwise creates a list with the values.

func ListValue

func ListValue(elementType attr.Type, elements []attr.Value) types.List

ListValue creates a types.List from attr.Value elements. Panics if creation fails, which should only happen with programming errors.

func ListValueFrom

func ListValueFrom(ctx context.Context, elementType attr.Type, elements any) types.List

ListValueFrom creates a types.List from a Go slice. Panics if creation fails, which should only happen with programming errors.

func MapNullIfEmpty

func MapNullIfEmpty(elementType attr.Type, values map[string]attr.Value) types.Map

MapNullIfEmpty returns MapNull if the map is empty, otherwise creates a map with the values.

func MapValue

func MapValue(elementType attr.Type, elements map[string]attr.Value) types.Map

MapValue creates a types.Map from attr.Value elements. Panics if creation fails, which should only happen with programming errors.

func MapValueFrom

func MapValueFrom(ctx context.Context, elementType attr.Type, elements any) types.Map

MapValueFrom creates a types.Map from a Go map. Panics if creation fails, which should only happen with programming errors.

func ObjectListElements

func ObjectListElements(list basetypes.ListValue) []map[string]attr.Value

ObjectListElements converts a basetypes.ListValue containing objects to a slice of maps. Returns nil if the list is null or unknown.

func ObjectMapElements

func ObjectMapElements(m basetypes.MapValue) map[string]map[string]attr.Value

ObjectMapElements converts a basetypes.MapValue containing objects to a map of maps. Returns nil if the map is null or unknown.

func ObjectNullIfEmpty

func ObjectNullIfEmpty(attrTypes map[string]attr.Type, values map[string]attr.Value) types.Object

ObjectNullIfEmpty returns ObjectNull if the map is empty, otherwise creates an object with the values.

func ObjectSetElements

func ObjectSetElements(set basetypes.SetValue) []map[string]attr.Value

ObjectSetElements converts a basetypes.SetValue containing objects to a slice of maps. Returns nil if the set is null or unknown.

func ObjectSetFromSlice

func ObjectSetFromSlice(ctx context.Context, attrTypes map[string]attr.Type, valueFunc func(int) map[string]attr.Value, length int) types.Set

ObjectSetFromSlice builds a set of objects from a slice Returns types.SetNull() if the length is zero

func ObjectValue

func ObjectValue(attrTypes map[string]attr.Type, values map[string]attr.Value) types.Object

ObjectValue creates a types.Object with known values from a map. Panics if creation fails, which should only happen with programming errors.

func ObjectValueFrom

func ObjectValueFrom(ctx context.Context, attrTypes map[string]attr.Type, value any) types.Object

ObjectValueFrom creates a types.Object from a Go struct. Panics if creation fails, which should only happen with programming errors.

func SetNullIfEmpty

func SetNullIfEmpty(ctx context.Context, elementType attr.Type, values []attr.Value) types.Set

SetNullIfEmpty returns SetNull if the slice is empty, otherwise creates a set with the values.

func SetValue

func SetValue(elementType attr.Type, elements []attr.Value) types.Set

SetValue creates a types.Set from attr.Value elements. Panics if creation fails, which should only happen with programming errors.

func SetValueFrom

func SetValueFrom(ctx context.Context, elementType attr.Type, elements any) types.Set

SetValueFrom creates a types.Set from a Go slice. Panics if creation fails, which should only happen with programming errors.

func StringListElements

func StringListElements(list basetypes.ListValue) []string

StringListElements converts a basetypes.ListValue to a slice of strings. Returns nil if the list is null or unknown.

func StringMapElements

func StringMapElements(m basetypes.MapValue) map[string]string

StringMapElements converts a basetypes.MapValue to a map of strings. Returns nil if the map is null or unknown.

func StringSetElements

func StringSetElements(set basetypes.SetValue) []string

StringSetElements converts a basetypes.SetValue to a slice of strings. Returns nil if the set is null or unknown.

Types

This section is empty.

Jump to

Keyboard shortcuts

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