Skip to content

Commit 67f09bb

Browse files
tgc-revival: add google_monitoring_alert_policy to TGC (#16003)
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
1 parent b4135cb commit 67f09bb

File tree

6 files changed

+40
-1
lines changed

6 files changed

+40
-1
lines changed

mmv1/api/resource.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2535,12 +2535,18 @@ func (r Resource) TGCTestIgnorePropertiesToStrings() []string {
25352535
}
25362536
}
25372537

2538+
for _, e := range r.Examples {
2539+
for _, p := range e.IgnoreReadExtra {
2540+
props = append(props, p)
2541+
}
2542+
}
2543+
25382544
if r.IgnoreCaiAssetName() {
25392545
props = append(props, "ASSETNAME")
25402546
}
25412547

25422548
slices.Sort(props)
2543-
return props
2549+
return slices.Compact(props)
25442550
}
25452551

25462552
// Filters out computed properties during cai2hcl

mmv1/products/compute/RegionSslCertificate.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ references:
2323
guides:
2424
'Official Documentation': 'https://cloud.google.com/load-balancing/docs/ssl-certificates'
2525
api: 'https://cloud.google.com/compute/docs/reference/rest/v1/regionSslCertificates'
26+
include_in_tgc_next: true
27+
tgc_include_handwritten_tests: true
2628
docs:
2729
optional_properties: |
2830
* `name_prefix` - (Optional) Creates a unique name beginning with the
@@ -49,6 +51,7 @@ async:
4951
resource_inside_response: false
5052
collection_url_key: 'items'
5153
custom_code:
54+
tgc_decoder: 'templates/tgc_next/custom_expand/region_ssl_certificate_decoder.go.tmpl'
5255
extra_schema_entry: 'templates/terraform/extra_schema_entry/ssl_certificate.tmpl'
5356
constants: 'templates/terraform/constants/compute_certificate.go.tmpl'
5457
examples:
@@ -96,6 +99,7 @@ properties:
9699
The chain must include at least one intermediate cert.
97100
required: true
98101
sensitive: true
102+
is_missing_in_cai: true
99103
- name: 'creationTimestamp'
100104
type: Time
101105
description: 'Creation timestamp in RFC3339 text format.'
@@ -137,3 +141,4 @@ properties:
137141
sensitive: true
138142
diff_suppress_func: 'sha256DiffSuppress'
139143
custom_flatten: 'templates/terraform/custom_flatten/sha256.tmpl'
144+
is_missing_in_cai: true

mmv1/products/datastream/ConnectionProfile.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,7 @@ properties:
626626
Specifies whether the client connects directly to the
627627
host[:port] in the connection URI.
628628
- name: 'forwardSshConnectivity'
629+
is_missing_in_cai: true
629630
type: NestedObject
630631
description: |
631632
Forward SSH tunnel connectivity.

mmv1/products/monitoring/AlertPolicy.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,16 @@ timeouts:
3737
custom_code:
3838
constants: 'templates/terraform/constants/monitoring_alert_policy.go.tmpl'
3939
custom_import: 'templates/terraform/custom_import/self_link_as_name_set_project.go.tmpl'
40+
include_in_tgc_next: true
41+
tgc_include_handwritten_tests: true
42+
tgc_tests:
43+
- name: 'TestAccMonitoringAlertPolicy/basic'
44+
- name: 'TestAccMonitoringAlertPolicy/forecast'
45+
- name: 'TestAccMonitoringAlertPolicy/full'
46+
- name: 'TestAccMonitoringAlertPolicy/log'
47+
- name: 'TestAccMonitoringAlertPolicy/mql'
48+
- name: 'TestAccMonitoringAlertPolicy/promql'
49+
- name: 'TestAccMonitoringAlertPolicy/update'
4050
error_retry_predicates:
4151

4252
- 'transport_tpg.IsMonitoringConcurrentEditError'
@@ -245,6 +255,7 @@ properties:
245255
otherwise an error is returned.
246256
- name: 'crossSeriesReducer'
247257
type: Enum
258+
custom_tgc_flatten: 'templates/tgc_next/custom_flatten/monitoring_alert_policy_cross_series_reducer.go.tmpl'
248259
description: |
249260
The approach to be used to combine
250261
time series. Not all reducer
@@ -538,6 +549,7 @@ properties:
538549
otherwise an error is returned.
539550
- name: 'crossSeriesReducer'
540551
type: Enum
552+
custom_tgc_flatten: 'templates/tgc_next/custom_flatten/monitoring_alert_policy_cross_series_reducer.go.tmpl'
541553
description: |
542554
The approach to be used to combine
543555
time series. Not all reducer
@@ -762,6 +774,7 @@ properties:
762774
otherwise an error is returned.
763775
- name: 'crossSeriesReducer'
764776
type: Enum
777+
custom_tgc_flatten: 'templates/tgc_next/custom_flatten/monitoring_alert_policy_cross_series_reducer.go.tmpl'
765778
description: |
766779
The approach to be used to combine
767780
time series. Not all reducer
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Inject dummy values for required fields missing in CAI
2+
if _, ok := res["privateKey"]; !ok {
3+
res["privateKey"] = "mc_is_missing_in_cai"
4+
}
5+
if _, ok := res["certificate"]; !ok {
6+
res["certificate"] = "mc_is_missing_in_cai"
7+
}
8+
return res, hclData, nil
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
func flatten{{$.GetPrefix}}{{$.TitlelizeProperty}}(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
2+
if v == nil || v == "" {
3+
return "REDUCE_NONE"
4+
}
5+
return v
6+
}

0 commit comments

Comments
 (0)