customtypes

package
v0.12.2 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Duration

type Duration struct {
	basetypes.StringValue
}

func NewDurationNull

func NewDurationNull() Duration

NewDurationNull creates a Duration with a null value. Determine whether the value is null via IsNull method.

func NewDurationPointerValue

func NewDurationPointerValue(value *string) Duration

NewDurationPointerValue creates a Duration with a null value if nil or a known value. Access the value via ValueStringPointer method.

func NewDurationUnknown

func NewDurationUnknown() Duration

NewDurationUnknown creates a Duration with an unknown value. Determine whether the value is unknown via IsUnknown method.

func NewDurationValue

func NewDurationValue(value string) Duration

NewDurationValue creates a Duration with a known value. Access the value via ValueString method.

func (Duration) Equal

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

Equal returns true if the given value is equivalent.

func (Duration) Parse

func (v Duration) Parse() (time.Duration, diag.Diagnostics)

Parse calls time.ParseDuration with the Duration StringValue. A null or unknown value will produce an error diagnostic.

func (Duration) StringSemanticEquals

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

StringSemanticEquals returns true if the given duration string value is semantically equal to the current duration string value. When compared, the durations are parsed into a time.Duration and the underlying nanosecond values compared.

func (Duration) Type

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

Type returns a DurationType.

func (Duration) ValidateAttribute

type DurationType

type DurationType struct {
	basetypes.StringType
}

func (DurationType) Equal

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

Equal returns true if the given type is equivalent.

func (DurationType) String

func (t DurationType) String() string

String returns a human readable string of the type name.

func (DurationType) ValueFromString

ValueFromString returns a StringValuable type given a StringValue.

func (DurationType) ValueFromTerraform

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

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

ValueType returns the Value type.

type JSONWithDefaultsType added in v0.12.2

type JSONWithDefaultsType[TModel any] struct {
	jsontypes.NormalizedType
	// contains filtered or unexported fields
}

JSONWithDefaultsType is a generic type for JSON attributes that need default values populated

func NewJSONWithDefaultsType added in v0.12.2

func NewJSONWithDefaultsType[TModel any](populateDefaults PopulateDefaultsFunc[TModel]) JSONWithDefaultsType[TModel]

NewJSONWithDefaultsType creates a new JSONWithDefaultsType with the given PopulateDefaultsFunc

func (JSONWithDefaultsType[TModel]) Equal added in v0.12.2

func (t JSONWithDefaultsType[TModel]) Equal(o attr.Type) bool

Equal returns true if the given type is equivalent.

func (JSONWithDefaultsType[TModel]) String added in v0.12.2

func (t JSONWithDefaultsType[TModel]) String() string

String returns a human readable string of the type name.

func (JSONWithDefaultsType[TModel]) ValueFromString added in v0.12.2

ValueFromString returns a StringValuable type given a StringValue.

func (JSONWithDefaultsType[TModel]) ValueFromTerraform added in v0.12.2

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

ValueFromTerraform returns a Value given a tftypes.Value.

func (JSONWithDefaultsType[TModel]) ValueType added in v0.12.2

func (t JSONWithDefaultsType[TModel]) ValueType(ctx context.Context) attr.Value

ValueType returns the Value type.

type JSONWithDefaultsValue added in v0.12.2

type JSONWithDefaultsValue[TModel any] struct {
	jsontypes.Normalized
	// contains filtered or unexported fields
}

JSONWithDefaultsValue is a generic value type for JSON attributes that need default values populated

func NewJSONWithDefaultsNull added in v0.12.2

func NewJSONWithDefaultsNull[TModel any](populateDefaults PopulateDefaultsFunc[TModel]) JSONWithDefaultsValue[TModel]

NewJSONWithDefaultsNull creates a JSONWithDefaultsValue with a null value.

func NewJSONWithDefaultsUnknown added in v0.12.2

func NewJSONWithDefaultsUnknown[TModel any](populateDefaults PopulateDefaultsFunc[TModel]) JSONWithDefaultsValue[TModel]

NewJSONWithDefaultsUnknown creates a JSONWithDefaultsValue with an unknown value.

func NewJSONWithDefaultsValue added in v0.12.2

func NewJSONWithDefaultsValue[TModel any](value string, populateDefaults PopulateDefaultsFunc[TModel]) JSONWithDefaultsValue[TModel]

NewJSONWithDefaultsValue creates a JSONWithDefaultsValue with a known value.

func (JSONWithDefaultsValue[TModel]) StringSemanticEquals added in v0.12.2

func (v JSONWithDefaultsValue[TModel]) StringSemanticEquals(ctx context.Context, newValuable basetypes.StringValuable) (bool, diag.Diagnostics)

StringSemanticEquals returns true if the given value is semantically equal to the current value. The comparison will ignore any default values present in one value, but unset in the other.

func (JSONWithDefaultsValue[TModel]) Type added in v0.12.2

func (v JSONWithDefaultsValue[TModel]) Type(_ context.Context) attr.Type

Type returns a JSONWithDefaultsType.

func (JSONWithDefaultsValue[TModel]) WithDefaults added in v0.12.2

func (v JSONWithDefaultsValue[TModel]) WithDefaults() (JSONWithDefaultsValue[TModel], diag.Diagnostics)

WithDefaults applies default values to the JSON content

type MemorySize added in v0.12.2

type MemorySize struct {
	basetypes.StringValue
}

func NewMemorySizeNull added in v0.12.2

func NewMemorySizeNull() MemorySize

NewMemorySizeNull creates a MemorySize with a null value. Determine whether the value is null via IsNull method.

func NewMemorySizePointerValue added in v0.12.2

func NewMemorySizePointerValue(value *string) MemorySize

NewMemorySizePointerValue creates a MemorySize with a null value if nil or a known value. Access the value via ValueStringPointer method.

func NewMemorySizeUnknown added in v0.12.2

func NewMemorySizeUnknown() MemorySize

NewMemorySizeUnknown creates a MemorySize with an unknown value. Determine whether the value is unknown via IsUnknown method.

func NewMemorySizeValue added in v0.12.2

func NewMemorySizeValue(value string) MemorySize

NewMemorySizeValue creates a MemorySize with a known value. Access the value via ValueString method.

func (MemorySize) ConvertToMB added in v0.12.2

func (v MemorySize) ConvertToMB() (int64, diag.Diagnostics)

ConvertToMB parses the memory size string and returns the equivalent number of megabytes. Supports units: k/K (kilobytes), m/M (megabytes), g/G (gigabytes), t/T (terabytes) The 'b' suffix is optional and ignored. Note: As per ML documentation, values are rounded down to the nearest MB for consistency.

func (MemorySize) Equal added in v0.12.2

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

Equal returns true if the given value is equivalent.

func (MemorySize) StringSemanticEquals added in v0.12.2

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

StringSemanticEquals returns true if the given memory size string value is semantically equal to the current memory size string value. When compared, the memory sizes are parsed into bytes and the byte values compared.

func (MemorySize) Type added in v0.12.2

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

Type returns a MemorySizeType.

func (MemorySize) ValidateAttribute added in v0.12.2

type MemorySizeType added in v0.12.2

type MemorySizeType struct {
	basetypes.StringType
}

func (MemorySizeType) Equal added in v0.12.2

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

Equal returns true if the given type is equivalent.

func (MemorySizeType) String added in v0.12.2

func (t MemorySizeType) String() string

String returns a human readable string of the type name.

func (MemorySizeType) ValueFromString added in v0.12.2

ValueFromString returns a StringValuable type given a StringValue.

func (MemorySizeType) ValueFromTerraform added in v0.12.2

func (t MemorySizeType) 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 (MemorySizeType) ValueType added in v0.12.2

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

ValueType returns the Value type.

type PopulateDefaultsFunc added in v0.12.2

type PopulateDefaultsFunc[TModel any] func(model TModel) TModel

PopulateDefaultsFunc is a function that takes a parsed model and returns it with defaults populated

Jump to

Keyboard shortcuts

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