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

Commit

Permalink
Merge pull request #318 from joyent/perigrin/add-hardware-sku
Browse files Browse the repository at this point in the history
Add SKU to the Hardware Product output
  • Loading branch information
perigrin authored Nov 5, 2019
2 parents dc90fb9 + a51f9dc commit 6e3e08e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
14 changes: 3 additions & 11 deletions pkg/commands/api/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ import (
"bytes"
"errors"
"fmt"
"github.com/jawher/mow.cli"
"github.com/joyent/conch-shell/pkg/util"
"io/ioutil"
"os"

cli "github.com/jawher/mow.cli"
"github.com/joyent/conch-shell/pkg/util"
)

func get(cmd *cli.Cmd) {
Expand All @@ -26,9 +27,6 @@ func get(cmd *cli.Cmd) {
if err != nil {
util.Bail(err)
}
if res == nil {
util.Bail(errors.New("empty response"))
}

body, err := ioutil.ReadAll(res.Body)
if err != nil {
Expand Down Expand Up @@ -59,9 +57,6 @@ func deleteAPI(cmd *cli.Cmd) {
if err != nil {
util.Bail(err)
}
if res == nil {
util.Bail(errors.New("empty response"))
}

body, err := ioutil.ReadAll(res.Body)
if err != nil {
Expand Down Expand Up @@ -106,9 +101,6 @@ func postAPI(cmd *cli.Cmd) {
if err != nil {
util.Bail(err)
}
if res == nil {
util.Bail(errors.New("empty response"))
}

body, err := ioutil.ReadAll(res.Body)
if err != nil {
Expand Down
10 changes: 6 additions & 4 deletions pkg/commands/hardware/hardware.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ import (
"reflect"
"text/template"

"github.com/jawher/mow.cli"
cli "github.com/jawher/mow.cli"
"github.com/joyent/conch-shell/pkg/conch"
"github.com/joyent/conch-shell/pkg/conch/uuid"
"github.com/joyent/conch-shell/pkg/util"
)

const singleHWPTemplate = `
ID: {{ .ID }}
ID: {{ .ID }}
Name: {{ .Name }}
Alias: {{ .Alias }}
Legacy Product Name: {{ .LegacyProductName }}
Expand Down Expand Up @@ -241,6 +241,7 @@ func getAll(app *cli.Cmd) {
}
type retRow struct {
ID string `json:"id"`
SKU string `json:"sku"`
Name string `json:"name"`
Alias string `json:"alias"`
Prefix string `json:"prefix"`
Expand All @@ -261,6 +262,7 @@ func getAll(app *cli.Cmd) {

rows = append(rows, retRow{
r.ID.String(),
r.SKU,
r.Name,
r.Alias,
r.Prefix,
Expand All @@ -275,10 +277,10 @@ func getAll(app *cli.Cmd) {
}

table := util.GetMarkdownTable()
table.SetHeader([]string{"ID", "Name", "Alias", "Prefix", "Vendor", "Purpose"})
table.SetHeader([]string{"ID", "SKU", "Name", "Alias", "Prefix", "Vendor", "Purpose"})

for _, r := range rows {
table.Append([]string{r.ID, r.Name, r.Alias, r.Prefix, r.Vendor, r.Purpose})
table.Append([]string{r.ID, r.SKU, r.Name, r.Alias, r.Prefix, r.Vendor, r.Purpose})
}

table.Render()
Expand Down

0 comments on commit 6e3e08e

Please sign in to comment.