-
Notifications
You must be signed in to change notification settings - Fork 95
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
Migrate tfsdk package Config, Plan, and State into schema package #78
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is fundamentally the right idea, because our Config, State, and Plan types are "schema-rich" - they are the abstraction the framework creates to marry the concepts of "value that comes over the wire from Terraform" and "user-defined schema" to provide a way of accessing those values as values of the schema type.
The validation work adds an irreducible dependency in the other direction, since the schema validation takes the config (and therefore schema) as one of its inputs.
The only way I see to resolve this inherent circularity would be to abstract the schema dependency from the Config type, so instead of
type Config struct {
Raw tftypes.Value
Schema schema.Schema
}
you would have
type Config struct {
Raw tftypes.Value
Schema elsewhere.Typer
}
where Typer
is an interface Schema
fulfills. Then you'd have to use dependency injection to fill that with the actual Schema
type when creating the Schema-specific version of the validation functionality inside the schema
package. I don't think this is really feasible given the shape of the APIs we want to offer.
Here's the package dependency graph of main
right now:
Graph of branch f-schema-validation
:
And finally, what happens if you move the proto6
functionality that depends on schema
into schema
(isolating the circular dependency, so we can ignore proto6
):
I therefore think this PR is the right idea, but we should rename the schema
package if we do this, so we don't end up with types schema.Plan
, schema.Config
, etc, which are semantically off.
The package name should be something that captures the concerns we've grouped together here, i.e. the resource values Terraform sends to us in the protocol, in a "schema-rich" form. I'm struggling to think of anything less abstract than values
, vals
, tfvals
...
I agree with @kmoe that an interface is likely not the route we want here. I'm wondering if bringing the Benefits:
I have a quick sketch of this PR with everything moved to |
#77 has the version of this with |
Reference: #76 These types are tightly coupled to Schema and Attribute handling and migrating them will allow for future enhancements with Attribute plan modifications and validations to reference these types without an import cycle.
7cd864d
to
5a17857
Compare
Happy to close in favour of #77 |
We have opted for #77 -- closing this PR. |
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions. |
Reference: #76
These types are tightly coupled to Schema and Attribute handling and migrating them will allow for future enhancements with Attribute plan modifications and validations to reference these types without an import cycle.