types

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2023 License: MPL-2.0 Imports: 16 Imported by: 0

README

Terraform Plugin Framework Provider-Defined Types

This package contains Terraform Plugin Framework provider-defined types (and values).

Documentation

Index

Constants

View Source
const (
	ARNType arnType = iota
)
View Source
const (
	CIDRBlockType cidrBlockType = iota
)
View Source
const (
	DurationType durationType = iota
)

Variables

View Source
var (
	RegexpType = regexpType{}
)

Functions

func AttributeTypes

func AttributeTypes[T any](ctx context.Context) (map[string]attr.Type, error)

AttributeTypes returns a map of attribute types for the specified type T. T must be a struct and reflection is used to find exported fields of T with the `tfsdk` tag.

func AttributeTypesMust

func AttributeTypesMust[T any](ctx context.Context) map[string]attr.Type

Types

type ARN

type ARN struct {
	// contains filtered or unexported fields
}

func ARNNull

func ARNNull() ARN

func ARNUnknown

func ARNUnknown() ARN

func ARNValue

func ARNValue(value arn.ARN) ARN

func (ARN) Equal

func (a ARN) Equal(other attr.Value) bool

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

func (ARN) IsNull

func (a ARN) IsNull() bool

IsNull returns true if the Value is not set, or is explicitly set to null.

func (ARN) IsUnknown

func (a ARN) IsUnknown() bool

IsUnknown returns true if the Value is not yet known.

func (ARN) String

func (a ARN) String() string

String returns a summary representation of either the underlying Value, or UnknownValueString (`<unknown>`) when IsUnknown() returns true, or NullValueString (`<null>`) when IsNull() return true.

This is an intentionally lossy representation, that are best suited for logging and error reporting, as they are not protected by compatibility guarantees within the framework.

func (ARN) ToStringValue

func (a ARN) ToStringValue(ctx context.Context) (types.String, diag.Diagnostics)

func (ARN) ToTerraformValue

func (a ARN) ToTerraformValue(ctx context.Context) (tftypes.Value, error)

func (ARN) Type

func (a ARN) Type(_ context.Context) attr.Type

func (ARN) ValueARN

func (a ARN) ValueARN() arn.ARN

ValueARN returns the known arn.ARN value. If ARN is null or unknown, returns {}.

type CIDRBlock

type CIDRBlock struct {
	// contains filtered or unexported fields
}

func CIDRBlockNull

func CIDRBlockNull() CIDRBlock

func CIDRBlockUnknown

func CIDRBlockUnknown() CIDRBlock

func CIDRBlockValue

func CIDRBlockValue(value string) CIDRBlock

func (CIDRBlock) Equal

func (c CIDRBlock) Equal(other attr.Value) bool

func (CIDRBlock) IsNull

func (c CIDRBlock) IsNull() bool

func (CIDRBlock) IsUnknown

func (c CIDRBlock) IsUnknown() bool

func (CIDRBlock) String

func (c CIDRBlock) String() string

func (CIDRBlock) ToStringValue

func (c CIDRBlock) ToStringValue(ctx context.Context) (types.String, diag.Diagnostics)

func (CIDRBlock) ToTerraformValue

func (c CIDRBlock) ToTerraformValue(ctx context.Context) (tftypes.Value, error)

func (CIDRBlock) Type

func (c CIDRBlock) Type(_ context.Context) attr.Type

func (CIDRBlock) ValueCIDRBlock

func (c CIDRBlock) ValueCIDRBlock() string

type Duration

type Duration struct {
	// contains filtered or unexported fields
}

func DurationNull

func DurationNull() Duration

func DurationUnknown

func DurationUnknown() Duration

func DurationValue

func DurationValue(value time.Duration) Duration

func (Duration) Equal

func (d Duration) Equal(other attr.Value) bool

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

func (Duration) IsNull

func (d Duration) IsNull() bool

IsNull returns true if the Value is not set, or is explicitly set to null.

func (Duration) IsUnknown

func (d Duration) IsUnknown() bool

IsUnknown returns true if the Value is not yet known.

func (Duration) String

func (d Duration) String() string

String returns a summary representation of either the underlying Value, or UnknownValueString (`<unknown>`) when IsUnknown() returns true, or NullValueString (`<null>`) when IsNull() return true.

This is an intentionally lossy representation, that are best suited for logging and error reporting, as they are not protected by compatibility guarantees within the framework.

func (Duration) ToStringValue

func (d Duration) ToStringValue(ctx context.Context) (types.String, diag.Diagnostics)

func (Duration) ToTerraformValue

func (d Duration) ToTerraformValue(ctx context.Context) (tftypes.Value, 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 (Duration) Type

func (d Duration) Type(_ context.Context) attr.Type

Type returns a DurationType.

func (Duration) ValueDuration

func (d Duration) ValueDuration() time.Duration

ValueDuration returns the known time.Duration value. If Duration is null or unknown, returns 0.

type ListNestedObjectTypeOf

type ListNestedObjectTypeOf[T any] struct {
	basetypes.ListType
}

ListNestedObjectTypeOf is the attribute type of a ListNestedObjectValueOf.

func NewListNestedObjectTypeOf

func NewListNestedObjectTypeOf[T any](ctx context.Context) ListNestedObjectTypeOf[T]

func (ListNestedObjectTypeOf[T]) Equal

func (t ListNestedObjectTypeOf[T]) Equal(o attr.Type) bool

func (ListNestedObjectTypeOf[T]) NewObjectPtr

func (t ListNestedObjectTypeOf[T]) NewObjectPtr(ctx context.Context) (any, diag.Diagnostics)

func (ListNestedObjectTypeOf[T]) NewObjectSlice

func (t ListNestedObjectTypeOf[T]) NewObjectSlice(ctx context.Context, len, cap int) (any, diag.Diagnostics)

func (ListNestedObjectTypeOf[T]) NullValue

func (ListNestedObjectTypeOf[T]) String

func (t ListNestedObjectTypeOf[T]) String() string

func (ListNestedObjectTypeOf[T]) ValueFromList

func (ListNestedObjectTypeOf[T]) ValueFromObjectPtr

func (t ListNestedObjectTypeOf[T]) ValueFromObjectPtr(ctx context.Context, ptr any) (attr.Value, diag.Diagnostics)

func (ListNestedObjectTypeOf[T]) ValueFromObjectSlice

func (t ListNestedObjectTypeOf[T]) ValueFromObjectSlice(ctx context.Context, slice any) (attr.Value, diag.Diagnostics)

func (ListNestedObjectTypeOf[T]) ValueFromTerraform

func (t ListNestedObjectTypeOf[T]) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error)

func (ListNestedObjectTypeOf[T]) ValueType

func (t ListNestedObjectTypeOf[T]) ValueType(ctx context.Context) attr.Value

type ListNestedObjectValueOf

type ListNestedObjectValueOf[T any] struct {
	basetypes.ListValue
}

ListNestedObjectValueOf represents a Terraform Plugin Framework List value whose elements are of type ObjectTypeOf.

func NewListNestedObjectValueOfNull

func NewListNestedObjectValueOfNull[T any](ctx context.Context) ListNestedObjectValueOf[T]

func NewListNestedObjectValueOfPtr

func NewListNestedObjectValueOfPtr[T any](ctx context.Context, t *T) ListNestedObjectValueOf[T]

func NewListNestedObjectValueOfSlice

func NewListNestedObjectValueOfSlice[T any](ctx context.Context, ts []*T) ListNestedObjectValueOf[T]

func NewListNestedObjectValueOfUnknown

func NewListNestedObjectValueOfUnknown[T any](ctx context.Context) ListNestedObjectValueOf[T]

func NewListNestedObjectValueOfValueSlice

func NewListNestedObjectValueOfValueSlice[T any](ctx context.Context, ts []T) ListNestedObjectValueOf[T]

func (ListNestedObjectValueOf[T]) Equal

func (v ListNestedObjectValueOf[T]) Equal(o attr.Value) bool

func (ListNestedObjectValueOf[T]) ToObjectPtr

func (v ListNestedObjectValueOf[T]) ToObjectPtr(ctx context.Context) (any, diag.Diagnostics)

func (ListNestedObjectValueOf[T]) ToObjectSlice

func (v ListNestedObjectValueOf[T]) ToObjectSlice(ctx context.Context) (any, diag.Diagnostics)

func (ListNestedObjectValueOf[T]) Type

type NestedObjectType

type NestedObjectType interface {
	attr.Type

	// NewObjectPtr returns a new, empty value as an object pointer (Go *struct).
	NewObjectPtr(context.Context) (any, diag.Diagnostics)

	// NewObjectSlice returns a new value as an object slice (Go []*struct).
	NewObjectSlice(context.Context, int, int) (any, diag.Diagnostics)

	// NullValue returns a Null Value.
	NullValue(context.Context) (attr.Value, diag.Diagnostics)

	// ValueFromObjectPtr returns a Value given an object pointer (Go *struct).
	ValueFromObjectPtr(context.Context, any) (attr.Value, diag.Diagnostics)

	// ValueFromObjectSlice returns a Value given an object pointer (Go []*struct).
	ValueFromObjectSlice(context.Context, any) (attr.Value, diag.Diagnostics)
}

NestedObjectType extends the Type interface for types that represent nested Objects.

type NestedObjectValue

type NestedObjectValue interface {
	attr.Value

	// ToObjectPtr returns the value as an object pointer (Go *struct).
	ToObjectPtr(context.Context) (any, diag.Diagnostics)

	// ToObjectSlice returns the value as an object slice (Go []*struct).
	ToObjectSlice(context.Context) (any, diag.Diagnostics)
}

NestedObjectValue extends the Value interface for values that represent nested Objects.

type ObjectTypeOf

type ObjectTypeOf[T any] struct {
	basetypes.ObjectType
}

ObjectTypeOf is the attribute type of an ObjectValueOf.

func NewObjectTypeOf

func NewObjectTypeOf[T any](ctx context.Context) ObjectTypeOf[T]

func (ObjectTypeOf[T]) Equal

func (t ObjectTypeOf[T]) Equal(o attr.Type) bool

func (ObjectTypeOf[T]) String

func (t ObjectTypeOf[T]) String() string

func (ObjectTypeOf[T]) ValueFromObject

func (ObjectTypeOf[T]) ValueFromTerraform

func (t ObjectTypeOf[T]) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error)

func (ObjectTypeOf[T]) ValueType

func (t ObjectTypeOf[T]) ValueType(ctx context.Context) attr.Value

type ObjectValueOf

type ObjectValueOf[T any] struct {
	basetypes.ObjectValue
}

ObjectValueOf represents a Terraform Plugin Framework Object value whose corresponding Go type is the structure T.

func NewObjectValueOf

func NewObjectValueOf[T any](ctx context.Context, t *T) ObjectValueOf[T]

func NewObjectValueOfNull

func NewObjectValueOfNull[T any](ctx context.Context) ObjectValueOf[T]

func NewObjectValueOfUnknown

func NewObjectValueOfUnknown[T any](ctx context.Context) ObjectValueOf[T]

func (ObjectValueOf[T]) Equal

func (v ObjectValueOf[T]) Equal(o attr.Value) bool

func (ObjectValueOf[T]) Type

func (v ObjectValueOf[T]) Type(ctx context.Context) attr.Type

type Regexp

type Regexp struct {
	// contains filtered or unexported fields
}

func RegexpNull

func RegexpNull() Regexp

func RegexpUnknown

func RegexpUnknown() Regexp

func RegexpValue

func RegexpValue(value *regexp.Regexp) Regexp

func (Regexp) Equal

func (a Regexp) Equal(other attr.Value) bool

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

func (Regexp) IsNull

func (a Regexp) IsNull() bool

IsNull returns true if the Value is not set, or is explicitly set to null.

func (Regexp) IsUnknown

func (a Regexp) IsUnknown() bool

IsUnknown returns true if the Value is not yet known.

func (Regexp) String

func (a Regexp) String() string

String returns a summary representation of either the underlying Value, or UnknownValueString (`<unknown>`) when IsUnknown() returns true, or NullValueString (`<null>`) when IsNull() return true.

This is an intentionally lossy representation, that are best suited for logging and error reporting, as they are not protected by compatibility guarantees within the framework.

func (Regexp) ToStringValue

func (a Regexp) ToStringValue(ctx context.Context) (types.String, diag.Diagnostics)

func (Regexp) ToTerraformValue

func (a Regexp) ToTerraformValue(ctx context.Context) (tftypes.Value, error)

func (Regexp) Type

func (a Regexp) Type(_ context.Context) attr.Type

func (Regexp) ValueRegexp

func (a Regexp) ValueRegexp() *regexp.Regexp

ValueRegexp returns the known *regexp.Regexp value. If Regexp is null or unknown, returns nil.

type SetNestedObjectTypeOf

type SetNestedObjectTypeOf[T any] struct {
	basetypes.SetType
}

SetNestedObjectTypeOf is the attribute type of a SetNestedObjectValueOf.

func NewSetNestedObjectTypeOf

func NewSetNestedObjectTypeOf[T any](ctx context.Context) SetNestedObjectTypeOf[T]

func (SetNestedObjectTypeOf[T]) Equal

func (t SetNestedObjectTypeOf[T]) Equal(o attr.Type) bool

func (SetNestedObjectTypeOf[T]) NewObjectPtr

func (t SetNestedObjectTypeOf[T]) NewObjectPtr(ctx context.Context) (any, diag.Diagnostics)

func (SetNestedObjectTypeOf[T]) NewObjectSlice

func (t SetNestedObjectTypeOf[T]) NewObjectSlice(ctx context.Context, len, cap int) (any, diag.Diagnostics)

func (SetNestedObjectTypeOf[T]) NullValue

func (SetNestedObjectTypeOf[T]) String

func (t SetNestedObjectTypeOf[T]) String() string

func (SetNestedObjectTypeOf[T]) ValueFromObjectPtr

func (t SetNestedObjectTypeOf[T]) ValueFromObjectPtr(ctx context.Context, ptr any) (attr.Value, diag.Diagnostics)

func (SetNestedObjectTypeOf[T]) ValueFromObjectSlice

func (t SetNestedObjectTypeOf[T]) ValueFromObjectSlice(ctx context.Context, slice any) (attr.Value, diag.Diagnostics)

func (SetNestedObjectTypeOf[T]) ValueFromSet

func (SetNestedObjectTypeOf[T]) ValueFromTerraform

func (t SetNestedObjectTypeOf[T]) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error)

func (SetNestedObjectTypeOf[T]) ValueType

func (t SetNestedObjectTypeOf[T]) ValueType(ctx context.Context) attr.Value

type SetNestedObjectValueOf

type SetNestedObjectValueOf[T any] struct {
	basetypes.SetValue
}

SetNestedObjectValueOf represents a Terraform Plugin Framework Set value whose elements are of type ObjectTypeOf.

func NewSetNestedObjectValueOfNull

func NewSetNestedObjectValueOfNull[T any](ctx context.Context) SetNestedObjectValueOf[T]

func NewSetNestedObjectValueOfPtr

func NewSetNestedObjectValueOfPtr[T any](ctx context.Context, t *T) SetNestedObjectValueOf[T]

func NewSetNestedObjectValueOfSlice

func NewSetNestedObjectValueOfSlice[T any](ctx context.Context, ts []*T) SetNestedObjectValueOf[T]

func NewSetNestedObjectValueOfUnknown

func NewSetNestedObjectValueOfUnknown[T any](ctx context.Context) SetNestedObjectValueOf[T]

func NewSetNestedObjectValueOfValueSlice

func NewSetNestedObjectValueOfValueSlice[T any](ctx context.Context, ts []T) SetNestedObjectValueOf[T]

func (SetNestedObjectValueOf[T]) Equal

func (v SetNestedObjectValueOf[T]) Equal(o attr.Value) bool

func (SetNestedObjectValueOf[T]) ToObjectPtr

func (v SetNestedObjectValueOf[T]) ToObjectPtr(ctx context.Context) (any, diag.Diagnostics)

func (SetNestedObjectValueOf[T]) ToObjectSlice

func (v SetNestedObjectValueOf[T]) ToObjectSlice(ctx context.Context) (any, diag.Diagnostics)

func (SetNestedObjectValueOf[T]) Type

type TimestampType

type TimestampType struct {
	basetypes.StringType
}

func (TimestampType) Equal

func (typ TimestampType) Equal(o attr.Type) bool

func (TimestampType) String

func (typ TimestampType) String() string

String returns a human-friendly description of the TimestampType.

func (TimestampType) Validate

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

func (TimestampType) ValueFromString

func (TimestampType) ValueFromTerraform

func (typ TimestampType) ValueFromTerraform(_ context.Context, in tftypes.Value) (attr.Value, error)

func (TimestampType) ValueType

func (typ TimestampType) ValueType(context.Context) attr.Value

type TimestampValue

type TimestampValue struct {
	basetypes.StringValue
	// contains filtered or unexported fields
}

func NewTimestampNull

func NewTimestampNull() TimestampValue

func NewTimestampUnknown

func NewTimestampUnknown() TimestampValue

func NewTimestampValue

func NewTimestampValue(t time.Time) TimestampValue

func NewTimestampValueString

func NewTimestampValueString(s string) (TimestampValue, error)

func (TimestampValue) Equal

func (val TimestampValue) Equal(other attr.Value) bool

func (TimestampValue) Type

func (val TimestampValue) Type(_ context.Context) attr.Type

func (TimestampValue) ValueTimestamp

func (val TimestampValue) ValueTimestamp() time.Time

ValueTimestamp returns the known time.Time value. If Timestamp is null or unknown, returns 0. To get the value as a string, use ValueString.

Jump to

Keyboard shortcuts

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