forked from cloudfoundry/bosh-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
stemcells.go
59 lines (48 loc) · 1.24 KB
/
stemcells.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
56
57
58
59
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 StemcellsCmd struct {
ui boshui.UI
director boshdir.Director
}
func NewStemcellsCmd(ui boshui.UI, director boshdir.Director) StemcellsCmd {
return StemcellsCmd{ui: ui, director: director}
}
func (c StemcellsCmd) Run() error {
stemcells, err := c.director.Stemcells()
if err != nil {
return err
}
table := boshtbl.Table{
Content: "stemcells",
Header: []boshtbl.Header{
boshtbl.NewHeader("Name"),
boshtbl.NewHeader("Version"),
boshtbl.NewHeader("OS"),
boshtbl.NewHeader("CPI"),
boshtbl.NewHeader("CID"),
},
SortBy: []boshtbl.ColumnSort{
{Column: 0, Asc: true},
{Column: 1, Asc: false},
},
Notes: []string{"(*) Currently deployed"},
}
for _, stem := range stemcells {
table.Rows = append(table.Rows, []boshtbl.Value{
boshtbl.NewValueString(stem.Name()),
boshtbl.NewValueSuffix(
boshtbl.NewValueVersion(stem.Version()),
stem.VersionMark("*"),
),
boshtbl.NewValueString(stem.OSName()),
boshtbl.NewValueString(stem.CPI()),
boshtbl.NewValueString(stem.CID()),
})
}
c.ui.PrintTable(table)
return nil
}