Skip to content

Commit 355c4c8

Browse files
author
Gabriel Monroy
committed
Merge pull request #2039 from gabrtv/fix-list-units
fix(deisctl): fix global unit display
2 parents 0f50abc + 5b474ae commit 355c4c8

1 file changed

Lines changed: 5 additions & 9 deletions

File tree

deisctl/backend/fleet/list_units.go

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,7 @@ var (
7676

7777
// ListUnits prints all Deis-related units to Stdout
7878
func (c *FleetClient) ListUnits() (err error) {
79-
var sortable sort.StringSlice
80-
states := make(map[string]*schema.UnitState, 0)
79+
var states []*schema.UnitState
8180

8281
unitStates, err := cAPI.UnitStates()
8382
if err != nil {
@@ -86,12 +85,10 @@ func (c *FleetClient) ListUnits() (err error) {
8685

8786
for _, us := range unitStates {
8887
if strings.HasPrefix(us.Name, "deis-") {
89-
states[us.Name] = us
90-
sortable = append(sortable, us.Name)
88+
states = append(states, us)
9189
}
9290
}
93-
sortable.Sort()
94-
printUnits(states, sortable)
91+
printUnits(states)
9592
return
9693
}
9794

@@ -110,17 +107,16 @@ func (c *FleetClient) GetLocaljobs() sort.StringSlice {
110107
}
111108

112109
// printUnits writes units to stdout using a tabwriter
113-
func printUnits(states map[string]*schema.UnitState, sortable sort.StringSlice) {
110+
func printUnits(states []*schema.UnitState) {
114111
cols := strings.Split(defaultListUnitsFields, ",")
115112
for _, s := range cols {
116113
if _, ok := listUnitsFields[s]; !ok {
117114
fmt.Fprintf(os.Stderr, "Invalid key in output format: %q\n", s)
118115
}
119116
}
120117
fmt.Fprintln(out, strings.ToUpper(strings.Join(cols, "\t")))
121-
for _, name := range sortable {
118+
for _, us := range states {
122119
var f []string
123-
us := states[name]
124120
for _, c := range cols {
125121
f = append(f, listUnitsFields[c](us, false))
126122
}

0 commit comments

Comments
 (0)