-
Notifications
You must be signed in to change notification settings - Fork 162
/
disks.go
50 lines (40 loc) · 1.11 KB
/
disks.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
package cmd
import (
"errors"
boshdir "github.com/cloudfoundry/bosh-cli/director"
boshui "github.com/cloudfoundry/bosh-cli/ui"
boshtbl "github.com/cloudfoundry/bosh-cli/ui/table"
)
type DisksCmd struct {
ui boshui.UI
director boshdir.Director
}
func NewDisksCmd(ui boshui.UI, director boshdir.Director) DisksCmd {
return DisksCmd{ui: ui, director: director}
}
func (c DisksCmd) Run(opts DisksOpts) error {
if !opts.Orphaned {
return errors.New("Only --orphaned is supported")
}
disks, err := c.director.OrphanedDisks()
if err != nil {
return err
}
table := boshtbl.Table{
Content: "disks",
Header: []string{"Disk CID", "Size", "Deployment", "Instance", "AZ", "Orphaned At"},
SortBy: []boshtbl.ColumnSort{{Column: 5}},
}
for _, d := range disks {
table.Rows = append(table.Rows, []boshtbl.Value{
boshtbl.NewValueString(d.CID()),
boshtbl.NewValueMegaBytes(d.Size()),
boshtbl.NewValueString(d.Deployment().Name()),
boshtbl.NewValueString(d.InstanceName()),
boshtbl.NewValueString(d.AZName()),
boshtbl.NewValueTime(d.OrphanedAt()),
})
}
c.ui.PrintTable(table)
return nil
}