feat(host/plugin): Support External Name field

The new `ExternalName` field is an optional field that is used to store
the cloud providers' human-identifiable name for a given compute
instance. This field is not user-editable, but it is kept in sync with
the cloud provider's through Boundary's `SetSyncJob`.
This commit is contained in:
Hugo Vieira authored and Hugo committed 2023-04-04 18:51:04 +01:00
1 parent 26ebaefd70
commit 2ff9b8efac
13 files changed
+340 -132

No files matched your search

@@ -30,12 +30,13 @@ func TestUtilFunctions(t *testing.T) {
require.NoError(t, err)
baseResponseHost := &plgpb.ListHostsResponseHost{
ExternalId: externalId,
Name: "base-name",
Description: "base-description",
IpAddresses: []string{"1.2.3.4", "5.6.7.8"},
DnsNames: []string{"a.b.c", "x.y.z"},
SetIds: []string{"set1", "set2"},
ExternalId: externalId,
ExternalName: "base-external-name",
Name: "base-name",
Description: "base-description",
IpAddresses: []string{"1.2.3.4", "5.6.7.8"},
DnsNames: []string{"a.b.c", "x.y.z"},
SetIds: []string{"set1", "set2"},
}
baseIpsIfaces := valueToInterfaceMap{}
for _, v := range baseResponseHost.IpAddresses {
@@ -50,6 +51,7 @@ func TestUtilFunctions(t *testing.T) {
baseDnsNamesIfaces[v] = name
}
baseHost := NewHost(ctx, catalog.PublicId, externalId)
baseHost.ExternalName = baseResponseHost.ExternalName
baseHost.Name = baseResponseHost.Name
baseHost.Description = baseResponseHost.Description
baseHost.IpAddresses = baseResponseHost.IpAddresses
@@ -124,6 +126,18 @@ func TestUtilFunctions(t *testing.T) {
return in, hi
},
},
{
name: "new-external-name",
host: defaultHostFunc,
sets: defaultSetsFunc,
in: func(in *plgpb.ListHostsResponseHost) (*plgpb.ListHostsResponseHost, *hostInfo) {
in.ExternalName = "newextname"
hi := &hostInfo{
dirtyHost: true,
}
return in, hi
},
},
{
name: "extra-ip",
host: defaultHostFunc,