d7048cb640
A couple of bugs have been discovered in ResourceDiff.ForceNew: * NewRemoved is not preserved when a diff for a key is already present. This is because the second diff that happens after customization performs a second getChange on not just state and config, but also on the pre-existing diff. This results in Exists == true, meaning nil is never returned as a new value. * ForceNew was doing the work of adding the key to the list of changed keys by doing a full SetNew on the existing value. This has a side effect of fetching zero values from what were otherwise undefined values and creating diffs for these values where there should not have been (example: "" => "0"). This update fixes these scenarios by: * Adding a new private function to check the existing diff for NewRemoved keys. This is included in the check on new values in diffChange. * Keys that have been flagged as ForceNew (or parent keys of lists and sets that have been flagged as ForceNew) are now maintained in a separate map. UpdatedKeys now returns the results of both of these maps, but otherwise these keys are ignored by ResourceDiff. * Pursuant the above, values are no longer pushed into the newDiff writer by ForceNew. This prevents the zero value problem, and makes for a cleaner implementation where the provider has to "manually" SetNew to update the appropriate values in the writer. It also prevents non-computed keys from winding up in the diff, which ResourceDiff normally blocks by design. There are also a couple of tests for cases that should never come up right now involving Optional/Computed values and NewRemoved, for which explanations are given in annotations of each test. These are here to guard against future regressions. |
||
---|---|---|
.. | ||
README.md | ||
backend.go | ||
backend_test.go | ||
core_schema.go | ||
core_schema_test.go | ||
data_source_resource_shim.go | ||
equal.go | ||
field_reader.go | ||
field_reader_config.go | ||
field_reader_config_test.go | ||
field_reader_diff.go | ||
field_reader_diff_test.go | ||
field_reader_map.go | ||
field_reader_map_test.go | ||
field_reader_multi.go | ||
field_reader_multi_test.go | ||
field_reader_test.go | ||
field_writer.go | ||
field_writer_map.go | ||
field_writer_map_test.go | ||
getsource_string.go | ||
provider.go | ||
provider_test.go | ||
provisioner.go | ||
provisioner_test.go | ||
resource.go | ||
resource_data.go | ||
resource_data_get_source.go | ||
resource_data_test.go | ||
resource_diff.go | ||
resource_diff_test.go | ||
resource_importer.go | ||
resource_test.go | ||
resource_timeout.go | ||
resource_timeout_test.go | ||
schema.go | ||
schema_test.go | ||
serialize.go | ||
serialize_test.go | ||
set.go | ||
set_test.go | ||
testing.go | ||
valuetype.go | ||
valuetype_string.go |
README.md
Terraform Helper Lib: schema
The schema
package provides a high-level interface for writing resource
providers for Terraform.
If you're writing a resource provider, we recommend you use this package.
The interface exposed by this package is much friendlier than trying to write to the Terraform API directly. The core Terraform API is low-level and built for maximum flexibility and control, whereas this library is built as a framework around that to more easily write common providers.