customtypes

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type YAMLNormalized

type YAMLNormalized struct {
	basetypes.StringValue
}

YAMLNormalized represents a valid YAML string (RFC 9512). Semantic equality logic is defined for YAMLNormalized such that inconsequential differences between YAML strings are ignored (whitespace, property order, etc). If you need strict, byte-for-byte, string equality, consider using ExactType. Inspired by yamltypes.NormalizedType https://github.com/hashicorp/terraform-plugin-framework-yamltypes

func NewNormalizedNull

func NewNormalizedNull() YAMLNormalized

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

func NewNormalizedPointerValue

func NewNormalizedPointerValue(value *string) YAMLNormalized

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

func NewNormalizedUnknown

func NewNormalizedUnknown() YAMLNormalized

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

func NewNormalizedValue

func NewNormalizedValue(value string) YAMLNormalized

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

func (YAMLNormalized) Equal

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

Equal returns true if the given value is equivalent.

func (YAMLNormalized) StringSemanticEquals

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

StringSemanticEquals returns true if the given YAML string value is semantically equal to the current YAML string value. When compared, these YAML 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 YAML strings (whitespace, property order, etc).

func (YAMLNormalized) Type

Type returns a YAMLNormalizedType.

func (YAMLNormalized) Unmarshal

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

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

func (YAMLNormalized) ValidateAttribute

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

func (YAMLNormalized) ValidateParameter

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

type YAMLNormalizedType

type YAMLNormalizedType struct {
	basetypes.StringType
}

YAMLNormalizedType is an attribute type that represents a valid JSON string (RFC 7159). Semantic equality logic is defined for YAMLNormalizedType 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 (YAMLNormalizedType) Equal

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

Equal returns true if the given type is equivalent.

func (YAMLNormalizedType) String

func (t YAMLNormalizedType) String() string

String returns a human readable string of the type name.

func (YAMLNormalizedType) ValueFromString

ValueFromString returns a StringValuable type given a StringValue.

func (YAMLNormalizedType) ValueFromTerraform

func (t YAMLNormalizedType) 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 (YAMLNormalizedType) ValueType

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