types

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2021 License: MPL-2.0 Imports: 7 Imported by: 608

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
)

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