This message was deleted.
# contributors
b
This message was deleted.
w
We should add a usage file parameter for the resource, e.g.:
monthly_additional_pushes: 12000000 # Monthly total number of additional pushes.
If this value is present, it could then be used to calculate the cost in the resource file, based on the tier (there’s a
CalculateTierBuckets
tier method that could be used to calculate it, it’s mentioned in the contributing)
c
Ok yeah that makes sense. I guess if you’ve already done the hard part of finding the price, then just add the usage parameter.
w
Yep, in addition, we only want to show what’s applicable… So for that resource’s Basic tier, we should show “Additional Pushes (over 10M) cost depends on usage” if there is no usage file. If there’s a usage file and the total number of additional pushes is <10M, we shouldn’t show that cost component. If it’s >10M, show that cost component with the calculated cost. For that resource’s Standard tier: if there’s no usage-file, we should show two cost components: • Additional pushes (10-100M), cost depends on usage… • Additional pushes (over 100M), cost depends on usage… If there is a usage file, we can use the value to calculate which of the above apply and only show them if applicable.
it’s a bit more work, but it means the user just enters their usage in the yml file and we show them their costs; not all possible prices.
c
If there’s no usage-file or if there’s no usage for that key? I guess there are three possibilities of no usage specified: No usage-file at all; No usage for the resource, Usage for the resource but without a ‘monthly_additional_pushes’ key.
w
inside the resource file, we normally do something like this:
Copy code
var monthlyAdditionalPushes *decimal.Decimal

if u != nil && u.Get("monthly_additional_pushes").Type != gjson.Null {
  monthlyAdditionalPushes = decimal.NewFromInt(u.Get("monthly_additional_pushes").Int())
}

...

return &schema.CostComponent{
  ...
  MonthlyQuantity: monthlyAdditionalPushes,
  ...
}
c
Yup that makes sense. We only show the “Monthly cost depends on…” message if there’s no “monthly_additional_pushes” for the resource. If it’s present and set to 0 we omit the line entirely.
🙌 1
w
in this case, if it’s set and <10M, we omit that line since it’s free