api(targets): add aliases to targets (#4337)
* api(targets): add aliases to targets
This commit is contained in:
1 parent
96d1f094a3
commit
eceb1fd40e
3 files changed
+16
No files matched your search
@@ -83,6 +83,7 @@ const (
|
||||
MetricNamespace = "boundary"
|
||||
LastStatusTimeField = "last_status_time"
|
||||
AddressField = "address"
|
||||
AliasesField = "aliases"
|
||||
CanonicalAddressField = "canonical_address"
|
||||
TagsField = "tags"
|
||||
CanonicalTagsField = "canonical_tags"
|
||||
|
||||
@@ -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())
|
||||
}
|
||||
|
||||
@@ -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()})
|
||||
|
||||
Reference in new issue
Block a user