Skip to content

Commit 22e1229

Browse files
Adding version to infoTypes in data_loss_prevention_inspect_template (#7047) (#13366)
fixes #12171 Signed-off-by: Modular Magician <[email protected]> Signed-off-by: Modular Magician <[email protected]>
1 parent 4209194 commit 22e1229

4 files changed

+33
-3
lines changed

.changelog/7047.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
dlp: added `version` field to `data_loss_prevention_inspect_template` resource
3+
```

google/resource_data_loss_prevention_inspect_template.go

+22-1
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,11 @@ By default this may be all types, but may change over time as detectors are upda
234234
Description: `Name of the information type. Either a name of your choosing when creating a CustomInfoType, or one of the names listed
235235
at https://cloud.google.com/dlp/docs/infotypes-reference when specifying a built-in type.`,
236236
},
237+
"version": {
238+
Type: schema.TypeString,
239+
Optional: true,
240+
Description: `Version of the information type to use. By default, the version is set to stable`,
241+
},
237242
},
238243
},
239244
},
@@ -955,7 +960,8 @@ func flattenDataLossPreventionInspectTemplateInspectConfigInfoTypes(v interface{
955960
continue
956961
}
957962
transformed = append(transformed, map[string]interface{}{
958-
"name": flattenDataLossPreventionInspectTemplateInspectConfigInfoTypesName(original["name"], d, config),
963+
"name": flattenDataLossPreventionInspectTemplateInspectConfigInfoTypesName(original["name"], d, config),
964+
"version": flattenDataLossPreventionInspectTemplateInspectConfigInfoTypesVersion(original["version"], d, config),
959965
})
960966
}
961967
return transformed
@@ -964,6 +970,10 @@ func flattenDataLossPreventionInspectTemplateInspectConfigInfoTypesName(v interf
964970
return v
965971
}
966972

973+
func flattenDataLossPreventionInspectTemplateInspectConfigInfoTypesVersion(v interface{}, d *schema.ResourceData, config *Config) interface{} {
974+
return v
975+
}
976+
967977
func flattenDataLossPreventionInspectTemplateInspectConfigContentOptions(v interface{}, d *schema.ResourceData, config *Config) interface{} {
968978
return v
969979
}
@@ -1622,6 +1632,13 @@ func expandDataLossPreventionInspectTemplateInspectConfigInfoTypes(v interface{}
16221632
transformed["name"] = transformedName
16231633
}
16241634

1635+
transformedVersion, err := expandDataLossPreventionInspectTemplateInspectConfigInfoTypesVersion(original["version"], d, config)
1636+
if err != nil {
1637+
return nil, err
1638+
} else if val := reflect.ValueOf(transformedVersion); val.IsValid() && !isEmptyValue(val) {
1639+
transformed["version"] = transformedVersion
1640+
}
1641+
16251642
req = append(req, transformed)
16261643
}
16271644
return req, nil
@@ -1631,6 +1648,10 @@ func expandDataLossPreventionInspectTemplateInspectConfigInfoTypesName(v interfa
16311648
return v, nil
16321649
}
16331650

1651+
func expandDataLossPreventionInspectTemplateInspectConfigInfoTypesVersion(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
1652+
return v, nil
1653+
}
1654+
16341655
func expandDataLossPreventionInspectTemplateInspectConfigContentOptions(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
16351656
return v, nil
16361657
}

google/resource_data_loss_prevention_inspect_template_test.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ resource "google_data_loss_prevention_inspect_template" "basic" {
5151
name = "EMAIL_ADDRESS"
5252
}
5353
info_types {
54-
name = "PERSON_NAME"
54+
name = "PERSON_NAME"
55+
version = "latest"
5556
}
5657
info_types {
5758
name = "LAST_NAME"
@@ -157,7 +158,8 @@ resource "google_data_loss_prevention_inspect_template" "basic" {
157158
158159
inspect_config {
159160
info_types {
160-
name = "PERSON_NAME"
161+
name = "PERSON_NAME"
162+
version = "stable"
161163
}
162164
info_types {
163165
name = "LAST_NAME"

website/docs/r/data_loss_prevention_inspect_template.html.markdown

+4
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,10 @@ The following arguments are supported:
327327
Name of the information type. Either a name of your choosing when creating a CustomInfoType, or one of the names listed
328328
at https://cloud.google.com/dlp/docs/infotypes-reference when specifying a built-in type.
329329

330+
* `version` -
331+
(Optional)
332+
Version of the information type to use. By default, the version is set to stable
333+
330334
<a name="nested_rule_set"></a>The `rule_set` block supports:
331335

332336
* `info_types` -

0 commit comments

Comments
 (0)