-
Notifications
You must be signed in to change notification settings - Fork 35
/
cluster.go
53 lines (42 loc) · 1.04 KB
/
cluster.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
43
44
45
46
47
48
49
50
51
52
53
package client
import (
"context"
clusterapi "github.com/ehazlett/stellar/api/services/cluster/v1"
)
type cluster struct {
client clusterapi.ClusterClient
}
func (c *cluster) ID() (string, error) {
ctx := context.Background()
resp, err := c.client.Info(ctx, &clusterapi.InfoRequest{})
if err != nil {
return "", err
}
return resp.ID, nil
}
func (c *cluster) Nodes() ([]*clusterapi.Node, error) {
ctx := context.Background()
resp, err := c.client.Nodes(ctx, &clusterapi.NodesRequest{})
if err != nil {
return nil, err
}
return resp.Nodes, nil
}
func (c *cluster) Containers(filters ...string) ([]*clusterapi.Container, error) {
ctx := context.Background()
resp, err := c.client.Containers(ctx, &clusterapi.ContainersRequest{
Filters: filters,
})
if err != nil {
return nil, err
}
return resp.Containers, nil
}
func (c *cluster) Health() ([]*clusterapi.NodeHealth, error) {
ctx := context.Background()
resp, err := c.client.Health(ctx, &clusterapi.HealthRequest{})
if err != nil {
return nil, err
}
return resp.Nodes, nil
}