Skip to content

Commit 75e910a

Browse files
authored
Fix error details type on google_database_migration_service_migration_job (#12858)
1 parent 05d2bc2 commit 75e910a

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

mmv1/products/databasemigrationservice/MigrationJob.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ properties:
155155
description: |
156156
A list of messages that carry the error details.
157157
output: true
158+
custom_flatten: 'templates/terraform/custom_flatten/dms_migration_job_error_details.tmpl'
158159
item_type:
159160
type: KeyValuePairs
160161
- name: 'type'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{{/*
2+
The license inside this block applies to this file
3+
Copyright 2024 Google Inc.
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
7+
Unless required by applicable law or agreed to in writing, software
8+
distributed under the License is distributed on an "AS IS" BASIS,
9+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
See the License for the specific language governing permissions and
11+
limitations under the License.
12+
*/ -}}
13+
func flatten{{$.GetPrefix}}{{$.TitlelizeProperty}}(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
14+
if v == nil {
15+
return nil
16+
}
17+
detailsArray := v.([]interface{})
18+
for i, raw := range detailsArray {
19+
m := raw.(map[string]interface{})
20+
if len(m) < 1 {
21+
// Do not include empty json objects coming back from the api
22+
continue
23+
}
24+
for k, val := range m {
25+
if _, ok := val.(string); !ok {
26+
b, err := json.Marshal(v)
27+
if err != nil {
28+
return err
29+
}
30+
m[k] = string(b)
31+
}
32+
}
33+
detailsArray[i] = m
34+
}
35+
return detailsArray
36+
}

0 commit comments

Comments
 (0)