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

Function detectUsageBased

internal/estimate/estimator.go:626–636  ·  view source on GitHub ↗

detectUsageBased returns (true, unit) when the dominant pricing unit is not time-based (i.e. not "Hrs"/"Hours"). It picks the unit from the first OnDemand entry, falling back to the first entry overall.

(entries []resources.PriceEntry)

Source from the content-addressed store, hash-verified

624// time-based (i.e. not "Hrs"/"Hours"). It picks the unit from the first
625// OnDemand entry, falling back to the first entry overall.
626func detectUsageBased(entries []resources.PriceEntry) (bool, string) {
627 for _, e := range entries {
628 if e.IsCurrent {
629 return !isHourlyUnit(e.Unit), e.Unit
630 }
631 }
632 if len(entries) > 0 {
633 return !isHourlyUnit(entries[0].Unit), entries[0].Unit
634 }
635 return false, ""
636}
637
638// resolveUsageQty returns the monthly quantity to use for a resource.
639// Priority: usageMap (user-supplied) > rawType key > service/subLabel key > service key > global default.

Callers 1

EstimateAllResourcesFunction · 0.85

Calls 1

isHourlyUnitFunction · 0.85

Tested by

no test coverage detected