Skip to content

Commit 45dc825

Browse files
author
Hugo Vieira
committed
feat(api): Support plugin host external_name field
1 parent 2ff9b8e commit 45dc825

File tree

7 files changed

+51
-21
lines changed

7 files changed

+51
-21
lines changed

api/hosts/host.gen.go

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

globals/fields.go

+1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ const (
7272
DnsNamesField = "dns_names"
7373
SecretsHmacField = "secrets_hmac"
7474
ExternalIdField = "external_id"
75+
ExternalNameField = "external_name"
7576
InjectedApplicationCredentialSourceIdsField = "injected_application_credential_source_ids"
7677
InjectedApplicationCredentialSourcesField = "injected_application_credential_sources"
7778
ConnectionsField = "connections"

internal/daemon/controller/handlers/hosts/host_service.go

+3
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,9 @@ func toProto(ctx context.Context, in host.Host, opt ...handlers.Option) (*pb.Hos
598598
if outputFields.Has(globals.ExternalIdField) {
599599
out.ExternalId = h.ExternalId
600600
}
601+
if outputFields.Has(globals.ExternalNameField) {
602+
out.ExternalName = h.ExternalName
603+
}
601604
}
602605
return &out, nil
603606
}

internal/daemon/controller/handlers/hosts/host_service_test.go

+9-3
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,11 @@ func TestGet_Plugin(t *testing.T) {
165165
return static.NewRepository(rw, rw, kms)
166166
}
167167
hc := plugin.TestCatalog(t, conn, proj.GetPublicId(), plg.GetPublicId())
168-
h := plugin.TestHost(t, conn, hc.GetPublicId(), "test")
169-
hPrev := plugin.TestHost(t, conn, hc.GetPublicId(), "test-prev", plugin.WithPublicId(fmt.Sprintf("%s_1234567890", globals.PluginHostPreviousPrefix)))
168+
h := plugin.TestHost(t, conn, hc.GetPublicId(), "test", plugin.WithExternalName("test-ext-name"))
169+
hPrev := plugin.TestHost(t, conn, hc.GetPublicId(), "test-prev",
170+
plugin.WithPublicId(fmt.Sprintf("%s_1234567890", globals.PluginHostPreviousPrefix)),
171+
plugin.WithExternalName("test-prev-name"),
172+
)
170173
hs := plugin.TestSet(t, conn, kms, sche, hc, plgm)
171174
plugin.TestSetMembers(t, conn, hs.GetPublicId(), []*plugin.Host{h, hPrev})
172175

@@ -184,6 +187,7 @@ func TestGet_Plugin(t *testing.T) {
184187
},
185188
HostSetIds: []string{hs.GetPublicId()},
186189
ExternalId: "test",
190+
ExternalName: "test-ext-name",
187191
AuthorizedActions: testAuthorizedActions[plugin.Subtype],
188192
}
189193

@@ -207,6 +211,7 @@ func TestGet_Plugin(t *testing.T) {
207211
resp.CreatedTime = hPrev.CreateTime.GetTimestamp()
208212
resp.UpdatedTime = hPrev.UpdateTime.GetTimestamp()
209213
resp.ExternalId = "test-prev"
214+
resp.ExternalName = "test-prev-name"
210215
return &pbs.GetHostResponse{Item: resp}
211216
}(),
212217
},
@@ -397,7 +402,7 @@ func TestList_Plugin(t *testing.T) {
397402
var wantHs []*pb.Host
398403
for i := 0; i < 10; i++ {
399404
extId := fmt.Sprintf("host %d", i)
400-
h := plugin.TestHost(t, conn, hc.GetPublicId(), extId)
405+
h := plugin.TestHost(t, conn, hc.GetPublicId(), extId, plugin.WithExternalName(fmt.Sprintf("ext-name-%d", i)))
401406
plugin.TestSetMembers(t, conn, hs.GetPublicId(), []*plugin.Host{h})
402407
wantHs = append(wantHs, &pb.Host{
403408
Id: h.GetPublicId(),
@@ -413,6 +418,7 @@ func TestList_Plugin(t *testing.T) {
413418
HostSetIds: []string{hs.GetPublicId()},
414419
Version: 1,
415420
ExternalId: extId,
421+
ExternalName: fmt.Sprintf("ext-name-%d", i),
416422
Type: plugin.Subtype.String(),
417423
AuthorizedActions: testAuthorizedActions[plugin.Subtype],
418424
})

internal/gen/controller.swagger.json

+5
Original file line numberDiff line numberDiff line change
@@ -4711,6 +4711,11 @@
47114711
"description": "Output only. The external ID of the host, if any.",
47124712
"readOnly": true
47134713
},
4714+
"external_name": {
4715+
"type": "string",
4716+
"description": "Output only. Refers to the name for a given host provided by the plugin enabled backing service.",
4717+
"readOnly": true
4718+
},
47144719
"authorized_actions": {
47154720
"type": "array",
47164721
"items": {

internal/proto/controller/api/resources/hosts/v1/host.proto

+3
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ message Host {
8888
// Output only. The external ID of the host, if any.
8989
string external_id = 140; // @gotags: `class:"public"`
9090

91+
// Output only. Refers to the name for a given host provided by the plugin enabled backing service.
92+
string external_name = 150; // @gotags: `class:"public"`
93+
9194
// Output only. The available actions on this resource for this user.
9295
repeated string authorized_actions = 300 [json_name = "authorized_actions"]; // @gotags: `class:"public"`
9396
}

sdk/pbs/controller/api/resources/hosts/host.pb.go

+29-18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)