types

package
Version: v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2021 License: MPL-2.0 Imports: 9 Imported by: 126

Documentation

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.
	Unknown bool

	// Null will be true if the value was not set, or was explicitly set to
	// null.
	Null bool

	// Value contains the set value, as long as Unknown and Null are both
	// false.
	Value bool
}

Bool represents a boolean value.

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) ToTerraformValue

func (b Bool) ToTerraformValue(_ context.Context) (interface{}, error)

ToTerraformValue returns the data contained in the *Bool as a bool. If Unknown is true, it returns a tftypes.UnknownValue. If Null is true, it returns nil.

func (Bool) Type added in v0.3.0

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

Type returns a BoolType.

type Float64 added in v0.4.0

type Float64 struct {
	// Unknown will be true if the value is not yet known.
	Unknown bool

	// Null will be true if the value was not set, or was explicitly set to
	// null.
	Null bool

	// Value contains the set value, as long as Unknown and Null are both
	// false.
	Value float64
}

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

func (Float64) Equal added in v0.4.0

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

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

func (Float64) ToTerraformValue added in v0.4.0

func (f Float64) ToTerraformValue(ctx context.Context) (interface{}, error)

ToTerraformValue returns the data contained in the Float64 as a float64. If Unknown is true, it returns a tftypes.UnknownValue. If Null is true, it returns nil.

func (Float64) Type added in v0.4.0

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

Type returns a NumberType.

type Int64 added in v0.4.0

type Int64 struct {
	// Unknown will be true if the value is not yet known.
	Unknown bool

	// Null will be true if the value was not set, or was explicitly set to
	// null.
	Null bool

	// Value contains the set value, as long as Unknown and Null are both
	// false.
	Value int64
}

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

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) ToTerraformValue added in v0.4.0

func (i Int64) ToTerraformValue(ctx context.Context) (interface{}, error)

ToTerraformValue returns the data contained in the Int64 as a int64. If Unknown is true, it returns a tftypes.UnknownValue. If Null is true, it returns nil.

func (Int64) Type added in v0.4.0

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

Type returns a NumberType.

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 AttributeValue
	// 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.
	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.
	Null bool

	// Elems are the elements in the list.
	Elems []attr.Value

	// ElemType is the tftypes.Type of the elements in the list. All
	// elements in the list must be of this type.
	ElemType attr.Type
}

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

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 must return true if the AttributeValue is considered semantically equal to the AttributeValue passed as an argument.

func (List) ToTerraformValue

func (l List) ToTerraformValue(ctx context.Context) (interface{}, error)

ToTerraformValue returns the data contained in the AttributeValue as a Go type that tftypes.NewValue will accept.

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) ValueFromTerraform

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

ValueFromTerraform returns an AttributeValue 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 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 AttributeValue
	// 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.
	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.
	Null bool

	// Elems are the elements in the map.
	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.
	ElemType attr.Type
}

Map represents a map of AttributeValues, all of the same type, indicated by ElemType. Keys for the map will always be strings.

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 must return true if the AttributeValue is considered semantically equal to the AttributeValue passed as an argument.

func (Map) ToTerraformValue

func (m Map) ToTerraformValue(ctx context.Context) (interface{}, error)

ToTerraformValue returns the data contained in the AttributeValue as a Go type that tftypes.NewValue will accept.

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) ValueFromTerraform

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

ValueFromTerraform returns an AttributeValue 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 Number

type Number struct {
	// Unknown will be true if the value is not yet known.
	Unknown bool

	// Null will be true if the value was not set, or was explicitly set to
	// null.
	Null bool

	// Value contains the set value, as long as Unknown and Null are both
	// false.
	Value *big.Float
}

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

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) ToTerraformValue

func (n Number) ToTerraformValue(_ context.Context) (interface{}, error)

ToTerraformValue returns the data contained in the *Number as a *big.Float. If Unknown is true, it returns a tftypes.UnknownValue. If Null is true, it returns nil.

func (Number) Type added in v0.3.0

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

Type returns a NumberType.

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 AttributeValue
	// 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.
	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.
	Null bool

	Attrs map[string]attr.Value

	AttrTypes map[string]attr.Type
}

Object represents an object

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) Equal

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

Equal must return true if the AttributeValue is considered semantically equal to the AttributeValue passed as an argument.

func (Object) ToTerraformValue

func (o Object) ToTerraformValue(ctx context.Context) (interface{}, error)

ToTerraformValue returns the data contained in the AttributeValue as a Go type that tftypes.NewValue will accept.

func (Object) Type added in v0.3.0

func (o Object) Type(_ 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 AttributeValue 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) 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 AttributeValue
	// 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.
	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.
	Null bool

	// Elems are the elements in the set.
	Elems []attr.Value

	// ElemType is the tftypes.Type of the elements in the set. All
	// elements in the set must be of this type.
	ElemType attr.Type
}

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

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 must return true if the AttributeValue is considered semantically equal to the AttributeValue passed as an argument.

func (Set) ToTerraformValue added in v0.4.0

func (s Set) ToTerraformValue(ctx context.Context) (interface{}, error)

ToTerraformValue returns the data contained in the AttributeValue as a Go type that tftypes.NewValue will accept.

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 (t SetType) ApplyTerraform5AttributePathStep(step tftypes.AttributePathStep) (interface{}, error)

ApplyTerraform5AttributePathStep applies the given AttributePathStep to the set.

func (SetType) ElementType added in v0.4.0

func (t SetType) ElementType() attr.Type

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

func (SetType) Equal added in v0.4.0

func (t 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 (t SetType) String() string

String returns a human-friendly description of the SetType.

func (SetType) TerraformType added in v0.4.0

func (t 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

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

func (SetType) ValueFromTerraform added in v0.4.0

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

ValueFromTerraform returns an AttributeValue 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 (t 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.
	Unknown bool

	// Null will be true if the value was not set, or was explicitly set to
	// null.
	Null bool

	// Value contains the set value, as long as Unknown and Null are both
	// false.
	Value string
}

String represents a UTF-8 string value.

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) ToTerraformValue

func (s String) ToTerraformValue(_ context.Context) (interface{}, error)

ToTerraformValue returns the data contained in the *String as a string. If Unknown is true, it returns a tftypes.UnknownValue. If Null is true, it returns nil.

func (String) Type added in v0.3.0

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

Type returns a StringType.

Jump to

Keyboard shortcuts

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