/
table_scalingo_key.go
42 lines (37 loc) · 1.14 KB
/
table_scalingo_key.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package scalingo
import (
"context"
"github.com/turbot/steampipe-plugin-sdk/v5/grpc/proto"
"github.com/turbot/steampipe-plugin-sdk/v5/plugin"
)
func tableScalingoKey() *plugin.Table {
return &plugin.Table{
Name: "scalingo_key",
Description: "An SSH key associated to the account.",
List: &plugin.ListConfig{
Hydrate: listKey,
},
GetMatrixItemFunc: BuildRegionList,
Columns: []*plugin.Column{
{Name: "id", Type: proto.ColumnType_STRING, Description: "Unique ID of the key."},
{Name: "name", Type: proto.ColumnType_STRING, Description: "Given name to the key."},
{Name: "content", Type: proto.ColumnType_STRING, Description: "Raw content of the SSH public key."},
},
}
}
func listKey(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateData) (interface{}, error) {
client, err := connect(ctx, d)
if err != nil {
plugin.Logger(ctx).Error("scalingo_key.listKey", "connection_error", err)
return nil, err
}
keys, err := client.KeysList(ctx)
if err != nil {
plugin.Logger(ctx).Error("scalingo_key.listKey", err)
return nil, err
}
for _, key := range keys {
d.StreamListItem(ctx, key)
}
return nil, nil
}