feat(terraform): honor const values on array and map properties

AS
3d ago
+2146-24

Summary

Array and map properties that declare a const value were parsed as ordinary fields: the schema parser only attached const/default metadata to containers when a default was present. Terraform therefore exposed them as configurable attributes and sent whatever was in state instead of the const value. Scalar consts were already handled correctly.

  • Parser: attach const metadata to arrays, sets and maps behind two new Experimental features, constArrays and constObjects (declared for the Terraform target). Consts whose elements are not scalars, or consts on objects with properties, are dropped with a validation warning.
  • Go models: emit a const struct tag carrying the JSON encoding for container fields, render Go literals for their getters, and compare received const values structurally when unmarshaling so whitespace differences from the server do not fail decoding.
  • Terraform: no template change needed. The existing const handling already removes the field from the resource/data-source schema and skips it when building requests, so the SDK model injects the value.

Behavior change

For providers whose spec has const on an array or map property, the attribute is removed from the resource schema. Configs that set it will need the line removed. Prior state is unaffected: the plugin framework drops attributes the schema no longer has.

Testing

  • Parser unit tests for array and map consts, including feature-off and element-type-mismatch cases.
  • New ConstContainer entity in the review spec with an acceptance test asserting the request body carries [], ["read","write"], {} and {"max":10} while the config sets only name.
  • Full Terraform acceptance suite, make lint, and template type checks pass. Review Go, CLI and Terraform fixtures regenerated.

Summary by cubic

Fixes const values on array and map properties being parsed as configurable attributes, so Terraform sent whatever was in state instead of the const value. Consts on arrays, sets, and maps are now attached behind two new Experimental features, constArrays and constObjects, hidden from the resource schema, and injected into request bodies. Scalar consts were already handled correctly.

Behavior change

  • Attributes with container consts are removed from the resource schema; configs that set them must remove those lines.
  • Prior state is unaffected; the plugin framework drops attributes the schema no longer has.
  • Consts are dropped with a validation warning when their elements are non-scalar, items are nullable, or the container is an object with properties; uuid and duration items are now accepted.
  • Received const values are compared structurally with exact JSON number equality, so whitespace differences from the server do not fail decoding.
  • Container default and const metadata are gated independently, so a const cannot ride along on a target that only supports container defaults.