Skip to content

Commit 20d08e8

Browse files
authored
tgc-revival: set the value to unknown for required fields missing in cais (#15993)
1 parent 24cf896 commit 20d08e8

File tree

10 files changed

+11
-41
lines changed

10 files changed

+11
-41
lines changed

mmv1/products/alloydb/Cluster.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ custom_code:
5959
pre_create: 'templates/terraform/pre_create/alloydb_cluster.go.tmpl'
6060
pre_update: 'templates/terraform/pre_update/alloydb_cluster.go.tmpl'
6161
pre_delete: 'templates/terraform/pre_delete/alloydb_cluster.go.tmpl'
62-
tgc_decoder: 'templates/tgc_next/decoders/alloydb_cluster.go.tmpl'
6362
# Skipping the sweeper because we need to force-delete clusters.
6463
exclude_sweeper: true
6564
include_in_tgc_next: true

mmv1/products/compute/Image.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ iam_policy:
5858
include_in_tgc_next: true
5959
tgc_include_handwritten_tests: true
6060
custom_code:
61-
tgc_decoder: 'templates/tgc_next/decoders/compute_image.go.tmpl'
6261
examples:
6362
- name: 'image_basic'
6463
primary_resource_id: 'example'

mmv1/products/compute/RegionSslCertificate.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ async:
5151
resource_inside_response: false
5252
collection_url_key: 'items'
5353
custom_code:
54-
tgc_decoder: 'templates/tgc_next/custom_expand/region_ssl_certificate_decoder.go.tmpl'
5554
extra_schema_entry: 'templates/terraform/extra_schema_entry/ssl_certificate.tmpl'
5655
constants: 'templates/terraform/constants/compute_certificate.go.tmpl'
5756
examples:

mmv1/products/netapp/ActiveDirectory.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ async:
4343
result:
4444
resource_inside_response: false
4545
custom_code:
46-
tgc_decoder: 'templates/tgc_next/decoders/netapp_active_directory.go.tmpl'
4746
# Skipping the sweeper since we need to sweep multiple regions
4847
exclude_sweeper: true
4948
examples:

mmv1/templates/terraform/flatten_property_method.go.tmpl

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func flatten{{$.GetPrefix}}{{$.TitlelizeProperty}}(v interface{}, d *schema.Reso
2424
if v == nil {
2525
return nil
2626
}
27-
{{- if not $.AllowEmptyObject }}
27+
{{- if and (not $.AllowEmptyObject) (not $.ResourceMetadata.IsTgcCompiler) }}
2828
original := v.(map[string]interface{})
2929
if len(original) == 0 {
3030
return nil
@@ -165,6 +165,15 @@ func flatten{{$.GetPrefix}}{{$.TitlelizeProperty}}(v interface{}, d *schema.Reso
165165
return false
166166
}
167167
return v
168+
{{- else if and ($.ResourceMetadata.IsTgcCompiler) ($.IsA "String") ($.Required) }}
169+
if v == nil {
170+
return "unknown"
171+
}
172+
transformed := v.(string)
173+
if transformed == "" {
174+
return "unknown"
175+
}
176+
return v
168177
{{- else }}
169178
return v
170179
{{- end }}

mmv1/templates/tgc_next/custom_expand/region_ssl_certificate_decoder.go.tmpl

Lines changed: 0 additions & 8 deletions
This file was deleted.

mmv1/templates/tgc_next/decoders/alloydb_cluster.go.tmpl

Lines changed: 0 additions & 8 deletions
This file was deleted.

mmv1/templates/tgc_next/decoders/compute_image.go.tmpl

Lines changed: 0 additions & 6 deletions
This file was deleted.

mmv1/templates/tgc_next/decoders/iam_workload_identity_pool_provider.go.tmpl

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
// These fields are missing in CAI assets, but requried in Terraform
2-
if saml, ok := res["saml"].(map[string]interface{}); ok {
3-
saml["idpMetadataXml"] = "unknown"
4-
}
5-
62
if x509, ok := res["x509"].(map[string]interface{}); ok {
73
if trustStore, ok := x509["trustStore"].(map[string]interface{}); ok {
84
if trustAnchors, ok := trustStore["trustAnchors"].([]interface{}); ok {
5+
// trust_anchors is missing in CAI assets, but requried in Terraform
96
for _, trustAnchorRaw := range trustAnchors {
107
if trustAnchor, ok := trustAnchorRaw.(map[string]interface{}); ok {
118
trustAnchor["pemCertificate"] = "hidden"

mmv1/templates/tgc_next/decoders/netapp_active_directory.go.tmpl

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)