mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-26 17:01:04 -06:00
0bbbb9c64b
This builds on an experimental feature in the underlying cty library which allows marking specific attribtues of an object type constraint as optional, which in turn modifies how the cty conversion package handles missing attributes in a source value: it will silently substitute a null value of the appropriate type rather than returning an error. In order to implement the experiment this commit temporarily forks the HCL typeexpr extension package into a local internal/typeexpr package, where I've extended the type constraint syntax to allow annotating object type attributes as being optional using the HCL function call syntax. If the experiment is successful -- both at the Terraform layer and in the underlying cty library -- we'll likely send these modifications to upstream HCL so that other HCL-based languages can potentially benefit from this new capability. Because it's experimental, the optional attribute modifier is allowed only with an explicit opt-in to the module_variable_optional_attrs experiment.
11 lines
554 B
Go
11 lines
554 B
Go
// Package typeexpr is a fork of github.com/hashicorp/hcl/v2/ext/typeexpr
|
|
// which has additional experimental support for optional attributes.
|
|
//
|
|
// This is here as part of the module_variable_optional_attrs experiment.
|
|
// If that experiment is successful, the changes here may be upstreamed into
|
|
// HCL itself or, if we deem it to be Terraform-specific, we should at least
|
|
// update this documentation to reflect that this is now the primary
|
|
// Terraform-specific type expression implementation, separate from the
|
|
// upstream HCL one.
|
|
package typeexpr
|