Skip to content

Commit

Permalink
feat: implet sort interface for nodes (#115)
Browse files Browse the repository at this point in the history
Signed-off-by: Artur Troian <[email protected]>
  • Loading branch information
troian authored Jan 28, 2024
1 parent 194782d commit 611df65
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions go/inventory/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,23 @@ type GPUs []GPU
type Nodes []Node
type ClusterStorage []Storage

var _ sort.Interface = (*Nodes)(nil)
var _ sort.Interface = (*GPUs)(nil)
var _ sort.Interface = (*CPUInfoS)(nil)
var _ sort.Interface = (*ClusterStorage)(nil)

func (s Nodes) Len() int {
return len(s)
}

func (s Nodes) Swap(i, j int) {
s[i], s[j] = s[j], s[i]
}

func (s Nodes) Less(i, j int) bool {
return s[i].Name < s[j].Name
}

func (s CPUInfoS) Len() int {
return len(s)
}
Expand Down

0 comments on commit 611df65

Please sign in to comment.