-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider Splitting tftypes.Type into Value and Constraint/Schema Types #128
Labels
breaking-change
This will impact or improve our compatibility posture
enhancement
New feature or request
Comments
bflad
added
enhancement
New feature or request
breaking-change
This will impact or improve our compatibility posture
labels
Dec 22, 2021
bflad
added a commit
that referenced
this issue
Jan 7, 2022
Reference: #94 Reference: #99 Reference: #100 Reference: #128 Reference: #133 Reverts incorrect logic for handling DynamicPseudoType values in `tftypes`. This type information must be preserved when traversing the protocol, as Terraform CLI decodes values based on the schema information. If a concrete value type is used where DynamicPseudoType is expected, Terraform CLI will return errors such as (given an object of 4 attributes, when DynamicPseudoType is expected): ``` │ Error: ["manifest"]: msgpack: invalid code=84 decoding array length ```
Drive-by note: Core refers to these as |
bflad
added a commit
that referenced
this issue
Jan 13, 2022
Reference: #94 Reference: #99 Reference: #100 Reference: #128 Reference: #133 Reverts incorrect logic for handling DynamicPseudoType values in `tftypes`. This type information must be preserved when traversing the protocol, as Terraform CLI decodes values based on the schema information. If a concrete value type is used where DynamicPseudoType is expected, Terraform CLI will return errors such as (given an object of 4 attributes, when DynamicPseudoType is expected): ``` │ Error: ["manifest"]: msgpack: invalid code=84 decoding array length ```
bflad
added a commit
that referenced
this issue
Jan 31, 2022
bflad
added a commit
that referenced
this issue
Feb 4, 2022
bflad
added a commit
that referenced
this issue
Feb 16, 2022
Reference: #128 Reference: #157 This methods implement standard conversion logic from `Schema*` types into their associated `tftypes.Type` equivalent. For example, these can be used to prepare calls to the `(DynamicValue).Unmarshal()` method, which is necessary in many RPCs. Preferably, these methods would have been named `Type()`, however the `SchemaAttribute` type implements a `Type` field and Go does not permit overlapping field and method names. Instead, the name `ValueType()` was chosen as an alternate designation as the `tftypes.Type` really represents a data value type, instead of a type constraint (sometimes also referred to as a schema type).
bflad
added a commit
that referenced
this issue
Feb 17, 2022
…158) Reference: #128 Reference: #157 This methods implement standard conversion logic from `Schema*` types into their associated `tftypes.Type` equivalent. For example, these can be used to prepare calls to the `(DynamicValue).Unmarshal()` method, which is necessary in many RPCs. Preferably, these methods would have been named `Type()`, however the `SchemaAttribute` type implements a `Type` field and Go does not permit overlapping field and method names. Instead, the name `ValueType()` was chosen as an alternate designation as the `tftypes.Type` really represents a data value type, instead of a type constraint (sometimes also referred to as a schema type).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
breaking-change
This will impact or improve our compatibility posture
enhancement
New feature or request
terraform-plugin-go version
Use cases
Terraform has two conceptually different meanings of a "type" within its type system today:
One place where this distinction is important are object types, which may define
OptionalAttributes
. An object value must specify all attributes (e.g. withnil
s), regardless of that additional information. Another odd case isDynamicPseudoType
, which technically can be used in both contexts.The
tftypes
package is currently written with a flattenedType
definition that serves both purposes. Functions likeNewValue()
accepttftypes.Object
withOptionalAttributes
, however this should not be valid in all scenarios and can cause provider development issues as it can be difficult to reason between the intended usage of functions. Since there is a single Go type to work with, it is slightly more difficult to enforce correctness. If Terraform expands usage of type constraints in the future, this issue will be exasperated.Proposal
Split
tftypes.Type
into multiple Go types, one with the sole purpose of value handling and the other for constraint/metadata/schema handling. e.g. (naming up for discussion, it just didn't feel appropriate to still call oneType
)The most impactful changes for implementors will then be the updated function signatures to align with these new types:
The value types that are implemented within
tftypes
should then support bothValueType
andTypeConstraint
.References
The text was updated successfully, but these errors were encountered: