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
- type Bool
- func (b Bool) Equal(other attr.Value) bool
- func (b Bool) IsNull() bool
- func (b Bool) IsUnknown() bool
- func (b Bool) String() string
- func (b Bool) ToBoolValue(context.Context) (Bool, diag.Diagnostics)
- func (b Bool) ToTerraformValue(_ context.Context) (tftypes.Value, error)
- func (b Bool) Type(_ context.Context) attr.Type
- func (b Bool) ValueBool() bool
- type BoolTypable
- type BoolValuable
- type Float64
- func (f Float64) Equal(other attr.Value) bool
- func (f Float64) IsNull() bool
- func (f Float64) IsUnknown() bool
- func (f Float64) String() string
- func (f Float64) ToFloat64Value(context.Context) (Float64, diag.Diagnostics)
- func (f Float64) ToTerraformValue(ctx context.Context) (tftypes.Value, error)
- func (f Float64) Type(ctx context.Context) attr.Type
- func (f Float64) ValueFloat64() float64
- type Float64Typable
- type Float64Valuable
- type Int64
- func (i Int64) Equal(other attr.Value) bool
- func (i Int64) IsNull() bool
- func (i Int64) IsUnknown() bool
- func (i Int64) String() string
- func (i Int64) ToInt64Value(context.Context) (Int64, diag.Diagnostics)
- func (i Int64) ToTerraformValue(ctx context.Context) (tftypes.Value, error)
- func (i Int64) Type(ctx context.Context) attr.Type
- func (i Int64) ValueInt64() int64
- type Int64Typable
- type Int64Valuable
- type List
- func ListNull(elementType attr.Type) List
- func ListUnknown(elementType attr.Type) List
- func ListValue(elementType attr.Type, elements []attr.Value) (List, diag.Diagnostics)
- func ListValueFrom(ctx context.Context, elementType attr.Type, elements any) (List, diag.Diagnostics)
- func ListValueMust(elementType attr.Type, elements []attr.Value) List
- func (l List) ElementType(_ context.Context) attr.Type
- func (l List) Elements() []attr.Value
- func (l List) ElementsAs(ctx context.Context, target interface{}, allowUnhandled bool) diag.Diagnostics
- func (l List) Equal(o attr.Value) bool
- func (l List) IsNull() bool
- func (l List) IsUnknown() bool
- func (l List) String() string
- func (l List) ToListValue(context.Context) (List, diag.Diagnostics)
- func (l List) ToTerraformValue(ctx context.Context) (tftypes.Value, error)
- func (l List) Type(ctx context.Context) attr.Type
- type ListTypable
- type ListType
- func (l ListType) ApplyTerraform5AttributePathStep(step tftypes.AttributePathStep) (interface{}, error)
- func (l ListType) ElementType() attr.Type
- func (l ListType) Equal(o attr.Type) bool
- func (l ListType) String() string
- func (l ListType) TerraformType(ctx context.Context) tftypes.Type
- func (l ListType) Validate(ctx context.Context, in tftypes.Value, path path.Path) diag.Diagnostics
- func (l ListType) ValueFromList(_ context.Context, list List) (ListValuable, diag.Diagnostics)
- func (l ListType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error)
- func (l ListType) ValueType(_ context.Context) attr.Value
- func (l ListType) WithElementType(typ attr.Type) attr.TypeWithElementType
- type ListValuable
- type Map
- func MapNull(elementType attr.Type) Map
- func MapUnknown(elementType attr.Type) Map
- func MapValue(elementType attr.Type, elements map[string]attr.Value) (Map, diag.Diagnostics)
- func MapValueFrom(ctx context.Context, elementType attr.Type, elements any) (Map, diag.Diagnostics)
- func MapValueMust(elementType attr.Type, elements map[string]attr.Value) Map
- func (m Map) ElementType(_ context.Context) attr.Type
- func (m Map) Elements() map[string]attr.Value
- func (m Map) ElementsAs(ctx context.Context, target interface{}, allowUnhandled bool) diag.Diagnostics
- func (m Map) Equal(o attr.Value) bool
- func (m Map) IsNull() bool
- func (m Map) IsUnknown() bool
- func (m Map) String() string
- func (m Map) ToMapValue(context.Context) (Map, diag.Diagnostics)
- func (m Map) ToTerraformValue(ctx context.Context) (tftypes.Value, error)
- func (m Map) Type(ctx context.Context) attr.Type
- type MapTypable
- type MapType
- func (m MapType) ApplyTerraform5AttributePathStep(step tftypes.AttributePathStep) (interface{}, error)
- func (m MapType) ElementType() attr.Type
- func (m MapType) Equal(o attr.Type) bool
- func (m MapType) String() string
- func (m MapType) TerraformType(ctx context.Context) tftypes.Type
- func (m MapType) Validate(ctx context.Context, in tftypes.Value, path path.Path) diag.Diagnostics
- func (m MapType) ValueFromMap(_ context.Context, ma Map) (MapValuable, diag.Diagnostics)
- func (m MapType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error)
- func (m MapType) ValueType(_ context.Context) attr.Value
- func (m MapType) WithElementType(typ attr.Type) attr.TypeWithElementType
- type MapValuable
- type Number
- func (n Number) Equal(other attr.Value) bool
- func (n Number) IsNull() bool
- func (n Number) IsUnknown() bool
- func (n Number) String() string
- func (n Number) ToNumberValue(context.Context) (Number, diag.Diagnostics)
- func (n Number) ToTerraformValue(_ context.Context) (tftypes.Value, error)
- func (n Number) Type(_ context.Context) attr.Type
- func (n Number) ValueBigFloat() *big.Float
- type NumberTypable
- type NumberValuable
- type Object
- func ObjectNull(attributeTypes map[string]attr.Type) Object
- func ObjectUnknown(attributeTypes map[string]attr.Type) Object
- func ObjectValue(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) (Object, diag.Diagnostics)
- func ObjectValueFrom(ctx context.Context, attributeTypes map[string]attr.Type, attributes any) (Object, diag.Diagnostics)
- func ObjectValueMust(attributeTypes map[string]attr.Type, attributes map[string]attr.Value) Object
- func (o Object) As(ctx context.Context, target interface{}, opts ObjectAsOptions) diag.Diagnostics
- func (o Object) AttributeTypes(_ context.Context) map[string]attr.Type
- func (o Object) Attributes() map[string]attr.Value
- func (o Object) Equal(c attr.Value) bool
- func (o Object) IsNull() bool
- func (o Object) IsUnknown() bool
- func (o Object) String() string
- func (o Object) ToObjectValue(context.Context) (Object, diag.Diagnostics)
- func (o Object) ToTerraformValue(ctx context.Context) (tftypes.Value, error)
- func (o Object) Type(ctx context.Context) attr.Type
- type ObjectAsOptions
- type ObjectTypable
- type ObjectType
- func (o ObjectType) ApplyTerraform5AttributePathStep(step tftypes.AttributePathStep) (interface{}, error)
- func (o ObjectType) AttributeTypes() map[string]attr.Type
- func (o ObjectType) Equal(candidate attr.Type) bool
- func (o ObjectType) String() string
- func (o ObjectType) TerraformType(ctx context.Context) tftypes.Type
- func (o ObjectType) ValueFromObject(_ context.Context, obj Object) (ObjectValuable, diag.Diagnostics)
- func (o ObjectType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error)
- func (o ObjectType) ValueType(_ context.Context) attr.Value
- func (o ObjectType) WithAttributeTypes(typs map[string]attr.Type) attr.TypeWithAttributeTypes
- type ObjectValuable
- type Set
- func SetNull(elementType attr.Type) Set
- func SetUnknown(elementType attr.Type) Set
- func SetValue(elementType attr.Type, elements []attr.Value) (Set, diag.Diagnostics)
- func SetValueFrom(ctx context.Context, elementType attr.Type, elements any) (Set, diag.Diagnostics)
- func SetValueMust(elementType attr.Type, elements []attr.Value) Set
- func (s Set) ElementType(_ context.Context) attr.Type
- func (s Set) Elements() []attr.Value
- func (s Set) ElementsAs(ctx context.Context, target interface{}, allowUnhandled bool) diag.Diagnostics
- func (s Set) Equal(o attr.Value) bool
- func (s Set) IsNull() bool
- func (s Set) IsUnknown() bool
- func (s Set) String() string
- func (s Set) ToSetValue(context.Context) (Set, diag.Diagnostics)
- func (s Set) ToTerraformValue(ctx context.Context) (tftypes.Value, error)
- func (s Set) Type(ctx context.Context) attr.Type
- type SetTypable
- type SetType
- func (st SetType) ApplyTerraform5AttributePathStep(step tftypes.AttributePathStep) (interface{}, error)
- func (st SetType) ElementType() attr.Type
- func (st SetType) Equal(o attr.Type) bool
- func (st SetType) String() string
- func (st SetType) TerraformType(ctx context.Context) tftypes.Type
- func (st SetType) Validate(ctx context.Context, in tftypes.Value, path path.Path) diag.Diagnostics
- func (st SetType) ValueFromSet(_ context.Context, set Set) (SetValuable, diag.Diagnostics)
- func (st SetType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error)
- func (st SetType) ValueType(_ context.Context) attr.Value
- func (st SetType) WithElementType(typ attr.Type) attr.TypeWithElementType
- type SetValuable
- type String
- func (s String) Equal(other attr.Value) bool
- func (s String) IsNull() bool
- func (s String) IsUnknown() bool
- func (s String) String() string
- func (s String) ToStringValue(context.Context) (String, diag.Diagnostics)
- func (s String) ToTerraformValue(_ context.Context) (tftypes.Value, error)
- func (s String) Type(_ context.Context) attr.Type
- func (s String) ValueString() string
- type StringTypable
- type StringValuable
Constants ¶
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 {
// 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
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) IsUnknown ¶ added in v0.9.0
IsUnknown returns true if the Bool represents a currently unknown value.
func (Bool) String ¶ added in v0.9.0
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) ToBoolValue ¶ added in v0.16.0
ToBoolValue returns Bool.
func (Bool) ToTerraformValue ¶
ToTerraformValue returns the data contained in the Bool as a tftypes.Value.
type BoolTypable ¶ added in v0.16.0
type BoolTypable interface { attr.Type // ValueFromBool should convert the Bool to a BoolValuable type. ValueFromBool(context.Context, Bool) (BoolValuable, diag.Diagnostics) }
BoolTypable extends attr.Type for bool types. Implement this interface to create a custom BoolType type.
type BoolValuable ¶ added in v0.16.0
type BoolValuable interface { attr.Value // ToBoolValue should convert the value type to a Bool. ToBoolValue(ctx context.Context) (Bool, diag.Diagnostics) }
BoolValuable extends attr.Value for boolean value types. Implement this interface to create a custom Bool value type.
type Float64 ¶ added in v0.4.0
type Float64 struct {
// 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
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
Equal returns true if `other` is a Float64 and has the same value as `f`.
func (Float64) IsUnknown ¶ added in v0.9.0
IsUnknown returns true if the Float64 represents a currently unknown value.
func (Float64) String ¶ added in v0.9.0
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) ToFloat64Value ¶ added in v0.16.0
ToFloat64Value returns Float64.
func (Float64) ToTerraformValue ¶ added in v0.4.0
ToTerraformValue returns the data contained in the Float64 as a tftypes.Value.
func (Float64) ValueFloat64 ¶ added in v0.15.0
ValueFloat64 returns the known float64 value. If Float64 is null or unknown, returns 0.0.
type Float64Typable ¶ added in v0.16.0
type Float64Typable interface { xattr.TypeWithValidate // ValueFromFloat64 should convert the Float64 to a Float64Valuable type. ValueFromFloat64(context.Context, Float64) (Float64Valuable, diag.Diagnostics) }
Float64Typable extends attr.Type for float64 types. Implement this interface to create a custom Float64Type type.
type Float64Valuable ¶ added in v0.16.0
type Float64Valuable interface { attr.Value // ToFloat64Value should convert the value type to a Float64. ToFloat64Value(ctx context.Context) (Float64, diag.Diagnostics) }
Float64Valuable extends attr.Value for float64 value types. Implement this interface to create a custom Float64 value type.
type Int64 ¶ added in v0.4.0
type Int64 struct {
// 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
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
Equal returns true if `other` is an Int64 and has the same value as `i`.
func (Int64) IsUnknown ¶ added in v0.9.0
IsUnknown returns true if the Int64 represents a currently unknown value.
func (Int64) String ¶ added in v0.9.0
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) ToInt64Value ¶ added in v0.16.0
ToInt64Value returns Int64.
func (Int64) ToTerraformValue ¶ added in v0.4.0
ToTerraformValue returns the data contained in the Int64 as a tftypes.Value.
func (Int64) ValueInt64 ¶ added in v0.15.0
ValueInt64 returns the known float64 value. If Int64 is null or unknown, returns 0.0.
type Int64Typable ¶ added in v0.16.0
type Int64Typable interface { xattr.TypeWithValidate // ValueFromInt64 should convert the Int64 to a Int64Valuable type. ValueFromInt64(context.Context, Int64) (Int64Valuable, diag.Diagnostics) }
Int64Typable extends attr.Type for int64 types. Implement this interface to create a custom Int64Type type.
type Int64Valuable ¶ added in v0.16.0
type Int64Valuable interface { attr.Value // ToInt64Value should convert the value type to an Int64. ToInt64Value(ctx context.Context) (Int64, diag.Diagnostics) }
Int64Valuable extends attr.Value for int64 value types. Implement this interface to create a custom Int64 value type.
type List ¶
type List struct {
// 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
ListNull creates a List with a null value. Determine whether the value is null via the List type IsNull method.
func ListUnknown ¶ added in v0.15.0
ListUnknown creates a List with an unknown value. Determine whether the value is unknown via the List type IsUnknown method.
func ListValue ¶ added in v0.15.0
ListValue creates a List with a known value. Access the value via the List type Elements or ElementsAs methods.
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
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 affect practitioners, such as testing, or exhaustively tested provider logic.
func (List) ElementType ¶ added in v0.15.0
ElementType returns the element type for the List.
func (List) Elements ¶ added in v0.15.0
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 ¶
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) IsUnknown ¶ added in v0.9.0
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
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) ToListValue ¶ added in v0.16.0
ToListValue returns the List.
func (List) ToTerraformValue ¶
ToTerraformValue returns the data contained in the List as a tftypes.Value.
type ListTypable ¶ added in v0.16.0
type ListTypable interface { attr.Type // ValueFromList should convert the List to a ListValuable type. ValueFromList(context.Context, List) (ListValuable, diag.Diagnostics) }
ListTypable extends attr.Type for list types. Implement this interface to create a custom ListType type.
type ListType ¶
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 ¶
ElementType returns the attr.Type elements will be created from.
func (ListType) String ¶ added in v0.4.0
String returns a human-friendly description of the ListType.
func (ListType) TerraformType ¶
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
Validate validates all elements of the list that are of type xattr.TypeWithValidate.
func (ListType) ValueFromList ¶ added in v0.16.0
func (l ListType) ValueFromList(_ context.Context, list List) (ListValuable, diag.Diagnostics)
ValueFromList returns a ListValuable type given a List.
func (ListType) ValueFromTerraform ¶
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) 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 ListValuable ¶ added in v0.16.0
type ListValuable interface { attr.Value // ToListValue should convert the value type to a List. ToListValue(ctx context.Context) (List, diag.Diagnostics) }
ListValuable extends attr.Value for list value types. Implement this interface to create a custom List value type.
type Map ¶
type Map struct {
// 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
MapNull creates a Map with a null value. Determine whether the value is null via the Map type IsNull method.
func MapUnknown ¶ added in v0.15.0
MapUnknown creates a Map with an unknown value. Determine whether the value is unknown via the Map type IsUnknown method.
func MapValue ¶ added in v0.15.0
MapValue creates a Map with a known value. Access the value via the Map type Elements or ElementsAs methods.
func MapValueFrom ¶ added in v0.15.0
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
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.
func (Map) ElementType ¶ added in v0.15.0
ElementType returns the element type for the Map.
func (Map) Elements ¶ added in v0.15.0
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 ¶
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) IsUnknown ¶ added in v0.9.0
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
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) ToMapValue ¶ added in v0.16.0
ToMapValue returns the Map.
func (Map) ToTerraformValue ¶
ToTerraformValue returns the data contained in the Map as a tftypes.Value.
type MapTypable ¶ added in v0.16.0
type MapTypable interface { attr.Type // ValueFromMap should convert the Map to a MapValuable type. ValueFromMap(context.Context, Map) (MapValuable, diag.Diagnostics) }
MapTypable extends attr.Type for map types. Implement this interface to create a custom MapType type.
type MapType ¶
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 ¶
ElementType returns the type's element type.
func (MapType) TerraformType ¶
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
Validate validates all elements of the map that are of type xattr.TypeWithValidate.
func (MapType) ValueFromMap ¶ added in v0.16.0
func (m MapType) ValueFromMap(_ context.Context, ma Map) (MapValuable, diag.Diagnostics)
ValueFromMap returns a MapValuable type given a Map.
func (MapType) ValueFromTerraform ¶
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) WithElementType ¶
func (m MapType) WithElementType(typ attr.Type) attr.TypeWithElementType
WithElementType returns a new copy of the type with its element type set.
type MapValuable ¶ added in v0.16.0
type MapValuable interface { attr.Value // ToMapValue should convert the value type to a Map. ToMapValue(ctx context.Context) (Map, diag.Diagnostics) }
MapValuable extends attr.Value for map value types. Implement this interface to create a custom Map value type.
type Number ¶
type Number struct {
// 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
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) IsUnknown ¶ added in v0.9.0
IsUnknown returns true if the Number represents a currently unknown value.
func (Number) String ¶ added in v0.9.0
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) ToNumberValue ¶ added in v0.16.0
ToNumberValue returns Number.
func (Number) ToTerraformValue ¶
ToTerraformValue returns the data contained in the Number as a tftypes.Value.
func (Number) ValueBigFloat ¶ added in v0.15.0
ValueBigFloat returns the known *big.Float value. If Number is null or unknown, returns 0.0.
type NumberTypable ¶ added in v0.16.0
type NumberTypable interface { attr.Type // ValueFromNumber should convert the Number to a NumberValuable type. ValueFromNumber(context.Context, Number) (NumberValuable, diag.Diagnostics) }
NumberTypable extends attr.Type for number types. Implement this interface to create a custom NumberType type.
type NumberValuable ¶ added in v0.16.0
type NumberValuable interface { attr.Value // ToNumberValue should convert the value type to a Number. ToNumberValue(ctx context.Context) (Number, diag.Diagnostics) }
NumberValuable extends attr.Value for number value types. Implement this interface to create a custom Number value type.
type Object ¶
type Object struct {
// contains filtered or unexported fields
}
Object represents an object
func ObjectNull ¶ added in v0.15.0
ObjectNull creates a Object with a null value. Determine whether the value is null via the Object type IsNull method.
func ObjectUnknown ¶ added in v0.15.0
ObjectUnknown creates a Object with an unknown value. Determine whether the value is unknown via the Object type IsUnknown method.
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.
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
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.
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
AttributeTypes returns the mapping of attribute types for the Object.
func (Object) Attributes ¶ added in v0.15.0
Attributes returns the mapping of known attribute values for the Object. Returns nil if the Object is null or unknown.
func (Object) Equal ¶
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) IsUnknown ¶ added in v0.9.0
IsUnknown returns true if the Object represents a currently unknown value.
func (Object) String ¶ added in v0.9.0
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) ToObjectValue ¶ added in v0.16.0
ToObjectValue returns the Object.
func (Object) ToTerraformValue ¶
ToTerraformValue returns the data contained in the attr.Value as a tftypes.Value.
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 ObjectTypable ¶ added in v0.16.0
type ObjectTypable interface { attr.Type // ValueFromObject should convert the Object to an ObjectValuable type. ValueFromObject(context.Context, Object) (ObjectValuable, diag.Diagnostics) }
ObjectTypable extends attr.Type for object types. Implement this interface to create a custom ObjectType type.
type ObjectType ¶
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) ValueFromObject ¶ added in v0.16.0
func (o ObjectType) ValueFromObject(_ context.Context, obj Object) (ObjectValuable, diag.Diagnostics)
ValueFromObject returns an ObjectValuable type given an Object.
func (ObjectType) ValueFromTerraform ¶
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 (o 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 ObjectValuable ¶ added in v0.16.0
type ObjectValuable interface { attr.Value // ToObjectValue should convert the value type to an Object. ToObjectValue(ctx context.Context) (Object, diag.Diagnostics) }
ObjectValuable extends attr.Value for object value types. Implement this interface to create a custom Object value type.
type Set ¶ added in v0.4.0
type Set struct {
// 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
SetNull creates a Set with a null value. Determine whether the value is null via the Set type IsNull method.
func SetUnknown ¶ added in v0.15.0
SetUnknown creates a Set with an unknown value. Determine whether the value is unknown via the Set type IsUnknown method.
func SetValue ¶ added in v0.15.0
SetValue creates a Set with a known value. Access the value via the Set type Elements or ElementsAs methods.
func SetValueFrom ¶ added in v0.15.0
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
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.
func (Set) ElementType ¶ added in v0.15.0
ElementType returns the element type for the Set.
func (Set) Elements ¶ added in v0.15.0
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
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) IsUnknown ¶ added in v0.9.0
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
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) ToSetValue ¶ added in v0.16.0
ToSetValue returns the Set.
func (Set) ToTerraformValue ¶ added in v0.4.0
ToTerraformValue returns the data contained in the Set as a tftypes.Value.
type SetTypable ¶ added in v0.16.0
type SetTypable interface { attr.Type // ValueFromSet should convert the Set to a SetValuable type. ValueFromSet(context.Context, Set) (SetValuable, diag.Diagnostics) }
SetTypable extends attr.Type for set types. Implement this interface to create a custom SetType type.
type SetType ¶ added in v0.4.0
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
ElementType returns the attr.Type elements will be created from.
func (SetType) Equal ¶ added in v0.4.0
Equal returns true if `o` is also a SetType and has the same ElemType.
func (SetType) TerraformType ¶ added in v0.4.0
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
Validate implements type validation. This type requires all elements to be unique.
func (SetType) ValueFromSet ¶ added in v0.16.0
func (st SetType) ValueFromSet(_ context.Context, set Set) (SetValuable, diag.Diagnostics)
ValueFromSet returns a SetValuable type given a Set.
func (SetType) ValueFromTerraform ¶ added in v0.4.0
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) 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 SetValuable ¶ added in v0.16.0
type SetValuable interface { attr.Value // ToSetValue should convert the value type to a Set. ToSetValue(ctx context.Context) (Set, diag.Diagnostics) }
SetValuable extends attr.Value for set value types. Implement this interface to create a custom Set value type.
type String ¶
type String struct {
// 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
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) IsUnknown ¶ added in v0.9.0
IsUnknown returns true if the String represents a currently unknown value.
func (String) String ¶ added in v0.9.0
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) ToStringValue ¶ added in v0.16.0
ToStringValue returns String.
func (String) ToTerraformValue ¶
ToTerraformValue returns the data contained in the *String as a tftypes.Value.
func (String) ValueString ¶ added in v0.15.0
ValueString returns the known string value. If String is null or unknown, returns "".
type StringTypable ¶ added in v0.16.0
type StringTypable interface { attr.Type // ValueFromString should convert the String to a StringValuable type. ValueFromString(context.Context, String) (StringValuable, diag.Diagnostics) }
StringTypable extends attr.Type for string types. Implement this interface to create a custom StringType type.
type StringValuable ¶ added in v0.16.0
type StringValuable interface { attr.Value // ToStringValue should convert the value type to a String. ToStringValue(ctx context.Context) (String, diag.Diagnostics) }
StringValuable extends attr.Value for string value types. Implement this interface to create a custom String value type.