hashicorp / terraform-provider-google

Terraform Provider for Google Cloud Platform
https://registry.terraform.io/providers/hashicorp/google/latest/docs
Mozilla Public License 2.0
2.32k stars 1.72k forks source link

Add first-class support for JSON fields in MMv1 #15796

Open melinath opened 1 year ago

melinath commented 1 year ago

Background

There are currently about 42 JSON fields represented in yaml files, like so:

      - !ruby/object:Api::Type::String
        name: field_name
        custom_expand: 'templates/terraform/custom_expand/json_schema.erb'
        custom_flatten: 'templates/terraform/custom_flatten/json_schema.erb'
        state_func:
          'func(v interface{}) string { s, _ :=
          structure.NormalizeJsonString(v); return s }'
        validation: !ruby/object:Provider::Terraform::Validation
          function: 'validation.StringIsJSON'

Since this is a common type of field, it could make sense for us to handle it as a standard subtype.

What kind of contribution is this issue about?

rileykarson commented 1 year ago

Note: This is how we handle the "Value" type in Google APIs

SarahFrench commented 1 year ago

Also "struct" type is used in the affected Google API docs

SarahFrench commented 1 year ago

Note: inconsistent use of expanders