-
Notifications
You must be signed in to change notification settings - Fork 221
/
machines.go
55 lines (42 loc) · 989 Bytes
/
machines.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
54
55
package status
import (
"context"
"github.com/superfly/flyctl/api"
"github.com/superfly/flyctl/flaps"
"github.com/superfly/flyctl/internal/render"
"github.com/superfly/flyctl/iostreams"
)
func renderMachineStatus(ctx context.Context, app *api.AppCompact) (err error) {
io := iostreams.FromContext(ctx)
flapsClient, err := flaps.New(ctx, app)
if err != nil {
return err
}
machines, err := flapsClient.List(ctx, "")
if err != nil {
return err
}
obj := [][]string{
{
app.Name,
app.Organization.Slug,
app.Hostname,
},
}
if err = render.VerticalTable(io.Out, "App", obj, "Name", "Owner", "Hostname"); err != nil {
return
}
rows := [][]string{}
for _, machine := range machines {
rows = append(rows, []string{
machine.ID,
machine.State,
machine.Region,
machine.FullImageRef(),
machine.CreatedAt,
machine.UpdatedAt,
})
}
_ = render.Table(io.Out, "", rows, "ID", "State", "Region", "Image", "Created", "Updated")
return
}