refact(target): Switch subtype attributes to oneof

This updates the target resources to use a oneof for attributes. This
allows requests to the targets service to leverage the new
subtypes.AttributeTransformerInterceptor so that attributes are strongly
typed prior to the service handler.
This commit is contained in:
Timothy Messier authored and Johan Brandhorst-Satzkorn committed 2022-04-20 13:32:32 -04:00
1 parent 8c452b0991
commit c8be4a9890
10 files changed
+483 -406

No files matched your search

+14 -1
View File
@@ -169,7 +169,13 @@ func TestList(t *testing.T) {
assert.ElementsMatch(comparableSlice(expected[:1]), comparableSlice(ul.Items))
for i := 1; i < 10; i++ {
tcr, err = tarClient.Create(tc.Context(), "tcp", proj.GetPublicId(), targets.WithName(expected[i].Name))
tcr, err = tarClient.Create(
tc.Context(),
"tcp",
proj.GetPublicId(),
targets.WithName(expected[i].Name),
targets.WithTcpTargetDefaultPort(uint32(i)),
)
require.NoError(err)
expected[i] = tcr.Item
}
@@ -183,6 +189,13 @@ func TestList(t *testing.T) {
require.NoError(err)
assert.Len(ul.Items, 1)
assert.Equal(filterItem.Id, ul.Items[0].Id)
filterstr := fmt.Sprintf(`"/item/attributes/default_port"==%d`, uint32(filterItem.Attributes["default_port"].(float64)))
ul, err = tarClient.List(tc.Context(), proj.GetPublicId(),
targets.WithFilter(filterstr))
require.NoError(err)
assert.Len(ul.Items, 1)
assert.Equal(filterItem.Id, ul.Items[0].Id)
}
func comparableSlice(in []*targets.Target) []targets.Target {