-
Notifications
You must be signed in to change notification settings - Fork 11
/
clusters.go
33 lines (27 loc) · 934 Bytes
/
clusters.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
package kubernetes
import (
"context"
"github.com/cloudquery/plugin-sdk/v4/schema"
"github.com/yandex-cloud/cq-source-yc/client"
"github.com/yandex-cloud/go-genproto/yandex/cloud/k8s/v1"
)
func Clusters() *schema.Table {
return &schema.Table{
Name: "yc_kubernetes_clusters",
Description: `https://cloud.yandex.ru/docs/managed-kubernetes/api-ref/grpc/cluster_service#Cluster1`,
Multiplex: client.FolderMultiplex,
Resolver: fetchClusters,
Transform: client.TransformWithStruct(&k8s.Cluster{}, client.PrimaryKeyIdTransformer),
Columns: schema.ColumnList{
client.CloudIdColumn,
},
}
}
func fetchClusters(ctx context.Context, meta schema.ClientMeta, _ *schema.Resource, res chan<- interface{}) error {
c := meta.(*client.Client)
it := c.SDK.Kubernetes().Cluster().ClusterIterator(ctx, &k8s.ListClustersRequest{FolderId: c.FolderId})
for it.Next() {
res <- it.Value()
}
return it.Error()
}