custom_types

package
v0.0.0-...-6209148 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2024 License: 0BSD Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Normalized

type Normalized struct {
	basetypes.StringValue
}

Normalized represents a valid JSON string (RFC 7159). Semantic equality logic is defined for Normalized such that inconsequential differences between JSON strings are ignored (whitespace, property order, etc). If you need strict, byte-for-byte, string equality, consider using ExactType.

func NewNormalizedNull

func NewNormalizedNull() Normalized

NewNormalizedNull creates a Normalized with a null value. Determine whether the value is null via IsNull method.

func NewNormalizedPointerValue

func NewNormalizedPointerValue(value *string) Normalized

NewNormalizedPointerValue creates a Normalized with a null value if nil or a known value. Access the value via ValueStringPointer method.

func NewNormalizedUnknown

func NewNormalizedUnknown() Normalized

NewNormalizedUnknown creates a Normalized with an unknown value. Determine whether the value is unknown via IsUnknown method.

func NewNormalizedValue

func NewNormalizedValue(value string) Normalized

NewNormalizedValue creates a Normalized with a known value. Access the value via ValueString method.

func (Normalized) Equal

func (v Normalized) Equal(o attr.Value) bool

Equal returns true if the given value is equivalent.

func (Normalized) MarshalJSON

func (v Normalized) MarshalJSON() ([]byte, error)

func (Normalized) StringSemanticEquals

func (v Normalized) StringSemanticEquals(_ context.Context, newValuable basetypes.StringValuable) (bool, diag.Diagnostics)

StringSemanticEquals returns true if the given JSON string value is semantically equal to the current JSON string value. When compared, these JSON string values are "normalized" by marshalling them to empty Go structs. This prevents Terraform data consistency errors and resource drift due to inconsequential differences in the JSON strings (whitespace, property order, etc).

func (Normalized) Type

func (v Normalized) Type(_ context.Context) attr.Type

Type returns a NormalizedType.

func (Normalized) Unmarshal

func (v Normalized) Unmarshal(target any) diag.Diagnostics

Unmarshal calls (encoding/json).Unmarshal with the Normalized StringValue and `target` input. A null or unknown value will produce an error diagnostic. See encoding/json docs for more on usage: https://pkg.go.dev/encoding/json#Unmarshal

func (Normalized) ValidateAttribute

ValidateAttribute implements attribute value validation. This type requires the value provided to be a String value that is valid JSON format (RFC 7159).

func (Normalized) ValidateParameter

ValidateParameter implements provider-defined function parameter value validation. This type requires the value provided to be a String value that is valid JSON format (RFC 7159).

type NormalizedType

type NormalizedType struct {
	basetypes.StringType
}

NormalizedType is an attribute type that represents a valid JSON string (RFC 7159). Semantic equality logic is defined for NormalizedType such that inconsequential differences between JSON strings are ignored (whitespace, property order, etc). If you need strict, byte-for-byte, string equality, consider using ExactType.

func (NormalizedType) Equal

func (t NormalizedType) Equal(o attr.Type) bool

Equal returns true if the given type is equivalent.

func (NormalizedType) String

func (t NormalizedType) String() string

String returns a human readable string of the type name.

func (NormalizedType) ValueFromString

ValueFromString returns a StringValuable type given a StringValue.

func (NormalizedType) ValueFromTerraform

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

ValueFromTerraform returns a 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 (NormalizedType) ValueType

func (t NormalizedType) ValueType(ctx context.Context) attr.Value

ValueType returns the Value type.

Jump to

Keyboard shortcuts

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