(record resources.DecodedResource, response map[string][]api.PricingItem)
| 512 | } |
| 513 | |
| 514 | func findMatchingPrice(record resources.DecodedResource, response map[string][]api.PricingItem) (api.PricingItem, bool) { |
| 515 | // Pass 1: exact matching on all attributes including usagetype. |
| 516 | for _, items := range response { |
| 517 | for _, item := range items { |
| 518 | if pricingItemMatchesRecord(item, record, false) { |
| 519 | return item, true |
| 520 | } |
| 521 | } |
| 522 | } |
| 523 | // Pass 2: allow usagetype suffix matching for region-prefixed values |
| 524 | // (e.g. "USW2-LoadBalancerUsage" matching expected "LoadBalancerUsage"). |
| 525 | for _, items := range response { |
| 526 | for _, item := range items { |
| 527 | if pricingItemMatchesRecord(item, record, true) { |
| 528 | return item, true |
| 529 | } |
| 530 | } |
| 531 | } |
| 532 | return api.PricingItem{}, false |
| 533 | } |
| 534 | |
| 535 | func pricingItemMatchesRecord(item api.PricingItem, record resources.DecodedResource, usageSuffixMatch bool) bool { |
| 536 | if record.Provider != "" && !equalFoldTrim(item.Provider, record.Provider) { |
no test coverage detected