-
Notifications
You must be signed in to change notification settings - Fork 162
/
vars.go
44 lines (34 loc) · 866 Bytes
/
vars.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
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 VarsCmd struct {
ui boshui.UI
deployment boshdir.Deployment
}
func NewVarsCmd(ui boshui.UI, deployment boshdir.Deployment) VarsCmd {
return VarsCmd{ui: ui, deployment: deployment}
}
func (c VarsCmd) Run() error {
vars, err := c.deployment.ConfigVars()
if err != nil {
return err
}
table := boshtbl.Table{
Header: []string{"ID", "Name"},
SortBy: []boshtbl.ColumnSort{
{Column: 0, Asc: true},
{Column: 1},
},
}
for _, configVar := range vars {
table.Rows = append(table.Rows, []boshtbl.Value{
boshtbl.NewValueString(configVar.PlaceholderID),
boshtbl.NewValueString(configVar.PlaceholderName),
})
}
c.ui.PrintTable(table)
return nil
}