joneshf / terraform-provider-openwrt

A Terraform provider for OpenWrt using LuCI's JSON-RPC API
https://registry.terraform.io/providers/joneshf/openwrt
Mozilla Public License 2.0
33 stars 8 forks source link

Give more structure to provider data #97

Closed joneshf closed 1 year ago

joneshf commented 1 year ago

We were only passing in the LuCI JSON-RPC client because that's all we thought we needed. What we found out recently is that we have been using the Metadata method incorrectly, and we need to change how we're doing Data Source and Resource initialization.

As it turns out, the Metadata method seems to discard the Data Source or Resource it's called on. So us setting the fullTypeName in the Metadata method was doing nothing, and out logs were missing information.

To rectify this, we're going to set the fullTypeName in the Configure method. This should stay on the state of the Data Source and Resource for the lifecycle that we care about. It seems odd that we have to make both of these methods in the first place. But the fact that we have to be aware that one of them is effectively a function and not a method (Metadata) is pretty confusing. Hopefully the framework makes this a little easier to deal with in the future.