mirror of
https://github.com/opentofu/opentofu.git
synced 2025-01-24 15:36:26 -06:00
85ec09111b
This commit adds a new callback, DiffSuppressFunc, to the schema.Schema structure. If set for a given schema, a callback to the user-supplied function will be made for each attribute for which the default type-based diff mechanism produces an attribute diff. Returning `true` from the callback will suppress the diff (i.e. pretend there was no diff), and returning false will retain it as part of the plan. There are a number of motivating examples for this - one of which is included as an example: 1. On SSH public keys, trailing whitespace does not matter in many cases - and in some cases it is added by provider APIs. For digitalocean_ssh_key resources we previously had a StateFunc that trimmed the whitespace - we now have a DiffSuppressFunc which verifies whether the trimmed strings are equivalent. 2. IAM policy equivalence for AWS. A good proportion of AWS issues relate to IAM policies which have been "normalized" (used loosely) by the IAM API endpoints. This can make the JSON strings differ from those generated by iam_policy_document resources or template files, even though the semantics are the same (for example, reordering of `bucket-prefix/` and `bucket-prefix/*` in an S3 bucket policy. DiffSupressFunc can be used to test for semantic equivalence rather than pure text equivalence, but without having to deal with the complexity associated with a full "provider-land" diff implementation without helper/schema. |
||
---|---|---|
.. | ||
data_source_resource_shim.go | ||
equal.go | ||
field_reader_config_test.go | ||
field_reader_config.go | ||
field_reader_diff_test.go | ||
field_reader_diff.go | ||
field_reader_map_test.go | ||
field_reader_map.go | ||
field_reader_multi_test.go | ||
field_reader_multi.go | ||
field_reader_test.go | ||
field_reader.go | ||
field_writer_map_test.go | ||
field_writer_map.go | ||
field_writer.go | ||
getsource_string.go | ||
provider_test.go | ||
provider.go | ||
README.md | ||
resource_data_get_source.go | ||
resource_data_test.go | ||
resource_data.go | ||
resource_importer.go | ||
resource_test.go | ||
resource.go | ||
schema_test.go | ||
schema.go | ||
serialize_test.go | ||
serialize.go | ||
set_test.go | ||
set.go | ||
valuetype_string.go | ||
valuetype.go |
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.