Skip to content

Commit

Permalink
Add support for description to tag template fields (hashicorp#8810)
Browse files Browse the repository at this point in the history
  • Loading branch information
geirsagberg committed Mar 31, 2021
1 parent 4164ca0 commit ff99d90
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
21 changes: 21 additions & 0 deletions google/resource_data_catalog_tag_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ Multiple fields can have the same order, and field orders within a tag do not ha
Computed: true,
Description: `The resource name of the tag template field in URL format. Example: projects/{project_id}/locations/{location}/tagTemplates/{tagTemplateId}/fields/{field}`,
},
"description": {
Type: schema.TypeString,
Optional: true,
Description: `A description for this field.`,
},
},
},
},
Expand Down Expand Up @@ -432,6 +437,7 @@ func flattenDataCatalogTagTemplateFields(v interface{}, d *schema.ResourceData,
"type": flattenDataCatalogTagTemplateFieldsType(original["type"], d, config),
"is_required": flattenDataCatalogTagTemplateFieldsIsRequired(original["isRequired"], d, config),
"order": flattenDataCatalogTagTemplateFieldsOrder(original["order"], d, config),
"description": flattenDataCatalogTagTemplateFieldsDescription(original["description"], d, config),
})
}
return transformed
Expand All @@ -444,6 +450,10 @@ func flattenDataCatalogTagTemplateFieldsDisplayName(v interface{}, d *schema.Res
return v
}

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

func flattenDataCatalogTagTemplateFieldsType(v interface{}, d *schema.ResourceData, config *Config) interface{} {
if v == nil {
return nil
Expand Down Expand Up @@ -546,6 +556,13 @@ func expandDataCatalogTagTemplateFields(v interface{}, d TerraformResourceData,
transformed["displayName"] = transformedDisplayName
}

transformedDescription, err := expandDataCatalogTagTemplateFieldsDescription(original["description"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedDescription); val.IsValid() && !isEmptyValue(val) {
transformed["description"] = transformedDescription
}

transformedType, err := expandDataCatalogTagTemplateFieldsType(original["type"], d, config)
if err != nil {
return nil, err
Expand Down Expand Up @@ -584,6 +601,10 @@ func expandDataCatalogTagTemplateFieldsDisplayName(v interface{}, d TerraformRes
return v, nil
}

func expandDataCatalogTagTemplateFieldsDescription(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
return v, nil
}

func expandDataCatalogTagTemplateFieldsType(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
l := v.([]interface{})
if len(l) == 0 || l[0] == nil {
Expand Down
1 change: 1 addition & 0 deletions google/resource_data_catalog_tag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ resource "google_data_catalog_tag_template" "tag_template" {
primitive_type = "STRING"
}
is_required = true
description = "The source of the data asset"
}
fields {
Expand Down

0 comments on commit ff99d90

Please sign in to comment.