MCPcopy Create free account
hub / github.com/OverloadBlitz/cloudcent-cli / findMatchingPrice

Function findMatchingPrice

internal/estimate/estimator.go:514–533  ·  view source on GitHub ↗
(record resources.DecodedResource, response map[string][]api.PricingItem)

Source from the content-addressed store, hash-verified

512}
513
514func 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
535func pricingItemMatchesRecord(item api.PricingItem, record resources.DecodedResource, usageSuffixMatch bool) bool {
536 if record.Provider != "" && !equalFoldTrim(item.Provider, record.Provider) {

Callers 1

EstimateAllResourcesFunction · 0.85

Calls 1

pricingItemMatchesRecordFunction · 0.85

Tested by

no test coverage detected