Skip to content

Commit

Permalink
model: update Firmware struct to include ID, rename ComponentSlug field
Browse files Browse the repository at this point in the history
  • Loading branch information
joelrebel committed May 4, 2023
1 parent c4acaf7 commit 4b32e88
Showing 1 changed file with 10 additions and 20 deletions.
30 changes: 10 additions & 20 deletions internal/model/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,27 +65,17 @@ type Asset struct {
}

// Firmware includes a firmware version attributes and is part of FirmwareConfig
//
// nolint:govet // fieldalignment struct is easier to read in the current format
type Firmware struct {
Version string `yaml:"version"`
URL string `yaml:"URL"`
FileName string `yaml:"filename"`
Utility string `yaml:"utility"`
Model string `yaml:"model"`
Vendor string `yaml:"vendor"`
ComponentSlug string `yaml:"componentslug"`
Checksum string `yaml:"checksum"`
}

// Firmwares is a list of firmwares with a SortByInstallOrder method.
type Firmwares []Firmware

// SortByInstallOrder sorts the firmwares planned in the order they should be installed
func (p Firmwares) SortByInstallOrder() {
sort.Slice(p, func(i, j int) bool {
slugi := strings.ToLower(p[i].ComponentSlug)
slugj := strings.ToLower(p[j].ComponentSlug)
return FirmwareInstallOrder[slugi] < FirmwareInstallOrder[slugj]
})
ID string `yaml:"id"`
Vendor string `yaml:"vendor"`
Models []string `yaml:"models"`
FileName string `yaml:"filename"`
Version string `yaml:"version"`
URL string `yaml:"URL"`
Component string `yaml:"component"`
Checksum string `yaml:"checksum"`
}

var (
Expand Down

0 comments on commit 4b32e88

Please sign in to comment.