flatteners

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: May 21, 2026 License: MPL-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BoolPtr

func BoolPtr(in *bool) basetypes.BoolValue

func Float64

func Float64(in float64) basetypes.Float64Value

Int64 accepts a `int64` and returns a `basetypes.Int64Value`. The return type automatically handles `Int64Null` should the integer be 0.

Removes the need for the following code when saving to state.

if response.MyField == "" {
    state.MyField = types.Int64Value(response.MyField)
} else {
    state.MyField = types.Int64Null()
}

Not recommended if you care about returning an empty string for the state.

nolint: contextcheck

func Int32

func Int32(in int) basetypes.Int32Value

func Int32Ptr

func Int32Ptr(in *int) basetypes.Int32Value

func Int64

func Int64(in int64) basetypes.Int64Value

Int64 accepts a `int64` and returns a `basetypes.Int64Value`. The return type automatically handles `Int64Null` should the integer be 0.

Removes the need for the following code when saving to state.

if response.MyField == "" {
    state.MyField = types.Int64Value(response.MyField)
} else {
    state.MyField = types.Int64Null()
}

Not recommended if you care about returning an empty string for the state.

nolint: contextcheck

func Int64Ptr

func Int64Ptr(in *int) basetypes.Int64Value

func Int64PtrDefault added in v1.11.0

func Int64PtrDefault(in *int) basetypes.Int64Value

func IsEmptyObject added in v1.11.0

func IsEmptyObject(v any) bool

IsEmptyObject reports whether v marshals to "{}". SDK structs use omitempty on every field, so a struct populated entirely with zero-values (what you get when the API returns "{}") marshals back to exactly two bytes. Use this in convertXxxFromAPI alongside the nil check:

if cfg == nil || flatteners.IsEmptyObject(cfg) {
    return nullObj, nil
}

func JSONInterfaceToString added in v1.11.0

func JSONInterfaceToString(v interface{}) types.String

func JSONInterfaceToStringDefault added in v1.11.0

func JSONInterfaceToStringDefault(v interface{}) types.String

func ListOfStringToTerraformList

func ListOfStringToTerraformList(l []string) (types.List, diag.Diagnostics)

func MapStringString added in v1.11.0

func MapStringString(ctx context.Context, m map[string]string) (types.Map, diag.Diagnostics)

MapStringString converts a map[string]string to types.Map. Returns null if the map is nil or empty.

func MapStringStringOrEmpty added in v1.11.0

func MapStringStringOrEmpty(ctx context.Context, m map[string]string) (types.Map, diag.Diagnostics)

MapStringStringOrEmpty converts a map[string]string to types.Map. Returns an empty (non-null) map when nil or empty, so UseStateForUnknown has a concrete value to carry forward on subsequent plans.

func String

func String(in string) basetypes.StringValue

String accepts a `string` and returns a `basetypes.StringValue`. The return type automatically handles `StringNull` should the string be empty.

Removes the need for the following code when saving to state.

if response.MyField == "" {
    state.MyField = types.StringValue(response.MyField)
} else {
    state.MyField = types.StringNull()
}

Not recommended if you care about returning an empty string for the state.

nolint: contextcheck

func StringPtr

func StringPtr(in *string) basetypes.StringValue

func StringPtrDefault added in v1.11.0

func StringPtrDefault(in *string) basetypes.StringValue

func StringPtrDefaultNull added in v1.11.0

func StringPtrDefaultNull(in *string) basetypes.StringValue

Types

This section is empty.

Jump to

Keyboard shortcuts

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