-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathfleet.go
More file actions
33 lines (29 loc) · 788 Bytes
/
fleet.go
File metadata and controls
33 lines (29 loc) · 788 Bytes
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 fleet
import "github.com/coreos/fleet/client"
// FleetClient used to wrap Fleet API calls
type FleetClient struct {
Fleet client.API
}
// NewClient returns a client used to communicate with Fleet
// using the Registry API
func NewClient() (*FleetClient, error) {
client, err := getRegistryClient()
if err != nil {
return nil, err
}
// set global client
cAPI = client
return &FleetClient{Fleet: client}, nil
}
// randomMachineID return a random machineID from the Fleet cluster
func randomMachineID(c *FleetClient) (machineID string, err error) {
machineState, err := c.Fleet.Machines()
if err != nil {
return "", err
}
var machineIDs []string
for _, ms := range machineState {
machineIDs = append(machineIDs, ms.ID)
}
return randomValue(machineIDs), nil
}