Skip to content

Commit 6f6457d

Browse files
authored
tgc-revival: add kms resources to tgc (#15167)
1 parent 82fa989 commit 6f6457d

File tree

5 files changed

+21
-1
lines changed

5 files changed

+21
-1
lines changed

mmv1/products/kms/AutokeyConfig.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ custom_code:
5555
test_check_destroy: 'templates/terraform/custom_check_destroy/kms_autokey_config.go.tmpl'
5656
# Using a handwritten sweeper because of pre_delete.
5757
exclude_sweeper: true
58+
include_in_tgc_next_DO_NOT_USE: true
5859
examples:
5960
- name: 'kms_autokey_config_all'
6061
primary_resource_id: 'example-autokeyconfig'

mmv1/products/kms/KeyHandle.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ async:
4848
resource_inside_response: true
4949
custom_code:
5050
decoder: 'templates/terraform/decoders/kms.go.tmpl'
51+
tgc_decoder: 'templates/tgc_next/decoders/kms.go.tmpl'
52+
include_in_tgc_next_DO_NOT_USE: true
5153
examples:
5254
- name: 'kms_key_handle_basic'
5355
primary_resource_id: 'example-keyhandle'

mmv1/templates/terraform/decoders/kms.go.tmpl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,8 @@
1414
// We can't just ignore_read on `name` as the linter will
1515
// complain that the returned `res` is never used afterwards.
1616
// Some field needs to be actually set, and we chose `name`.
17-
res["name"] = d.Get("name").(string)
17+
v := d.Get("name")
18+
if v != nil {
19+
res["name"] = v.(string)
20+
}
1821
return res, nil
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
if raw, ok := res["name"]; ok {
2+
res["name"] = tpgresource.GetResourceNameFromSelfLink(raw.(string))
3+
}
4+
5+
return res, hclData, nil

mmv1/third_party/tgc_next/test/assert_test_files.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,15 @@ func testSingleResource(t *testing.T, testName string, testData ResourceTestData
258258
yParts := strings.Split(y, "/")
259259
return xParts[len(xParts)-1] == yParts[len(yParts)-1]
260260
})),
261+
cmp.FilterPath(func(p cmp.Path) bool {
262+
// Filter if "parent" field in original asset is an empty string
263+
// and then ingore comparing
264+
if p.Last().String() == ".Parent" {
265+
v1, _ := p.Index(-1).Values()
266+
return v1.IsZero()
267+
}
268+
return false
269+
}, cmp.Ignore()),
261270
); diff != "" {
262271
return fmt.Errorf("differences found between exported asset and roundtrip asset (-want +got):\n%s", diff)
263272
}

0 commit comments

Comments
 (0)