1e81a3e7fa
When the following conditions were met: * Schema attribute with a primative type (e.g. Type: TypeString) and Computed: true * Old state of attribute set to zero value for type (e.g. "") * Old state ID of resource set to non-empty (e.g. existing resource) Attempting to use CustomizeDiff with SetNewComputed() would result in the difference previously being discarded. This update ensures that previous zero values or resource existence does not influence the propagation of the computed update. Previously: ``` --- FAIL: TestSetNewComputed (0.00s) --- FAIL: TestSetNewComputed/NewComputed_should_always_propagate (0.00s) resource_diff_test.go:684: Expected (*terraform.InstanceDiff)(0xc00051cea0)({ mu: (sync.Mutex) { state: (int32) 0, sema: (uint32) 0 }, Attributes: (map[string]*terraform.ResourceAttrDiff) (len=1) { (string) (len=3) "foo": (*terraform.ResourceAttrDiff)(0xc0003dcec0)({ Old: (string) "", New: (string) "", NewComputed: (bool) true, NewRemoved: (bool) false, NewExtra: (interface {}) <nil>, RequiresNew: (bool) false, Sensitive: (bool) false, Type: (terraform.DiffAttrType) 0 }) }, Destroy: (bool) false, DestroyDeposed: (bool) false, DestroyTainted: (bool) false, Meta: (map[string]interface {}) <nil> }) , got (*terraform.InstanceDiff)(0xc00051ce80)({ mu: (sync.Mutex) { state: (int32) 0, sema: (uint32) 0 }, Attributes: (map[string]*terraform.ResourceAttrDiff) { }, Destroy: (bool) false, DestroyDeposed: (bool) false, DestroyTainted: (bool) false, Meta: (map[string]interface {}) <nil> }) --- FAIL: TestSchemaMap_Diff (0.01s) --- FAIL: TestSchemaMap_Diff/79-NewComputed_should_always_propagate_with_CustomizeDiff (0.00s) schema_test.go:3289: expected: *terraform.InstanceDiff{mu:sync.Mutex{state:0, sema:0x0}, Attributes:map[string]*terraform.ResourceAttrDiff{"foo":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}}, Destroy:false, DestroyDeposed:false, DestroyTainted:false, Meta:map[string]interface {}(nil)} got: <nil> FAIL FAIL github.com/hashicorp/terraform/helper/schema 0.825s ``` |
||
---|---|---|
.. | ||
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 | ||
shims.go | ||
shims_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.