Skip to content

Commit

Permalink
device-show: Add hardware info
Browse files Browse the repository at this point in the history
The API now includes this information for devices included in
Factories based on LMP v53

Signed-off-by: Andy Doan <andy@foundries.io>
  • Loading branch information
doanac committed Oct 17, 2019
1 parent a668d83 commit c040f2c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 14 deletions.
29 changes: 15 additions & 14 deletions client/foundries.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,21 @@ type UpdateEvent struct {
}

type Device struct {
Uuid string `json:"uuid"`
Name string `json:"name"`
Owner string `json:"owner"`
Factory string `json:"factory"`
CreatedAt string `json:"created-at"`
LastSeen string `json:"last-seen"`
OstreeHash string `json:"ostree-hash"`
DockerApps []string `json:"docker-apps,omitempty"`
Tags []string `json:"device-tags,omitempty"`
Network *NetInfo `json:"network-info,omitempty"`
TargetName string `json:"target-name"`
Status string `json:"status"`
CurrentUpdate string `json:"current-update"`
Updates []Update `json:"updates"`
Uuid string `json:"uuid"`
Name string `json:"name"`
Owner string `json:"owner"`
Factory string `json:"factory"`
CreatedAt string `json:"created-at"`
LastSeen string `json:"last-seen"`
OstreeHash string `json:"ostree-hash"`
DockerApps []string `json:"docker-apps,omitempty"`
Tags []string `json:"device-tags,omitempty"`
Network *NetInfo `json:"network-info,omitempty"`
Hardware *json.RawMessage `json:"hardware-info,omitempty"`
TargetName string `json:"target-name"`
Status string `json:"status"`
CurrentUpdate string `json:"current-update"`
Updates []Update `json:"updates"`
}

type DeviceList struct {
Expand Down
10 changes: 10 additions & 0 deletions cmd/device_show.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cmd

import (
"encoding/json"
"fmt"
"os"
"strings"
Expand Down Expand Up @@ -47,6 +48,15 @@ func doDeviceShow(cmd *cobra.Command, args []string) {
if len(device.CurrentUpdate) > 0 {
fmt.Printf("\tUpdate Id:\t%s\n", device.CurrentUpdate)
}
if device.Hardware != nil {
b, err := json.MarshalIndent(device.Hardware, "\t\t", " ")
if err != nil {
fmt.Println("Unable to marshall hardware info: ", err)
}
fmt.Printf("\tHardware Info:\n\t\t")
os.Stdout.Write(b)
fmt.Println("")
}
if len(device.Updates) > 0 {
fmt.Printf("\tUpdate History:\n")
for idx, update := range device.Updates {
Expand Down

0 comments on commit c040f2c

Please sign in to comment.