Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions redfish/softwareinventory.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ type SoftwareInventory struct {
OEM json.RawMessage
// RelatedItem shall contain an array of IDs for pointers consistent with JSON Pointer syntax to the Resource that
// is associated with this software inventory item.
relatedItem []string
RelatedItem common.Links
// RelatedItemCount is the number of related items.
RelatedItemCount int `json:"RelatedItem@odata.count"`
// ReleaseDate is the date of release or
Expand Down Expand Up @@ -121,16 +121,15 @@ type SoftwareInventory struct {
// image can be overwritten, where a value `true` shall indicate that the
// software cannot be altered or overwritten.
WriteProtected bool
// rawData holds the original serialized JSON so we can compare updates.
rawData []byte
// RawData holds the original serialized JSON so we can compare updates.
RawData []byte
}

// UnmarshalJSON unmarshals a SoftwareInventory object from the raw JSON.
func (softwareinventory *SoftwareInventory) UnmarshalJSON(b []byte) error {
type temp SoftwareInventory
var t struct {
temp
RelatedItem common.Links
}

err := json.Unmarshal(b, &t)
Expand All @@ -140,11 +139,8 @@ func (softwareinventory *SoftwareInventory) UnmarshalJSON(b []byte) error {

*softwareinventory = SoftwareInventory(t.temp)

// Extract the links to other entities for later
softwareinventory.relatedItem = t.RelatedItem.ToStrings()

// This is a read/write object, so we need to save the raw object data for later
softwareinventory.rawData = b
softwareinventory.RawData = b

return nil
}
Expand All @@ -153,7 +149,7 @@ func (softwareinventory *SoftwareInventory) UnmarshalJSON(b []byte) error {
func (softwareinventory *SoftwareInventory) Update() error {
readWriteFields := []string{"WriteProtected"}

return softwareinventory.UpdateFromRawData(softwareinventory, softwareinventory.rawData, readWriteFields)
return softwareinventory.UpdateFromRawData(softwareinventory, softwareinventory.RawData, readWriteFields)
}

// GetSoftwareInventory will get a SoftwareInventory instance from the service.
Expand Down
4 changes: 2 additions & 2 deletions redfish/softwareinventory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ func TestSoftwareInventory(t *testing.T) {
t.Errorf("Manufacturer is wrong")
}

if len(result.relatedItem) != 1 || result.relatedItem[0] != "/redfish/v1/Managers/1" {
t.Errorf("Unexpected related items: %#v", result.relatedItem)
if len(result.RelatedItem) != 1 || result.RelatedItem[0] != "/redfish/v1/Managers/1" {
t.Errorf("Unexpected related items: %#v", result.RelatedItem)
}

if result.ReleaseDate != "1/1/2020" {
Expand Down