Skip to content

Commit

Permalink
fix: match go experimental func interface for Slices Sort functions
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianriobo committed Sep 19, 2023
1 parent 5bf85c1 commit d4b9eaa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions pkg/provider/aws/modules/spot-price/placement-score.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ func GetBestPlacementScores(regions, instanceTypes []string,
return nil, fmt.Errorf("non available scores")
}
slices.SortFunc(sps.SpotPlacementScores,
func(a, b *awsEC2.SpotPlacementScore) bool {
return *a.Score > *b.Score
func(a, b *awsEC2.SpotPlacementScore) int {
return int(*a.Score - *b.Score)
})
return sps.SpotPlacementScores, nil
}
6 changes: 3 additions & 3 deletions pkg/provider/aws/modules/spot-price/spot-price.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ func getDescribeAvailabilityZones(regions []string) []*ec2.AvailabilityZone {

func checkBestOption(source []SpotPriceGroup, sps []*ec2.SpotPlacementScore, availabilityZones []*ec2.AvailabilityZone) *SpotPriceGroup {
slices.SortFunc(source,
func(a, b SpotPriceGroup) bool {
return a.AVGPrice < b.AVGPrice
func(a, b SpotPriceGroup) int {
return int(a.AVGPrice - b.AVGPrice)
})
var score int64 = spsMaxScore
for score > 3 {
Expand Down Expand Up @@ -137,7 +137,7 @@ func getBestSpotPrice(instanceTypes []string, productDescription, region string)
return price
})
groupInfo.AVGPrice = util.Average(prices)
slices.SortFunc(prices, func(a, b float64) bool { return a < b })
slices.SortFunc(prices, func(a, b float64) int { return int(a - b) })
groupInfo.MaxPrice = prices[len(prices)-1]
pricesGroup = append(pricesGroup, groupInfo)
}
Expand Down

0 comments on commit d4b9eaa

Please sign in to comment.