forked from cloudfoundry/bosh-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
snapshots.go
46 lines (38 loc) · 1 KB
/
snapshots.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
package cmd
import (
boshdir "github.com/cloudfoundry/bosh-cli/director"
boshui "github.com/cloudfoundry/bosh-cli/ui"
boshtbl "github.com/cloudfoundry/bosh-cli/ui/table"
)
type SnapshotsCmd struct {
ui boshui.UI
deployment boshdir.Deployment
}
func NewSnapshotsCmd(ui boshui.UI, deployment boshdir.Deployment) SnapshotsCmd {
return SnapshotsCmd{ui: ui, deployment: deployment}
}
func (c SnapshotsCmd) Run(opts SnapshotsOpts) error {
snapshots, err := c.deployment.Snapshots()
if err != nil {
return err
}
table := boshtbl.Table{
Content: "snapshots",
Header: []boshtbl.Header{
boshtbl.NewHeader("Instance"),
boshtbl.NewHeader("CID"),
boshtbl.NewHeader("Created At"),
boshtbl.NewHeader("Clean"),
},
}
for _, s := range snapshots {
table.Rows = append(table.Rows, []boshtbl.Value{
boshtbl.NewValueString(s.InstanceDesc()),
boshtbl.NewValueString(s.CID),
boshtbl.NewValueTime(s.CreatedAt),
boshtbl.NewValueBool(s.Clean),
})
}
c.ui.PrintTable(table)
return nil
}