Note
The tuple type doesn't have associated schema attributes as it has limited real world application. Provider developers will only encounter tuples when handling provider-defined function variadic parameters or dynamic values.
Tuple types store an ordered collection of elements where each element has it's own type. Values must have exactly the same number of elements (no more and no fewer), and the value in each position must match the specified type for that position.
The tuple type is used to express Terraform's tuple type constraint.
The tuple type is not supported in schema definitions of provider, data sources, ephemeral resources, or managed resources as it has limited real world application.
Access types.Tuple
information via the following methods:
(types.Tuple).IsNull() bool
: Returns true
if the tuple is null.(types.Tuple).IsUnknown() bool
: Returns true
if the tuple is unknown. Returns false
if the number of elements is known, any of which may be unknown.(types.Tuple).Elements() []attr.Value
: Returns the known []attr.Value
value, or nil
if null or unknown.Call one of the following to create a types.Tuple
value:
types.TupleNull([]attr.Type) types.Tuple
: A null tuple value with the given element types.types.TupleUnknown([]attr.Type) types.Tuple
: An unknown tuple value with the given element types.types.TupleValue([]attr.Type, []attr.Value) (types.Tuple, diag.Diagnostics)
: A known value with the given element types and values.types.TupleValueMust([]attr.Type, []attr.Value) types.Tuple
: A known value with the given element types and values. Any diagnostics are converted to a runtime panic. This is recommended only for testing or exhaustively tested logic.In this example, a known tuple value (["one", true, 123]
) is created from framework types:
elementTypes := []attr.Type{
types.StringType,
types.BoolType,
types.Int64Type,
}
elements := []attr.Value{
types.StringValue("one"),
types.BoolValue(true),
types.Int64Value(123),
}
tupleValue, diags := types.TupleValue(elementTypes, elements)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4