Skip to content
This repository was archived by the owner on Sep 29, 2020. It is now read-only.

Commit 6e3e08e

Browse files
authored
Merge pull request #318 from joyent/perigrin/add-hardware-sku
Add SKU to the Hardware Product output
2 parents dc90fb9 + a51f9dc commit 6e3e08e

File tree

2 files changed

+9
-15
lines changed

2 files changed

+9
-15
lines changed

pkg/commands/api/main.go

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ import (
1010
"bytes"
1111
"errors"
1212
"fmt"
13-
"github.com/jawher/mow.cli"
14-
"github.com/joyent/conch-shell/pkg/util"
1513
"io/ioutil"
1614
"os"
15+
16+
cli "github.com/jawher/mow.cli"
17+
"github.com/joyent/conch-shell/pkg/util"
1718
)
1819

1920
func get(cmd *cli.Cmd) {
@@ -26,9 +27,6 @@ func get(cmd *cli.Cmd) {
2627
if err != nil {
2728
util.Bail(err)
2829
}
29-
if res == nil {
30-
util.Bail(errors.New("empty response"))
31-
}
3230

3331
body, err := ioutil.ReadAll(res.Body)
3432
if err != nil {
@@ -59,9 +57,6 @@ func deleteAPI(cmd *cli.Cmd) {
5957
if err != nil {
6058
util.Bail(err)
6159
}
62-
if res == nil {
63-
util.Bail(errors.New("empty response"))
64-
}
6560

6661
body, err := ioutil.ReadAll(res.Body)
6762
if err != nil {
@@ -106,9 +101,6 @@ func postAPI(cmd *cli.Cmd) {
106101
if err != nil {
107102
util.Bail(err)
108103
}
109-
if res == nil {
110-
util.Bail(errors.New("empty response"))
111-
}
112104

113105
body, err := ioutil.ReadAll(res.Body)
114106
if err != nil {

pkg/commands/hardware/hardware.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ import (
1515
"reflect"
1616
"text/template"
1717

18-
"github.com/jawher/mow.cli"
18+
cli "github.com/jawher/mow.cli"
1919
"github.com/joyent/conch-shell/pkg/conch"
2020
"github.com/joyent/conch-shell/pkg/conch/uuid"
2121
"github.com/joyent/conch-shell/pkg/util"
2222
)
2323

2424
const singleHWPTemplate = `
25-
ID: {{ .ID }}
25+
ID: {{ .ID }}
2626
Name: {{ .Name }}
2727
Alias: {{ .Alias }}
2828
Legacy Product Name: {{ .LegacyProductName }}
@@ -241,6 +241,7 @@ func getAll(app *cli.Cmd) {
241241
}
242242
type retRow struct {
243243
ID string `json:"id"`
244+
SKU string `json:"sku"`
244245
Name string `json:"name"`
245246
Alias string `json:"alias"`
246247
Prefix string `json:"prefix"`
@@ -261,6 +262,7 @@ func getAll(app *cli.Cmd) {
261262

262263
rows = append(rows, retRow{
263264
r.ID.String(),
265+
r.SKU,
264266
r.Name,
265267
r.Alias,
266268
r.Prefix,
@@ -275,10 +277,10 @@ func getAll(app *cli.Cmd) {
275277
}
276278

277279
table := util.GetMarkdownTable()
278-
table.SetHeader([]string{"ID", "Name", "Alias", "Prefix", "Vendor", "Purpose"})
280+
table.SetHeader([]string{"ID", "SKU", "Name", "Alias", "Prefix", "Vendor", "Purpose"})
279281

280282
for _, r := range rows {
281-
table.Append([]string{r.ID, r.Name, r.Alias, r.Prefix, r.Vendor, r.Purpose})
283+
table.Append([]string{r.ID, r.SKU, r.Name, r.Alias, r.Prefix, r.Vendor, r.Purpose})
282284
}
283285

284286
table.Render()

0 commit comments

Comments
 (0)