types

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2022 License: MPL-2.0 Imports: 11 Imported by: 627

Documentation

Overview

Package types contains the framework-defined data types and values, such as boolean, floating point, integer, list, map, object, set, and string. These types can be extended by providers for custom use cases.

Index

Constants

View Source
const (
	// StringType represents a UTF-8 string type.
	StringType primitive = iota

	// NumberType represents a number type, either an integer or a float.
	NumberType

	// BoolType represents a boolean type.
	BoolType

	// Int64Type represents a 64-bit integer.
	Int64Type

	// Float64Type represents a 64-bit floating point.
	Float64Type
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Bool

type Bool struct {
	// Unknown will be true if the value is not yet known.
	//
	// If the Bool was created with the BoolValue, BoolNull, or BoolUnknown
	// functions, changing this field has no effect.
	//
	// Deprecated: Use the BoolUnknown function to create an unknown Bool
	// value or use the IsUnknown method to determine whether the Bool value
	// is unknown instead.
	Unknown bool

	// Null will be true if the value was not set, or was explicitly set to
	// null.
	//
	// If the Bool was created with the BoolValue, BoolNull, or BoolUnknown
	// functions, changing this field has no effect.
	//
	// Deprecated: Use the BoolNull function to create a null Bool value or
	// use the IsNull method to determine whether the Bool value is null
	// instead.
	Null bool

	// Value contains the set value, as long as Unknown and Null are both
	// false.
	//
	// If the Bool was created with the BoolValue, BoolNull, or BoolUnknown
	// functions, changing this field has no effect.
	//
	// Deprecated: Use the BoolValue function to create a known Bool value or
	// use the ValueBool method to retrieve the Bool value instead.
	Value bool
	// contains filtered or unexported fields
}

Bool represents a boolean value.

func BoolNull added in v0.15.0

func BoolNull() Bool

BoolNull creates a Bool with a null value. Determine whether the value is null via the Bool type IsNull method.

Setting the deprecated Bool type Null, Unknown, or Value fields after creating a Bool with this function has no effect.

func BoolUnknown added in v0.15.0

func BoolUnknown() Bool

BoolUnknown creates a Bool with an unknown value. Determine whether the value is unknown via the Bool type IsUnknown method.

Setting the deprecated Bool type Null, Unknown, or Value fields after creating a Bool with this function has no effect.

func BoolValue added in v0.15.0

func BoolValue(value bool) Bool

BoolValue creates a Bool with a known value. Access the value via the Bool type ValueBool method.

Setting the deprecated Bool type Null, Unknown, or Value fields after creating a Bool with this function has no effect.

func (Bool) Equal

func (b Bool) Equal(other attr.Value) bool

Equal returns true if `other` is a *Bool and has the same value as `b`.

func (Bool) IsNull added in v0.9.0

func (b Bool) IsNull() bool

IsNull returns true if the Bool represents a null value.

func (Bool) IsUnknown added in v0.9.0

func (b Bool) IsUnknown() bool

IsUnknown returns true if the Bool represents a currently unknown value.

func (Bool) String added in v0.9.0

func (b Bool) String() string

String returns a human-readable representation of the Bool value. The string returned here is not protected by any compatibility guarantees, and is intended for logging and error reporting.

func (Bool) ToTerraformValue

func (b Bool) ToTerraformValue(_ context.Context) (tftypes.Value, error)

ToTerraformValue returns the data contained in the Bool as a tftypes.Value.

func (Bool) Type added in v0.3.0

func (b Bool) Type(_ context.Context) attr.Type

Type returns a BoolType.

func (Bool) ValueBool added in v0.15.0

func (b Bool) ValueBool() bool

ValueBool returns the known bool value. If Bool is null or unknown, returns false.

type Float64 added in v0.4.0

type Float64 struct {
	// Unknown will be true if the value is not yet known.
	//
	// If the Float64 was created with the Float64Value, Float64Null, or Float64Unknown
	// functions, changing this field has no effect.
	//
	// Deprecated: Use the Float64Unknown function to create an unknown Float64
	// value or use the IsUnknown method to determine whether the Float64 value
	// is unknown instead.
	Unknown bool

	// Null will be true if the value was not set, or was explicitly set to
	// null.
	//
	// If the Float64 was created with the Float64Value, Float64Null, or Float64Unknown
	// functions, changing this field has no effect.
	//
	// Deprecated: Use the Float64Null function to create a null Float64 value or
	// use the IsNull method to determine whether the Float64 value is null
	// instead.
	Null bool

	// Value contains the set value, as long as Unknown and Null are both
	// false.
	//
	// If the Float64 was created with the Float64Value, Float64Null, or Float64Unknown
	// functions, changing this field has no effect.
	//
	// Deprecated: Use the Float64Value function to create a known Float64 value or
	// use the ValueFloat64 method to retrieve the Float64 value instead.
	Value float64
	// contains filtered or unexported fields
}

Float64 represents a 64-bit floating point value, exposed as a float64.

func Float64Null added in v0.15.0

func Float64Null() Float64

Float64Null creates a Float64 with a null value. Determine whether the value is null via the Float64 type IsNull method.

Setting the deprecated Float64 type Null, Unknown, or Value fields after creating a Float64 with this function has no effect.

func Float64Unknown added in v0.15.0

func Float64Unknown() Float64

Float64Unknown creates a Float64 with an unknown value. Determine whether the value is unknown via the Float64 type IsUnknown method.

Setting the deprecated Float64 type Null, Unknown, or Value fields after creating a Float64 with this function has no effect.

func Float64Value added in v0.15.0

func Float64Value(value float64) Float64

Float64Value creates a Float64 with a known value. Access the value via the Float64 type ValueFloat64 method.

Setting the deprecated Float64 type Null, Unknown, or Value fields after creating a Float64 with this function has no effect.

func (Float64) Equal added in v0.4.0

func (f Float64) Equal(other attr.Value) bool

Equal returns true if `other` is a Float64 and has the same value as `f`.

func (Float64) IsNull added in v0.9.0

func (f Float64) IsNull() bool

IsNull returns true if the Float64 represents a null value.

func (Float64) IsUnknown added in v0.9.0

func (f Float64) IsUnknown() bool

IsUnknown returns true if the Float64 represents a currently unknown value.

func (Float64) String added in v0.9.0

func (f Float64) String() string

String returns a human-readable representation of the Float64 value. The string returned here is not protected by any compatibility guarantees, and is intended for logging and error reporting.

func (Float64) ToTerraformValue added in v0.4.0

func (f Float64) ToTerraformValue(ctx context.Context) (tftypes.Value, error)

ToTerraformValue returns the data contained in the Float64 as a tftypes.Value.

func (Float64) Type added in v0.4.0

func (f Float64) Type(ctx context.Context) attr.Type

Type returns a Float64Type.

func (Float64) ValueFloat64 added in v0.15.0

func (f Float64) ValueFloat64() float64

ValueFloat64 returns the known float64 value. If Float64 is null or unknown, returns 0.0.

type Int64 added in v0.4.0

type Int64 struct {
	// Unknown will be true if the value is not yet known.
	//
	// If the Int64 was created with the Int64Value, Int64Null, or Int64Unknown
	// functions, changing this field has no effect.
	//
	// Deprecated: Use the Int64Unknown function to create an unknown Int64
	// value or use the IsUnknown method to determine whether the Int64 value
	// is unknown instead.
	Unknown bool

	// Null will be true if the value was not set, or was explicitly set to
	// null.
	//
	// If the Int64 was created with the Int64Value, Int64Null, or Int64Unknown
	// functions, changing this field has no effect.
	//
	// Deprecated: Use the Int64Null function to create a null Int64 value or
	// use the IsNull method to determine whether the Int64 value is null
	// instead.
	Null bool

	// Value contains the set value, as long as Unknown and Null are both
	// false.
	//
	// If the Int64 was created with the Int64Value, Int64Null, or Int64Unknown
	// functions, changing this field has no effect.
	//
	// Deprecated: Use the Int64Value function to create a known Int64 value or
	// use the ValueInt64 method to retrieve the Int64 value instead.
	Value int64
	// contains filtered or unexported fields
}

Int64 represents a 64-bit integer value, exposed as an int64.

func Int64Null added in v0.15.0

func Int64Null() Int64

Int64Null creates a Int64 with a null value. Determine whether the value is null via the Int64 type IsNull method.

Setting the deprecated Int64 type Null, Unknown, or Value fields after creating a Int64 with this function has no effect.

func Int64Unknown added in v0.15.0

func Int64Unknown() Int64

Int64Unknown creates a Int64 with an unknown value. Determine whether the value is unknown via the Int64 type IsUnknown method.

Setting the deprecated Int64 type Null, Unknown, or Value fields after creating a Int64 with this function has no effect.

func Int64Value added in v0.15.0

func Int64Value(value int64) Int64

Int64Value creates a Int64 with a known value. Access the value via the Int64 type ValueInt64 method.

Setting the deprecated Int64 type Null, Unknown, or Value fields after creating a Int64 with this function has no effect.

func (Int64) Equal added in v0.4.0

func (i Int64) Equal(other attr.Value) bool

Equal returns true if `other` is an Int64 and has the same value as `i`.

func (Int64) IsNull added in v0.9.0

func (i Int64) IsNull() bool

IsNull returns true if the Int64 represents a null value.

func (Int64) IsUnknown added in v0.9.0

func (i Int64) IsUnknown() bool

IsUnknown returns true if the Int64 represents a currently unknown value.

func (Int64) String added in v0.9.0

func (i Int64) String() string

String returns a human-readable representation of the Int64 value. The string returned here is not protected by any compatibility guarantees, and is intended for logging and error reporting.

func (Int64) ToTerraformValue added in v0.4.0

func (i Int64) ToTerraformValue(ctx context.Context) (tftypes.Value, error)

ToTerraformValue returns the data contained in the Int64 as a tftypes.Value.

func (Int64) Type added in v0.4.0

func (i Int64) Type(ctx context.Context) attr.Type

Type returns a Int64Type.

func (Int64) ValueInt64 added in v0.15.0

func (i Int64) ValueInt64() int64

ValueInt64 returns the known float64 value. If Int64 is null or unknown, returns 0.0.

type List

type List struct {
	// Unknown will be set to true if the entire list is an unknown value.
	// If only some of the elements in the list are unknown, their known or
	// unknown status will be represented however that attr.Value
	// surfaces that information. The List's Unknown property only tracks
	// if the number of elements in a List is known, not whether the
	// elements that are in the list are known.
	//
	// If the List was created with the ListValue, ListNull, or ListUnknown
	// functions, changing this field has no effect.
	//
	// Deprecated: Use the ListUnknown function to create an unknown List
	// value or use the IsUnknown method to determine whether the List value
	// is unknown instead.
	Unknown bool

	// Null will be set to true if the list is null, either because it was
	// omitted from the configuration, state, or plan, or because it was
	// explicitly set to null.
	//
	// If the List was created with the ListValue, ListNull, or ListUnknown
	// functions, changing this field has no effect.
	//
	// Deprecated: Use the ListNull function to create a null List value or
	// use the IsNull method to determine whether the List value is null
	// instead.
	Null bool

	// Elems are the elements in the list.
	//
	// If the List was created with the ListValue, ListNull, or ListUnknown
	// functions, changing this field has no effect.
	//
	// Deprecated: Use the ListValue function to create a known List value or
	// use the Elements or ElementsAs methods to retrieve the List elements
	// instead.
	Elems []attr.Value

	// ElemType is the tftypes.Type of the elements in the list. All
	// elements in the list must be of this type.
	//
	// Deprecated: Use the ListValue, ListNull, or ListUnknown functions
	// to create a List or use the ElementType method to retrieve the
	// List element type instead.
	ElemType attr.Type
	// contains filtered or unexported fields
}

List represents a list of attr.Values, all of the same type, indicated by ElemType.

func ListNull added in v0.15.0

func ListNull(elementType attr.Type) List

ListNull creates a List with a null value. Determine whether the value is null via the List type IsNull method.

Setting the deprecated List type ElemType, Elems, Null, or Unknown fields after creating a List with this function has no effect.

func ListUnknown added in v0.15.0

func ListUnknown(elementType attr.Type) List

ListUnknown creates a List with an unknown value. Determine whether the value is unknown via the List type IsUnknown method.

Setting the deprecated List type ElemType, Elems, Null, or Unknown fields after creating a List with this function has no effect.

func ListValue added in v0.15.0

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

ListValue creates a List with a known value. Access the value via the List type Elements or ElementsAs methods.

Setting the deprecated List type ElemType, Elems, Null, or Unknown fields after creating a List with this function has no effect.

func ListValueFrom added in v0.15.0

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

ListValueFrom creates a List with a known value, using reflection rules. The elements must be a slice which can convert into the given element type. Access the value via the List type Elements or ElementsAs methods.

func ListValueMust added in v0.15.0

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

ListValueMust creates a List with a known value, converting any diagnostics into a panic at runtime. Access the value via the List type Elements or ElementsAs methods.

This creation function is only recommended to create List values which will not potentially effect practitioners, such as testing, or exhaustively tested provider logic.

Setting the deprecated List type ElemType, Elems, Null, or Unknown fields after creating a List with this function has no effect.

func (List) ElementType added in v0.15.0

func (l List) ElementType(_ context.Context) attr.Type

ElementType returns the element type for the List.

func (List) Elements added in v0.15.0

func (l List) Elements() []attr.Value

Elements returns the collection of elements for the List. Returns nil if the List is null or unknown.

func (List) ElementsAs

func (l List) ElementsAs(ctx context.Context, target interface{}, allowUnhandled bool) diag.Diagnostics

ElementsAs populates `target` with the elements of the List, throwing an error if the elements cannot be stored in `target`.

func (List) Equal

func (l List) Equal(o attr.Value) bool

Equal returns true if the List is considered semantically equal (same type and same value) to the attr.Value passed as an argument.

func (List) IsNull added in v0.9.0

func (l List) IsNull() bool

IsNull returns true if the List represents a null value.

func (List) IsUnknown added in v0.9.0

func (l List) IsUnknown() bool

IsUnknown returns true if the List represents a currently unknown value. Returns false if the List has a known number of elements, even if all are unknown values.

func (List) String added in v0.9.0

func (l List) String() string

String returns a human-readable representation of the List value. The string returned here is not protected by any compatibility guarantees, and is intended for logging and error reporting.

func (List) ToTerraformValue

func (l List) ToTerraformValue(ctx context.Context) (tftypes.Value, error)

ToTerraformValue returns the data contained in the List as a tftypes.Value.

func (List) Type added in v0.3.0

func (l List) Type(ctx context.Context) attr.Type

Type returns a ListType with the same element type as `l`.

type ListType

type ListType struct {
	ElemType attr.Type
}

ListType is an AttributeType representing a list of values. All values must be of the same type, which the provider must specify as the ElemType property.

func (ListType) ApplyTerraform5AttributePathStep

func (l ListType) ApplyTerraform5AttributePathStep(step tftypes.AttributePathStep) (interface{}, error)

ApplyTerraform5AttributePathStep applies the given AttributePathStep to the list.

func (ListType) ElementType

func (l ListType) ElementType() attr.Type

ElementType returns the attr.Type elements will be created from.

func (ListType) Equal

func (l ListType) Equal(o attr.Type) bool

Equal returns true if `o` is also a ListType and has the same ElemType.

func (ListType) String added in v0.4.0

func (l ListType) String() string

String returns a human-friendly description of the ListType.

func (ListType) TerraformType

func (l ListType) TerraformType(ctx context.Context) tftypes.Type

TerraformType returns the tftypes.Type that should be used to represent this type. This constrains what user input will be accepted and what kind of data can be set in state. The framework will use this to translate the AttributeType to something Terraform can understand.

func (ListType) Validate added in v0.13.0

func (l ListType) Validate(ctx context.Context, in tftypes.Value, path path.Path) diag.Diagnostics

Validate validates all elements of the list that are of type xattr.TypeWithValidate.

func (ListType) ValueFromTerraform

func (l ListType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error)

ValueFromTerraform returns an attr.Value given a tftypes.Value. This is meant to convert the tftypes.Value into a more convenient Go type for the provider to consume the data with.

func (ListType) ValueType added in v0.14.0

func (t ListType) ValueType(_ context.Context) attr.Value

ValueType returns the Value type.

func (ListType) WithElementType

func (l ListType) WithElementType(typ attr.Type) attr.TypeWithElementType

WithElementType returns a ListType that is identical to `l`, but with the element type set to `typ`.

type Map

type Map struct {
	// Unknown will be set to true if the entire map is an unknown value.
	// If only some of the elements in the map are unknown, their known or
	// unknown status will be represented however that attr.Value
	// surfaces that information. The Map's Unknown property only tracks if
	// the number of elements in a Map is known, not whether the elements
	// that are in the map are known.
	//
	// If the Map was created with the MapValue, MapNull, or MapUnknown
	// functions, changing this field has no effect.
	//
	// Deprecated: Use the MapUnknown function to create an unknown Map
	// value or use the IsUnknown method to determine whether the Map value
	// is unknown instead.
	Unknown bool

	// Null will be set to true if the map is null, either because it was
	// omitted from the configuration, state, or plan, or because it was
	// explicitly set to null.
	//
	// If the Map was created with the MapValue, MapNull, or MapUnknown
	// functions, changing this field has no effect.
	//
	// Deprecated: Use the MapNull function to create a null Map value or
	// use the IsNull method to determine whether the Map value is null
	// instead.
	Null bool

	// Elems are the elements in the map.
	//
	// If the Map was created with the MapValue, MapNull, or MapUnknown
	// functions, changing this field has no effect.
	//
	// Deprecated: Use the MapValue function to create a known Map value or
	// use the Elements or ElementsAs methods to retrieve the Map elements
	// instead.
	Elems map[string]attr.Value

	// ElemType is the AttributeType of the elements in the map. All
	// elements in the map must be of this type.
	//
	// Deprecated: Use the MapValue, MapNull, or MapUnknown functions
	// to create a Map or use the ElementType method to retrieve the
	// Map element type instead.
	ElemType attr.Type
	// contains filtered or unexported fields
}

Map represents a mapping of string keys to attr.Value values of a single type.

func MapNull added in v0.15.0

func MapNull(elementType attr.Type) Map

MapNull creates a Map with a null value. Determine whether the value is null via the Map type IsNull method.

Setting the deprecated Map type ElemType, Elems, Null, or Unknown fields after creating a Map with this function has no effect.

func MapUnknown added in v0.15.0

func MapUnknown(elementType attr.Type) Map

MapUnknown creates a Map with an unknown value. Determine whether the value is unknown via the Map type IsUnknown method.

Setting the deprecated Map type ElemType, Elems, Null, or Unknown fields after creating a Map with this function has no effect.

func MapValue added in v0.15.0

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

MapValue creates a Map with a known value. Access the value via the Map type Elements or ElementsAs methods.

Setting the deprecated Map type ElemType, Elems, Null, or Unknown fields after creating a Map with this function has no effect.

func MapValueFrom added in v0.15.0

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

MapValueFrom creates a Map with a known value, using reflection rules. The elements must be a map of string keys to values which can convert into the given element type. Access the value via the Map type Elements or ElementsAs methods.

func MapValueMust added in v0.15.0

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

MapValueMust creates a Map with a known value, converting any diagnostics into a panic at runtime. Access the value via the Map type Elements or ElementsAs methods.

This creation function is only recommended to create Map values which will not potentially effect practitioners, such as testing, or exhaustively tested provider logic.

Setting the deprecated Map type ElemType, Elems, Null, or Unknown fields after creating a Map with this function has no effect.

func (Map) ElementType added in v0.15.0

func (m Map) ElementType(_ context.Context) attr.Type

ElementType returns the element type for the Map.

func (Map) Elements added in v0.15.0

func (m Map) Elements() map[string]attr.Value

Elements returns the mapping of elements for the Map. Returns nil if the Map is null or unknown.

func (Map) ElementsAs

func (m Map) ElementsAs(ctx context.Context, target interface{}, allowUnhandled bool) diag.Diagnostics

ElementsAs populates `target` with the elements of the Map, throwing an error if the elements cannot be stored in `target`.

func (Map) Equal

func (m Map) Equal(o attr.Value) bool

Equal returns true if the Map is considered semantically equal (same type and same value) to the attr.Value passed as an argument.

func (Map) IsNull added in v0.9.0

func (m Map) IsNull() bool

IsNull returns true if the Map represents a null value.

func (Map) IsUnknown added in v0.9.0

func (m Map) IsUnknown() bool

IsUnknown returns true if the Map represents a currently unknown value. Returns false if the Map has a known number of elements, even if all are unknown values.

func (Map) String added in v0.9.0

func (m Map) String() string

String returns a human-readable representation of the Map value. The string returned here is not protected by any compatibility guarantees, and is intended for logging and error reporting.

func (Map) ToTerraformValue

func (m Map) ToTerraformValue(ctx context.Context) (tftypes.Value, error)

ToTerraformValue returns the data contained in the List as a tftypes.Value.

func (Map) Type added in v0.3.0

func (m Map) Type(ctx context.Context) attr.Type

Type returns a MapType with the same element type as `m`.

type MapType

type MapType struct {
	ElemType attr.Type
}

MapType is an AttributeType representing a map of values. All values must be of the same type, which the provider must specify as the ElemType property. Keys will always be strings.

func (MapType) ApplyTerraform5AttributePathStep

func (m MapType) ApplyTerraform5AttributePathStep(step tftypes.AttributePathStep) (interface{}, error)

ApplyTerraform5AttributePathStep applies the given AttributePathStep to the map.

func (MapType) ElementType

func (m MapType) ElementType() attr.Type

ElementType returns the type's element type.

func (MapType) Equal

func (m MapType) Equal(o attr.Type) bool

Equal returns true if `o` is also a MapType and has the same ElemType.

func (MapType) String added in v0.4.0

func (m MapType) String() string

String returns a human-friendly description of the MapType.

func (MapType) TerraformType

func (m MapType) TerraformType(ctx context.Context) tftypes.Type

TerraformType returns the tftypes.Type that should be used to represent this type. This constrains what user input will be accepted and what kind of data can be set in state. The framework will use this to translate the AttributeType to something Terraform can understand.

func (MapType) Validate added in v0.13.0

func (m MapType) Validate(ctx context.Context, in tftypes.Value, path path.Path) diag.Diagnostics

Validate validates all elements of the map that are of type xattr.TypeWithValidate.

func (MapType) ValueFromTerraform

func (m MapType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error)

ValueFromTerraform returns an attr.Value given a tftypes.Value. This is meant to convert the tftypes.Value into a more convenient Go type for the provider to consume the data with.

func (MapType) ValueType added in v0.14.0

func (t MapType) ValueType(_ context.Context) attr.Value

ValueType returns the Value type.

func (MapType) WithElementType

func (m MapType) WithElementType(typ attr.Type) attr.TypeWithElementType

WithElementType returns a new copy of the type with its element type set.

type Number

type Number struct {
	// Unknown will be true if the value is not yet known.
	//
	// If the Number was created with the NumberValue, NumberNull, or NumberUnknown
	// functions, changing this field has no effect.
	//
	// Deprecated: Use the NumberUnknown function to create an unknown Number
	// value or use the IsUnknown method to determine whether the Number value
	// is unknown instead.
	Unknown bool

	// Null will be true if the value was not set, or was explicitly set to
	// null.
	//
	// If the Number was created with the NumberValue, NumberNull, or NumberUnknown
	// functions, changing this field has no effect.
	//
	// Deprecated: Use the NumberNull function to create a null Number value or
	// use the IsNull method to determine whether the Number value is null
	// instead.
	Null bool

	// Value contains the set value, as long as Unknown and Null are both
	// false.
	//
	// If the Number was created with the NumberValue, NumberNull, or NumberUnknown
	// functions, changing this field has no effect.
	//
	// Deprecated: Use the NumberValue function to create a known Number value or
	// use the ValueBigFloat method to retrieve the Number value instead.
	Value *big.Float
	// contains filtered or unexported fields
}

Number represents a number value, exposed as a *big.Float. Numbers can be floats or integers.

func NumberNull added in v0.15.0

func NumberNull() Number

NumberNull creates a Number with a null value. Determine whether the value is null via the Number type IsNull method.

Setting the deprecated Number type Null, Unknown, or Value fields after creating a Number with this function has no effect.

func NumberUnknown added in v0.15.0

func NumberUnknown() Number

NumberUnknown creates a Number with an unknown value. Determine whether the value is unknown via the Number type IsUnknown method.

Setting the deprecated Number type Null, Unknown, or Value fields after creating a Number with this function has no effect.

func NumberValue added in v0.15.0

func NumberValue(value *big.Float) Number

NumberValue creates a Number with a known value. Access the value via the Number type ValueBigFloat method. If the given value is nil, a null Number is created.

Setting the deprecated Number type Null, Unknown, or Value fields after creating a Number with this function has no effect.

func (Number) Equal

func (n Number) Equal(other attr.Value) bool

Equal returns true if `other` is a Number and has the same value as `n`.

func (Number) IsNull added in v0.9.0

func (n Number) IsNull() bool

IsNull returns true if the Number represents a null value.

func (Number) IsUnknown added in v0.9.0

func (n Number) IsUnknown() bool

IsUnknown returns true if the Number represents a currently unknown value.

func (Number) String added in v0.9.0

func (n Number) String() string

String returns a human-readable representation of the Number value. The string returned here is not protected by any compatibility guarantees, and is intended for logging and error reporting.

func (Number) ToTerraformValue

func (n Number) ToTerraformValue(_ context.Context) (tftypes.Value, error)

ToTerraformValue returns the data contained in the Number as a tftypes.Value.

func (Number) Type added in v0.3.0

func (n Number) Type(_ context.Context) attr.Type

Type returns a NumberType.

func (Number) ValueBigFloat added in v0.15.0

func (n Number) ValueBigFloat() *big.Float

ValueBigFloat returns the known *big.Float value. If Number is null or unknown, returns 0.0.

type Object

type Object struct {
	// Unknown will be set to true if the entire object is an unknown value.
	// If only some of the elements in the object are unknown, their known or
	// unknown status will be represented however that attr.Value
	// surfaces that information. The Object's Unknown property only tracks
	// if the number of elements in a Object is known, not whether the
	// elements that are in the object are known.
	//
	// If the Object was created with the ObjectValue, ObjectNull, or ObjectUnknown
	// functions, changing this field has no effect.
	//
	// Deprecated: Use the ObjectNull function to create a null Object value or
	// use the IsNull method to determine whether the Object value is null
	// instead.
	Unknown bool

	// Null will be set to true if the object is null, either because it was
	// omitted from the configuration, state, or plan, or because it was
	// explicitly set to null.
	//
	// If the Object was created with the ObjectValue, ObjectNull, or ObjectUnknown
	// functions, changing this field has no effect.
	//
	// Deprecated: Use the ObjectNull function to create a null Object value or
	// use the IsNull method to determine whether the Object value is null
	// instead.
	Null bool

	// Attrs is the mapping of known attribute values in the Object.
	//
	// If the Object was created with the ObjectValue, ObjectNull, or ObjectUnknown
	// functions, changing this field has no effect.
	//
	// Deprecated: Use the ObjectValue function to create a known Object value or
	// use the As or Attributes methods to retrieve the Object attributes
	// instead.
	Attrs map[string]attr.Value

	// AttrTypes is the mapping of attribute types in the Object. Required
	// for a valid Object.
	//
	// Deprecated: Use the ObjectValue, ObjectNull, or ObjectUnknown functions
	// to create a Object or use the AttributeTypes method to retrieve the
	// Object attribute types instead.
	AttrTypes map[string]attr.Type
	// contains filtered or unexported fields
}

Object represents an object

func ObjectNull added in v0.15.0

func ObjectNull(attributeTypes map[string]attr.Type) Object

ObjectNull creates a Object with a null value. Determine whether the value is null via the Object type IsNull method.

Setting the deprecated Object type AttrTypes, Attrs, Null, or Unknown fields after creating a Object with this function has no effect.

func ObjectUnknown added in v0.15.0

func ObjectUnknown(attributeTypes map[string]attr.Type) Object

ObjectUnknown creates a Object with an unknown value. Determine whether the value is unknown via the Object type IsUnknown method.

Setting the deprecated Object type AttrTypes, Attrs, Null, or Unknown fields after creating a Object with this function has no effect.

func ObjectValue added in v0.15.0

func ObjectValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (Object, diag.Diagnostics)

ObjectValue creates a Object with a known value. Access the value via the Object type ElementsAs method.

Setting the deprecated Object type AttrTypes, Attrs, Null, or Unknown fields after creating a Object with this function has no effect.

func ObjectValueFrom added in v0.15.0

func ObjectValueFrom(ctx context.Context, attributeTypes map[string]attr.Type, attributes any) (Object, diag.Diagnostics)

ObjectValueFrom creates a Object with a known value, using reflection rules. The attributes must be a map of string attribute names to attribute values which can convert into the given attribute type or a struct with tfsdk field tags. Access the value via the Object type Elements or ElementsAs methods.

func ObjectValueMust added in v0.15.0

func ObjectValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) Object

ObjectValueMust creates a Object with a known value, converting any diagnostics into a panic at runtime. Access the value via the Object type Elements or ElementsAs methods.

This creation function is only recommended to create Object values which will not potentially effect practitioners, such as testing, or exhaustively tested provider logic.

Objectting the deprecated Object type ElemType, Elems, Null, or Unknown fields after creating a Object with this function has no effect.

func (Object) As

func (o Object) As(ctx context.Context, target interface{}, opts ObjectAsOptions) diag.Diagnostics

As populates `target` with the data in the Object, throwing an error if the data cannot be stored in `target`.

func (Object) AttributeTypes added in v0.15.0

func (o Object) AttributeTypes(_ context.Context) map[string]attr.Type

AttributeTypes returns the mapping of attribute types for the Object.

func (Object) Attributes added in v0.15.0

func (o Object) Attributes() map[string]attr.Value

Attributes returns the mapping of known attribute values for the Object. Returns nil if the Object is null or unknown.

func (Object) Equal

func (o Object) Equal(c attr.Value) bool

Equal returns true if the Object is considered semantically equal (same type and same value) to the attr.Value passed as an argument.

func (Object) IsNull added in v0.9.0

func (o Object) IsNull() bool

IsNull returns true if the Object represents a null value.

func (Object) IsUnknown added in v0.9.0

func (o Object) IsUnknown() bool

IsUnknown returns true if the Object represents a currently unknown value.

func (Object) String added in v0.9.0

func (o Object) String() string

String returns a human-readable representation of the Object value. The string returned here is not protected by any compatibility guarantees, and is intended for logging and error reporting.

func (Object) ToTerraformValue

func (o Object) ToTerraformValue(ctx context.Context) (tftypes.Value, error)

ToTerraformValue returns the data contained in the attr.Value as a tftypes.Value.

func (Object) Type added in v0.3.0

func (o Object) Type(ctx context.Context) attr.Type

Type returns an ObjectType with the same attribute types as `o`.

type ObjectAsOptions

type ObjectAsOptions struct {
	// UnhandledNullAsEmpty controls what happens when As needs to put a
	// null value in a type that has no way to preserve that distinction.
	// When set to true, the type's empty value will be used.  When set to
	// false, an error will be returned.
	UnhandledNullAsEmpty bool

	// UnhandledUnknownAsEmpty controls what happens when As needs to put
	// an unknown value in a type that has no way to preserve that
	// distinction. When set to true, the type's empty value will be used.
	// When set to false, an error will be returned.
	UnhandledUnknownAsEmpty bool
}

ObjectAsOptions is a collection of toggles to control the behavior of Object.As.

type ObjectType

type ObjectType struct {
	AttrTypes map[string]attr.Type
}

ObjectType is an AttributeType representing an object.

func (ObjectType) ApplyTerraform5AttributePathStep

func (o ObjectType) ApplyTerraform5AttributePathStep(step tftypes.AttributePathStep) (interface{}, error)

ApplyTerraform5AttributePathStep applies the given AttributePathStep to the object.

func (ObjectType) AttributeTypes

func (o ObjectType) AttributeTypes() map[string]attr.Type

AttributeTypes returns the type's attribute types.

func (ObjectType) Equal

func (o ObjectType) Equal(candidate attr.Type) bool

Equal returns true if `candidate` is also an ObjectType and has the same AttributeTypes.

func (ObjectType) String added in v0.4.0

func (o ObjectType) String() string

String returns a human-friendly description of the ObjectType.

func (ObjectType) TerraformType

func (o ObjectType) TerraformType(ctx context.Context) tftypes.Type

TerraformType returns the tftypes.Type that should be used to represent this type. This constrains what user input will be accepted and what kind of data can be set in state. The framework will use this to translate the AttributeType to something Terraform can understand.

func (ObjectType) ValueFromTerraform

func (o ObjectType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error)

ValueFromTerraform returns an attr.Value given a tftypes.Value. This is meant to convert the tftypes.Value into a more convenient Go type for the provider to consume the data with.

func (ObjectType) ValueType added in v0.14.0

func (t ObjectType) ValueType(_ context.Context) attr.Value

ValueType returns the Value type.

func (ObjectType) WithAttributeTypes

func (o ObjectType) WithAttributeTypes(typs map[string]attr.Type) attr.TypeWithAttributeTypes

WithAttributeTypes returns a new copy of the type with its attribute types set.

type Set added in v0.4.0

type Set struct {
	// Unknown will be set to true if the entire set is an unknown value.
	// If only some of the elements in the set are unknown, their known or
	// unknown status will be represented however that attr.Value
	// surfaces that information. The Set's Unknown property only tracks
	// if the number of elements in a Set is known, not whether the
	// elements that are in the set are known.
	//
	// If the Set was created with the SetValue, SetNull, or SetUnknown
	// functions, changing this field has no effect.
	//
	// Deprecated: Use the SetUnknown function to create an unknown Set
	// value or use the IsUnknown method to determine whether the Set value
	// is unknown instead.
	Unknown bool

	// Null will be set to true if the set is null, either because it was
	// omitted from the configuration, state, or plan, or because it was
	// explicitly set to null.
	//
	// If the Set was created with the SetValue, SetNull, or SetUnknown
	// functions, changing this field has no effect.
	//
	// Deprecated: Use the SetNull function to create a null Set value or
	// use the IsNull method to determine whether the Set value is null
	// instead.
	Null bool

	// Elems are the elements in the set.
	//
	// If the Set was created with the SetValue, SetNull, or SetUnknown
	// functions, changing this field has no effect.
	//
	// Deprecated: Use the SetValue function to create a known Set value or
	// use the Elements or ElementsAs methods to retrieve the Set elements
	// instead.
	Elems []attr.Value

	// ElemType is the tftypes.Type of the elements in the set. All
	// elements in the set must be of this type.
	//
	// Deprecated: Use the SetValue, SetNull, or SetUnknown functions
	// to create a Set or use the ElementType method to retrieve the
	// Set element type instead.
	ElemType attr.Type
	// contains filtered or unexported fields
}

Set represents a set of attr.Value, all of the same type, indicated by ElemType.

func SetNull added in v0.15.0

func SetNull(elementType attr.Type) Set

SetNull creates a Set with a null value. Determine whether the value is null via the Set type IsNull method.

Setting the deprecated Set type ElemType, Elems, Null, or Unknown fields after creating a Set with this function has no effect.

func SetUnknown added in v0.15.0

func SetUnknown(elementType attr.Type) Set

SetUnknown creates a Set with an unknown value. Determine whether the value is unknown via the Set type IsUnknown method.

Setting the deprecated Set type ElemType, Elems, Null, or Unknown fields after creating a Set with this function has no effect.

func SetValue added in v0.15.0

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

SetValue creates a Set with a known value. Access the value via the Set type Elements or ElementsAs methods.

Setting the deprecated Set type ElemType, Elems, Null, or Unknown fields after creating a Set with this function has no effect.

func SetValueFrom added in v0.15.0

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

SetValueFrom creates a Set with a known value, using reflection rules. The elements must be a slice which can convert into the given element type. Access the value via the Set type Elements or ElementsAs methods.

func SetValueMust added in v0.15.0

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

SetValueMust creates a Set with a known value, converting any diagnostics into a panic at runtime. Access the value via the Set type Elements or ElementsAs methods.

This creation function is only recommended to create Set values which will not potentially effect practitioners, such as testing, or exhaustively tested provider logic.

Setting the deprecated Set type ElemType, Elems, Null, or Unknown fields after creating a Set with this function has no effect.

func (Set) ElementType added in v0.15.0

func (s Set) ElementType(_ context.Context) attr.Type

ElementType returns the element type for the Set.

func (Set) Elements added in v0.15.0

func (s Set) Elements() []attr.Value

Elements returns the collection of elements for the Set. Returns nil if the Set is null or unknown.

func (Set) ElementsAs added in v0.4.0

func (s Set) ElementsAs(ctx context.Context, target interface{}, allowUnhandled bool) diag.Diagnostics

ElementsAs populates `target` with the elements of the Set, throwing an error if the elements cannot be stored in `target`.

func (Set) Equal added in v0.4.0

func (s Set) Equal(o attr.Value) bool

Equal returns true if the Set is considered semantically equal (same type and same value) to the attr.Value passed as an argument.

func (Set) IsNull added in v0.9.0

func (s Set) IsNull() bool

IsNull returns true if the Set represents a null value.

func (Set) IsUnknown added in v0.9.0

func (s Set) IsUnknown() bool

IsUnknown returns true if the Set represents a currently unknown value. Returns false if the Set has a known number of elements, even if all are unknown values.

func (Set) String added in v0.9.0

func (s Set) String() string

String returns a human-readable representation of the Set value. The string returned here is not protected by any compatibility guarantees, and is intended for logging and error reporting.

func (Set) ToTerraformValue added in v0.4.0

func (s Set) ToTerraformValue(ctx context.Context) (tftypes.Value, error)

ToTerraformValue returns the data contained in the Set as a tftypes.Value.

func (Set) Type added in v0.4.0

func (s Set) Type(ctx context.Context) attr.Type

Type returns a SetType with the same element type as `s`.

type SetType added in v0.4.0

type SetType struct {
	ElemType attr.Type
}

SetType is an AttributeType representing a set of values. All values must be of the same type, which the provider must specify as the ElemType property.

func (SetType) ApplyTerraform5AttributePathStep added in v0.4.0

func (st SetType) ApplyTerraform5AttributePathStep(step tftypes.AttributePathStep) (interface{}, error)

ApplyTerraform5AttributePathStep applies the given AttributePathStep to the set.

func (SetType) ElementType added in v0.4.0

func (st SetType) ElementType() attr.Type

ElementType returns the attr.Type elements will be created from.

func (SetType) Equal added in v0.4.0

func (st SetType) Equal(o attr.Type) bool

Equal returns true if `o` is also a SetType and has the same ElemType.

func (SetType) String added in v0.4.0

func (st SetType) String() string

String returns a human-friendly description of the SetType.

func (SetType) TerraformType added in v0.4.0

func (st SetType) TerraformType(ctx context.Context) tftypes.Type

TerraformType returns the tftypes.Type that should be used to represent this type. This constrains what user input will be accepted and what kind of data can be set in state. The framework will use this to translate the AttributeType to something Terraform can understand.

func (SetType) Validate added in v0.4.0

func (st SetType) Validate(ctx context.Context, in tftypes.Value, path path.Path) diag.Diagnostics

Validate implements type validation. This type requires all elements to be unique.

func (SetType) ValueFromTerraform added in v0.4.0

func (st SetType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error)

ValueFromTerraform returns an attr.Value given a tftypes.Value. This is meant to convert the tftypes.Value into a more convenient Go type for the provider to consume the data with.

func (SetType) ValueType added in v0.14.0

func (t SetType) ValueType(_ context.Context) attr.Value

ValueType returns the Value type.

func (SetType) WithElementType added in v0.4.0

func (st SetType) WithElementType(typ attr.Type) attr.TypeWithElementType

WithElementType returns a SetType that is identical to `l`, but with the element type set to `typ`.

type String

type String struct {
	// Unknown will be true if the value is not yet known.
	//
	// If the String was created with the StringValue, StringNull, or StringUnknown
	// functions, changing this field has no effect.
	//
	// Deprecated: Use the StringUnknown function to create an unknown String
	// value or use the IsUnknown method to determine whether the String value
	// is unknown instead.
	Unknown bool

	// Null will be true if the value was not set, or was explicitly set to
	// null.
	//
	// If the String was created with the StringValue, StringNull, or StringUnknown
	// functions, changing this field has no effect.
	//
	// Deprecated: Use the StringNull function to create a null String value or
	// use the IsNull method to determine whether the String value is null
	// instead.
	Null bool

	// Value contains the set value, as long as Unknown and Null are both
	// false.
	//
	// If the String was created with the StringValue, StringNull, or StringUnknown
	// functions, changing this field has no effect.
	//
	// Deprecated: Use the StringValue function to create a known String value or
	// use the ValueString method to retrieve the String value instead.
	Value string
	// contains filtered or unexported fields
}

String represents a UTF-8 string value.

func StringNull added in v0.15.0

func StringNull() String

StringNull creates a String with a null value. Determine whether the value is null via the String type IsNull method.

Setting the deprecated String type Null, Unknown, or Value fields after creating a String with this function has no effect.

func StringUnknown added in v0.15.0

func StringUnknown() String

StringUnknown creates a String with an unknown value. Determine whether the value is unknown via the String type IsUnknown method.

Setting the deprecated String type Null, Unknown, or Value fields after creating a String with this function has no effect.

func StringValue added in v0.15.0

func StringValue(value string) String

StringValue creates a String with a known value. Access the value via the String type ValueString method.

Setting the deprecated String type Null, Unknown, or Value fields after creating a String with this function has no effect.

func (String) Equal

func (s String) Equal(other attr.Value) bool

Equal returns true if `other` is a String and has the same value as `s`.

func (String) IsNull added in v0.9.0

func (s String) IsNull() bool

IsNull returns true if the String represents a null value.

func (String) IsUnknown added in v0.9.0

func (s String) IsUnknown() bool

IsUnknown returns true if the String represents a currently unknown value.

func (String) String added in v0.9.0

func (s String) String() string

String returns a human-readable representation of the String value. Use the ValueString method for Terraform data handling instead.

The string returned here is not protected by any compatibility guarantees, and is intended for logging and error reporting.

func (String) ToTerraformValue

func (s String) ToTerraformValue(_ context.Context) (tftypes.Value, error)

ToTerraformValue returns the data contained in the *String as a tftypes.Value.

func (String) Type added in v0.3.0

func (s String) Type(_ context.Context) attr.Type

Type returns a StringType.

func (String) ValueString added in v0.15.0

func (s String) ValueString() string

ValueString returns the known string value. If String is null or unknown, returns "".

Jump to

Keyboard shortcuts

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