diff --git a/globals/fields.go b/globals/fields.go index 1184aacb51..9386b711c4 100644 --- a/globals/fields.go +++ b/globals/fields.go @@ -83,6 +83,7 @@ const ( MetricNamespace = "boundary" LastStatusTimeField = "last_status_time" AddressField = "address" + AliasesField = "aliases" CanonicalAddressField = "canonical_address" TagsField = "tags" CanonicalTagsField = "canonical_tags" diff --git a/internal/daemon/controller/handlers/targets/target_service.go b/internal/daemon/controller/handlers/targets/target_service.go index cb94da5c9e..8f56c5c86c 100644 --- a/internal/daemon/controller/handlers/targets/target_service.go +++ b/internal/daemon/controller/handlers/targets/target_service.go @@ -1728,6 +1728,7 @@ func toProto(ctx context.Context, in target.Target, opt ...handlers.Option) (*pb outputFields := *opts.WithOutputFields hostSources := in.GetHostSources() credSources := in.GetCredentialSources() + aliases := in.GetAliases() out := pb.Target{} if outputFields.Has(globals.IdField) { @@ -1788,6 +1789,14 @@ func toProto(ctx context.Context, in target.Target, opt ...handlers.Option) (*pb }) } } + if outputFields.Has(globals.AliasesField) { + for _, a := range aliases { + out.Aliases = append(out.Aliases, &pb.Alias{ + Id: a.PublicId, + Value: a.Value, + }) + } + } if outputFields.Has(globals.AddressField) { out.Address = wrapperspb.String(in.GetAddress()) } diff --git a/internal/daemon/controller/handlers/targets/tcp/target_service_test.go b/internal/daemon/controller/handlers/targets/tcp/target_service_test.go index ee8fb1d829..b660f91d7b 100644 --- a/internal/daemon/controller/handlers/targets/tcp/target_service_test.go +++ b/internal/daemon/controller/handlers/targets/tcp/target_service_test.go @@ -159,6 +159,11 @@ func TestGet(t *testing.T) { al := talias.TestAlias(t, rw, "test.alias", talias.WithDestinationId(tar.GetPublicId())) alNoDest := talias.TestAlias(t, rw, "no.destination.test.alias") + pAlias := &pb.Alias{ + Id: al.GetPublicId(), + Value: al.GetValue(), + } + pTar := &pb.Target{ Id: tar.GetPublicId(), ScopeId: proj.GetPublicId(), @@ -173,6 +178,7 @@ func TestGet(t *testing.T) { SessionConnectionLimit: wrapperspb.Int32(-1), AuthorizedActions: testAuthorizedActions, Address: &wrapperspb.StringValue{}, + Aliases: []*pb.Alias{pAlias}, } for _, ihs := range hs { pTar.HostSources = append(pTar.HostSources, &pb.HostSource{Id: ihs.GetPublicId(), HostCatalogId: ihs.GetCatalogId()})