feat(api): Support plugin host external_name field
This commit is contained in:
1 parent
2ff9b8efac
commit
45dc8251ec
7 files changed
+51
-21
No files matched your search
@@ -29,6 +29,7 @@ type Host struct {
|
||||
IpAddresses []string `json:"ip_addresses,omitempty"`
|
||||
DnsNames []string `json:"dns_names,omitempty"`
|
||||
ExternalId string `json:"external_id,omitempty"`
|
||||
ExternalName string `json:"external_name,omitempty"`
|
||||
AuthorizedActions []string `json:"authorized_actions,omitempty"`
|
||||
|
||||
response *api.Response
|
||||
|
||||
@@ -72,6 +72,7 @@ const (
|
||||
DnsNamesField = "dns_names"
|
||||
SecretsHmacField = "secrets_hmac"
|
||||
ExternalIdField = "external_id"
|
||||
ExternalNameField = "external_name"
|
||||
InjectedApplicationCredentialSourceIdsField = "injected_application_credential_source_ids"
|
||||
InjectedApplicationCredentialSourcesField = "injected_application_credential_sources"
|
||||
ConnectionsField = "connections"
|
||||
|
||||
@@ -598,6 +598,9 @@ func toProto(ctx context.Context, in host.Host, opt ...handlers.Option) (*pb.Hos
|
||||
if outputFields.Has(globals.ExternalIdField) {
|
||||
out.ExternalId = h.ExternalId
|
||||
}
|
||||
if outputFields.Has(globals.ExternalNameField) {
|
||||
out.ExternalName = h.ExternalName
|
||||
}
|
||||
}
|
||||
return &out, nil
|
||||
}
|
||||
|
||||
@@ -165,8 +165,11 @@ func TestGet_Plugin(t *testing.T) {
|
||||
return static.NewRepository(rw, rw, kms)
|
||||
}
|
||||
hc := plugin.TestCatalog(t, conn, proj.GetPublicId(), plg.GetPublicId())
|
||||
h := plugin.TestHost(t, conn, hc.GetPublicId(), "test")
|
||||
hPrev := plugin.TestHost(t, conn, hc.GetPublicId(), "test-prev", plugin.WithPublicId(fmt.Sprintf("%s_1234567890", globals.PluginHostPreviousPrefix)))
|
||||
h := plugin.TestHost(t, conn, hc.GetPublicId(), "test", plugin.WithExternalName("test-ext-name"))
|
||||
hPrev := plugin.TestHost(t, conn, hc.GetPublicId(), "test-prev",
|
||||
plugin.WithPublicId(fmt.Sprintf("%s_1234567890", globals.PluginHostPreviousPrefix)),
|
||||
plugin.WithExternalName("test-prev-name"),
|
||||
)
|
||||
hs := plugin.TestSet(t, conn, kms, sche, hc, plgm)
|
||||
plugin.TestSetMembers(t, conn, hs.GetPublicId(), []*plugin.Host{h, hPrev})
|
||||
|
||||
@@ -184,6 +187,7 @@ func TestGet_Plugin(t *testing.T) {
|
||||
},
|
||||
HostSetIds: []string{hs.GetPublicId()},
|
||||
ExternalId: "test",
|
||||
ExternalName: "test-ext-name",
|
||||
AuthorizedActions: testAuthorizedActions[plugin.Subtype],
|
||||
}
|
||||
|
||||
@@ -207,6 +211,7 @@ func TestGet_Plugin(t *testing.T) {
|
||||
resp.CreatedTime = hPrev.CreateTime.GetTimestamp()
|
||||
resp.UpdatedTime = hPrev.UpdateTime.GetTimestamp()
|
||||
resp.ExternalId = "test-prev"
|
||||
resp.ExternalName = "test-prev-name"
|
||||
return &pbs.GetHostResponse{Item: resp}
|
||||
}(),
|
||||
},
|
||||
@@ -397,7 +402,7 @@ func TestList_Plugin(t *testing.T) {
|
||||
var wantHs []*pb.Host
|
||||
for i := 0; i < 10; i++ {
|
||||
extId := fmt.Sprintf("host %d", i)
|
||||
h := plugin.TestHost(t, conn, hc.GetPublicId(), extId)
|
||||
h := plugin.TestHost(t, conn, hc.GetPublicId(), extId, plugin.WithExternalName(fmt.Sprintf("ext-name-%d", i)))
|
||||
plugin.TestSetMembers(t, conn, hs.GetPublicId(), []*plugin.Host{h})
|
||||
wantHs = append(wantHs, &pb.Host{
|
||||
Id: h.GetPublicId(),
|
||||
@@ -413,6 +418,7 @@ func TestList_Plugin(t *testing.T) {
|
||||
HostSetIds: []string{hs.GetPublicId()},
|
||||
Version: 1,
|
||||
ExternalId: extId,
|
||||
ExternalName: fmt.Sprintf("ext-name-%d", i),
|
||||
Type: plugin.Subtype.String(),
|
||||
AuthorizedActions: testAuthorizedActions[plugin.Subtype],
|
||||
})
|
||||
|
||||
@@ -4711,6 +4711,11 @@
|
||||
"description": "Output only. The external ID of the host, if any.",
|
||||
"readOnly": true
|
||||
},
|
||||
"external_name": {
|
||||
"type": "string",
|
||||
"description": "Output only. Refers to the name for a given host provided by the plugin enabled backing service.",
|
||||
"readOnly": true
|
||||
},
|
||||
"authorized_actions": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
|
||||
@@ -88,6 +88,9 @@ message Host {
|
||||
// Output only. The external ID of the host, if any.
|
||||
string external_id = 140; // @gotags: `class:"public"`
|
||||
|
||||
// Output only. Refers to the name for a given host provided by the plugin enabled backing service.
|
||||
string external_name = 150; // @gotags: `class:"public"`
|
||||
|
||||
// Output only. The available actions on this resource for this user.
|
||||
repeated string authorized_actions = 300 [json_name = "authorized_actions"]; // @gotags: `class:"public"`
|
||||
}
|
||||
|
||||
@@ -70,6 +70,8 @@ type Host struct {
|
||||
DnsNames []string `protobuf:"bytes,130,rep,name=dns_names,json=dnsNames,proto3" json:"dns_names,omitempty" class:"public"` // @gotags: `class:"public"`
|
||||
// Output only. The external ID of the host, if any.
|
||||
ExternalId string `protobuf:"bytes,140,opt,name=external_id,json=externalId,proto3" json:"external_id,omitempty" class:"public"` // @gotags: `class:"public"`
|
||||
// Output only. Refers to the name for a given host provided by the plugin enabled backing service.
|
||||
ExternalName string `protobuf:"bytes,150,opt,name=external_name,json=externalName,proto3" json:"external_name,omitempty" class:"public"` // @gotags: `class:"public"`
|
||||
// Output only. The available actions on this resource for this user.
|
||||
AuthorizedActions []string `protobuf:"bytes,300,rep,name=authorized_actions,proto3" json:"authorized_actions,omitempty" class:"public"` // @gotags: `class:"public"`
|
||||
}
|
||||
@@ -225,6 +227,13 @@ func (x *Host) GetExternalId() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Host) GetExternalName() string {
|
||||
if x != nil {
|
||||
return x.ExternalName
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Host) GetAuthorizedActions() []string {
|
||||
if x != nil {
|
||||
return x.AuthorizedActions
|
||||
@@ -321,7 +330,7 @@ var file_controller_api_resources_hosts_v1_host_proto_rawDesc = []byte{
|
||||
0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65,
|
||||
0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x67, 0x6f, 0x6f,
|
||||
0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x77, 0x72, 0x61,
|
||||
0x70, 0x70, 0x65, 0x72, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xcd, 0x07, 0x0a, 0x04,
|
||||
0x70, 0x70, 0x65, 0x72, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xf3, 0x07, 0x0a, 0x04,
|
||||
0x48, 0x6f, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09,
|
||||
0x52, 0x02, 0x69, 0x64, 0x12, 0x2e, 0x0a, 0x0f, 0x68, 0x6f, 0x73, 0x74, 0x5f, 0x63, 0x61, 0x74,
|
||||
0x61, 0x6c, 0x6f, 0x67, 0x5f, 0x69, 0x64, 0x18, 0x14, 0x20, 0x01, 0x28, 0x09, 0x42, 0x04, 0xa0,
|
||||
@@ -379,23 +388,25 @@ var file_controller_api_resources_hosts_v1_host_proto_rawDesc = []byte{
|
||||
0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x64, 0x6e, 0x73, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x12,
|
||||
0x20, 0x0a, 0x0b, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x5f, 0x69, 0x64, 0x18, 0x8c,
|
||||
0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x49,
|
||||
0x64, 0x12, 0x2f, 0x0a, 0x12, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x65, 0x64, 0x5f,
|
||||
0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xac, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x12,
|
||||
0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x65, 0x64, 0x5f, 0x61, 0x63, 0x74, 0x69, 0x6f,
|
||||
0x6e, 0x73, 0x42, 0x07, 0x0a, 0x05, 0x61, 0x74, 0x74, 0x72, 0x73, 0x22, 0x75, 0x0a, 0x14, 0x53,
|
||||
0x74, 0x61, 0x74, 0x69, 0x63, 0x48, 0x6f, 0x73, 0x74, 0x41, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75,
|
||||
0x74, 0x65, 0x73, 0x12, 0x5d, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x0a,
|
||||
0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72,
|
||||
0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c,
|
||||
0x75, 0x65, 0x42, 0x25, 0xa0, 0xda, 0x29, 0x01, 0xc2, 0xdd, 0x29, 0x1d, 0x0a, 0x12, 0x61, 0x74,
|
||||
0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x2e, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73,
|
||||
0x12, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65,
|
||||
0x73, 0x73, 0x42, 0x4c, 0x5a, 0x4a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d,
|
||||
0x2f, 0x68, 0x61, 0x73, 0x68, 0x69, 0x63, 0x6f, 0x72, 0x70, 0x2f, 0x62, 0x6f, 0x75, 0x6e, 0x64,
|
||||
0x61, 0x72, 0x79, 0x2f, 0x73, 0x64, 0x6b, 0x2f, 0x70, 0x62, 0x73, 0x2f, 0x63, 0x6f, 0x6e, 0x74,
|
||||
0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x75,
|
||||
0x72, 0x63, 0x65, 0x73, 0x2f, 0x68, 0x6f, 0x73, 0x74, 0x73, 0x3b, 0x68, 0x6f, 0x73, 0x74, 0x73,
|
||||
0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x64, 0x12, 0x24, 0x0a, 0x0d, 0x65, 0x78, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x5f, 0x6e, 0x61,
|
||||
0x6d, 0x65, 0x18, 0x96, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x65, 0x78, 0x74, 0x65, 0x72,
|
||||
0x6e, 0x61, 0x6c, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x2f, 0x0a, 0x12, 0x61, 0x75, 0x74, 0x68, 0x6f,
|
||||
0x72, 0x69, 0x7a, 0x65, 0x64, 0x5f, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xac, 0x02,
|
||||
0x20, 0x03, 0x28, 0x09, 0x52, 0x12, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x65, 0x64,
|
||||
0x5f, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x42, 0x07, 0x0a, 0x05, 0x61, 0x74, 0x74, 0x72,
|
||||
0x73, 0x22, 0x75, 0x0a, 0x14, 0x53, 0x74, 0x61, 0x74, 0x69, 0x63, 0x48, 0x6f, 0x73, 0x74, 0x41,
|
||||
0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x12, 0x5d, 0x0a, 0x07, 0x61, 0x64, 0x64,
|
||||
0x72, 0x65, 0x73, 0x73, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f,
|
||||
0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72,
|
||||
0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x42, 0x25, 0xa0, 0xda, 0x29, 0x01, 0xc2, 0xdd,
|
||||
0x29, 0x1d, 0x0a, 0x12, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x2e, 0x61,
|
||||
0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x52,
|
||||
0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x42, 0x4c, 0x5a, 0x4a, 0x67, 0x69, 0x74, 0x68,
|
||||
0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x68, 0x61, 0x73, 0x68, 0x69, 0x63, 0x6f, 0x72, 0x70,
|
||||
0x2f, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x61, 0x72, 0x79, 0x2f, 0x73, 0x64, 0x6b, 0x2f, 0x70, 0x62,
|
||||
0x73, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2f, 0x61, 0x70, 0x69,
|
||||
0x2f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2f, 0x68, 0x6f, 0x73, 0x74, 0x73,
|
||||
0x3b, 0x68, 0x6f, 0x73, 0x74, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
|
||||
Reference in new issue
Block a user