-
Notifications
You must be signed in to change notification settings - Fork 132
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 provider to terraform-plugin-framework
#633
Comments
I've started to play around migrating the provider to v6 / terraform-plugin-framework & the new test framework (terraform-plugin-testing): https://github.com/greatman/terraform-provider-netbox/tree/plugin-framework So far, seems possible rather easily through the mux server feature like suggested. I have a v6 protocol provider using plugin-framework and a v5 protocol with the old SDKv2. It does require rewriting about everything but at least the mux server allows to migrate 1 piece at a time. The tests runs through the mux server so they still have access to everything. All tests except the old netbox_site v5 tests works. The new main implementation: Some other modifications around. First project i'm working on Go ever, so all new stuff for me 😛 |
If I had more time, I would take an in-depth look at re-generating this provider mostly from scratch with https://www.hashicorp.com/blog/terraform-provider-code-generation-now-in-tech-preview (which would be using the framework then) I think with these tools plus some glue code, most of the code base could be auto-generated. |
yeah, auto-generation would be amazing, but i feel like there are a couple nasty edge cases. would it make sense to maybe do a virtual hackday to give this a spin or something like that? |
I explored yesterday the code gen module of Terraform, that's what I discovered:
Some example of what scaffolding it generates:
To generate the _gen files, the following was used: To generate a base scaffolding, the following: So from a quick look, good to increase velocity on heavy boilerplate like generating Schemas & validation, but still need to write all the logic. With both the mux server & that, the conversion could be faster. |
Yes, but like 80% of the logic of a terraform provider is mapping the API attributes to their respective hcl attributes via a go library (in this case go-netbox). These fields are usually just strings or number, lists of these, or pointers on these. There obviously remain some edge cases where custom behavior is needed like custom fields, tags, the available_* resources and the provider configuration itself (and probably more), so that has to be considered. |
The
terraform-plugin-sdk
used in this provider has some limitations when it comes to newer provider features.I think it could be beneficial to the project to eventually switch to the newer terraform-plugin-framework.
An example of something that's not possible with
terraform-plugin-sdk
is nested schemas (issue), which would help a lot with non-string values for custom fields (#349) and general ergonomics of custom fields.There seems to be a way to use
tf5muxserver
to gradually migrate a provider to the plugin framework.The text was updated successfully, but these errors were encountered: