state

package
v0.15.0-alpha Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2025 License: MPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BoolPointerValue

func BoolPointerValue(value *bool) types.Bool

BoolPointerValue safely converts a *bool to types.Bool. Returns types.BoolNull() if the pointer is nil.

func BoolPointerValueWithDefault

func BoolPointerValueWithDefault(value *bool, defaultValue bool) types.Bool

BoolPointerValueWithDefault safely converts a *bool to types.Bool. Returns the default value if the pointer is nil.

func BoolPtrToBool

func BoolPtrToBool(b *bool) bool

BoolPtrToBool converts a bool pointer to a bool. If the input is nil, it returns false.

func BoolPtrToTypeBool

func BoolPtrToTypeBool(b *bool) types.Bool

BoolPtrToTypeBool converts a *bool to a types.Bool. If the input is nil, it returns types.BoolNull().

func BoolValue

func BoolValue(value bool) types.Bool

BoolValue safely converts a bool to types.Bool. Always returns a valid types.Bool value, never null.

func BuildObjectSetFromSlice

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

BuildObjectSetFromSlice creates a Set from a slice using an extractor function.

This function converts a Go slice into a Terraform Framework Set type with proper error handling and logging. It's commonly used for mapping Graph API collections to Terraform state.

Parameters:

  • ctx: Context for logging
  • attrTypes: Map defining the attribute types for objects in the set
  • extract: Function that extracts attribute values for each slice element
  • length: Length of the source slice

Returns:

  • types.Set: The constructed set, or a null set if errors occur

func ByteStringToBase64

func ByteStringToBase64(b []byte) string

ByteStringToBase64 converts a byte slice to a base64-encoded string. This is useful for when the bytes represent binary data that should be base64 encoded. For script content that is already UTF-8, use BytesToString.

func BytesToString

func BytesToString(value []byte) types.String

BytesToString safely converts a byte slice to types.String. Returns types.StringNull() if the byte slice is nil, otherwise converts the byte slice to a string and wraps it in types.String. This is useful for script content which is stored as []byte but needs to be represented as a string in Terraform.

func DateOnlyPtrToString

func DateOnlyPtrToString(date *serialization.DateOnly) types.String

DateOnlyPtrToString converts a DateOnly pointer to a Terraform string.

func DecodeBase64ToString

func DecodeBase64ToString(ctx context.Context, encoded string) types.String

DecodeBase64ToString decodes a base64-encoded string and returns a basetypes.StringValue. If decoding fails, it logs a warning and returns the original string as a basetypes.StringValue.

func EnumListPtrToTypeStringSlice

func EnumListPtrToTypeStringSlice[T fmt.Stringer](input []*T) []types.String

EnumListPtrToTypeStringSlice converts a slice of pointers to enum-like constants to a slice of types.String. It uses the String() method of the enum type to convert each value to a string.

func EnumPtrToTypeString

func EnumPtrToTypeString[T fmt.Stringer](e *T) types.String

EnumPtrToTypeString converts a pointer to an enum-like type to a types.String. It uses the String() method of the enum type to convert the value to a string.

func EnumSliceToTypeStringSlice

func EnumSliceToTypeStringSlice[T fmt.Stringer](input []T) []types.String

EnumSliceToTypeStringSlice converts a slice of enum-like constants to a slice of types.String. It uses the String() method of the enum type to convert each value to a string.

func ISO8601DurationToString

func ISO8601DurationToString(duration *serialization.ISODuration) types.String

ISO8601DurationToString converts an ISODuration to a types.String value.

func Int32PointerToInt64Value

func Int32PointerToInt64Value(value *int32) types.Int64

Int32PointerToInt64Value safely converts a *int32 to types.Int64. Returns types.Int64Null() if the pointer is nil.

func Int32PointerValue

func Int32PointerValue(value *int32) types.Int32

Int32PointerValue safely converts a *int32 to types.Int32. Returns types.Int32Null() if the pointer is nil.

func Int32PtrToTypeInt32

func Int32PtrToTypeInt32(i *int32) types.Int32

Int32PtrToTypeInt32 converts a pointer to an int32 to a types.Int32. This function is useful for converting nullable int32 values from the SDK to Terraform's types.Int32.

func Int32PtrToTypeInt64

func Int32PtrToTypeInt64(i *int32) types.Int64

Int32PtrToTypeInt64 converts a pointer to an int32 to a types.Int64. This function is useful for converting nullable int32 values from the SDK to Terraform's types.Int64.

func Int64PointerValue

func Int64PointerValue(value *int64) types.Int64

Int64PointerValue safely converts a *int64 to types.Int64. Returns types.Int64Null() if the pointer is nil.

func Int64PtrToTypeInt64

func Int64PtrToTypeInt64(i *int64) types.Int64

Int64PtrToTypeInt64 converts a *int64 to a types.Int64. If the input is nil, it returns types.Int64Null().

func IsNilOrEmpty

func IsNilOrEmpty(value *string) bool

IsNilOrEmpty checks if a string pointer is nil or points to an empty string.

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 ListValueFromStrings

func ListValueFromStrings(input []string) types.List

ListValueFromStrings creates a types.List from a slice of strings. If the input slice is nil or empty, it returns an empty list, not null.

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 ObjectValueMust

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

ObjectValueMust creates a types.Object with known values from a map. It panics if the creation fails, which should only happen if there's a programming error.

func SliceToTypeStringSlice

func SliceToTypeStringSlice(input []string) []types.String

SliceToTypeStringSlice converts a slice of strings to a slice of types.String. It handles nil input by returning nil, and empty slices by returning an empty slice of types.String.

func StringListToTypeList

func StringListToTypeList(strings []string) types.List

StringListToTypeList converts a slice of strings to a types.List.

func StringPointerValue

func StringPointerValue(value *string) types.String

StringPointerValue safely converts a *string to types.String. Returns types.StringNull() if the pointer is nil.

func StringPointerValueWithDefault

func StringPointerValueWithDefault(value *string, defaultValue string) types.String

StringPointerValueWithDefault safely converts a *string to types.String. Returns default if the pointer is nil or points to an empty string.

func StringPtrToString

func StringPtrToString(s *string) string

StringPtrToString converts a string pointer to a string.

func StringSliceToSet

func StringSliceToSet(ctx context.Context, input []string) types.Set

StringSliceToSet converts a []string to a Terraform types.Set (StringType).

func StringValue

func StringValue(value string) types.String

StringValue safely converts a string to types.String. Always returns a valid types.String value, never null.

func StringValueWithDefault

func StringValueWithDefault(value string, defaultValue string) types.String

StringValueWithDefault safely converts a string to types.String. If the value is empty, it returns the default value instead.

func TimeOnlyPtrToString

func TimeOnlyPtrToString(time *serialization.TimeOnly) types.String

TimeOnlyPtrToString converts a TimeOnly pointer to a Terraform string.

func TimeToString

func TimeToString(t *time.Time) types.String

TimeToString converts a *time.Time to a types.String. If the input is nil, it returns types.StringNull(). Otherwise, it returns a types.String with the time formatted in RFC3339 format.

func UUIDPtrToTypeString

func UUIDPtrToTypeString(id *uuid.UUID) types.String

UUIDPtrToTypeString converts a *uuid.UUID to a types.String. If the input is nil, it returns types.StringNull(). This is useful for working with UUID values from the Graph API.

Types

This section is empty.

Directories

Path Synopsis
graph_beta

Jump to

Keyboard shortcuts

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