Skip to content

Commit

Permalink
update fields values to camel case in ruby
Browse files Browse the repository at this point in the history
  • Loading branch information
megan07 committed Jun 8, 2020
1 parent 2e5c2e0 commit 1c63154
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 43 deletions.
12 changes: 6 additions & 6 deletions products/datacatalog/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -453,28 +453,28 @@ objects:
within a tag do not have to be sequential.
output: true
- !ruby/object:Api::Type::Double
name: double_value
name: doubleValue
description: |
Holds the value for a tag field with double type.
- !ruby/object:Api::Type::String
name: string_value
name: stringValue
description: |
Holds the value for a tag field with string type.
- !ruby/object:Api::Type::Boolean
name: bool_value
name: boolValue
description: |
Holds the value for a tag field with boolean type.
- !ruby/object:Api::Type::String
name: timestamp_value
name: timestampValue
description: |
Holds the value for a tag field with timestamp type.
- !ruby/object:Api::Type::NestedObject
name: enum_value
name: enumValue
description: |
Holds the value for a tag field with enum type. This value must be one of the allowed values in the definition of this enum.
properties:
- !ruby/object:Api::Type::String
name: display_name
name: displayName
description: |
The display name of the enum value.
required: true
Expand Down
7 changes: 3 additions & 4 deletions products/datacatalog/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -158,18 +158,17 @@ overrides: !ruby/object:Overrides::ResourceOverrides
# this doesn't conflict with tag template's display name methods
templateDisplayName: !ruby/object:Overrides::Terraform::PropertyOverride
name: template_displayname
fields.enum_value: !ruby/object:Overrides::Terraform::PropertyOverride
fields.enumValue: !ruby/object:Overrides::Terraform::PropertyOverride
flatten_object: true
# because `fields` is a set, the current generated expand code can't properly retrieve
# enum_value by d.Get("enum_value") without knowing the set id, however, the value
# `v` is the correct value and passed to expand, so this custom expand will use
# that as the correct `enum_value.display_name` value
custom_expand: templates/terraform/custom_expand/data_catalog_tag.go.erb
fields.enum_value.display_name: !ruby/object:Overrides::Terraform::PropertyOverride
custom_flatten: templates/terraform/custom_flatten/data_catalog_tag.go.erb
fields.enumValue.displayName: !ruby/object:Overrides::Terraform::PropertyOverride
name: enum_value
required: false
fields: !ruby/object:Overrides::Terraform::PropertyOverride
custom_flatten: templates/terraform/custom_flatten/data_catalog_tag.go.erb
custom_code: !ruby/object:Provider::Terraform::CustomCode
custom_import: templates/terraform/custom_import/data_catalog_tag.go.erb
# This is for copying files over
Expand Down
2 changes: 1 addition & 1 deletion templates/terraform/custom_expand/data_catalog_tag.go.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func expand<%= prefix -%><%= titlelize_property(property) -%>(v interface{}, d T
// v is the value we want from the config
transformed := make(map[string]interface{})
if val := reflect.ValueOf(v); val.IsValid() && !isEmptyValue(val) {
transformed["display_name"] = v
transformed["displayName"] = v
}

return transformed, nil
Expand Down
32 changes: 0 additions & 32 deletions templates/terraform/custom_flatten/data_catalog_tag.go.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,38 +13,6 @@
# limitations under the License.
-%>
func flatten<%= prefix -%><%= titlelize_property(property) -%>(v interface{}, d *schema.ResourceData, config *Config) interface{} {
if v == nil {
return v
}
l := v.(map[string]interface{})
transformed := make([]interface{}, 0, len(l))
for k, raw := range l {
original := raw.(map[string]interface{})
transformedTag := map[string]interface{}{
"field_name": k,
"display_name": flattenDataCatalogTagFieldsDisplayName(original["displayName"], d, config),
"order": flattenDataCatalogTagFieldsOrder(original["order"], d, config),
"bool_value": original["boolValue"],
"double_value": original["doubleValue"],
"string_value": original["stringValue"],
"timestamp_value": original["timestampValue"],
"enum_value": flattenDataCatalogTagFieldsEnumValue(original["enumValue"], d, config),
}

transformed = append(transformed, transformedTag)
}
return transformed
}

func flattenDataCatalogTagFieldsDisplayName(v interface{}, d *schema.ResourceData, config *Config) interface{} {
return v
}

func flattenDataCatalogTagFieldsOrder(v interface{}, d *schema.ResourceData, config *Config) interface{} {
return v
}

func flattenDataCatalogTagFieldsEnumValue(v interface{}, d *schema.ResourceData, config *Config) interface{} {
if v == nil {
return nil
}
Expand Down

0 comments on commit 1c63154

Please sign in to comment.