forked from infracost/infracost
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into feat/scc-wp-support
- Loading branch information
Showing
8 changed files
with
167 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
internal/resources/ibm/resource_instance_aiopenscale.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
package ibm | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/infracost/infracost/internal/schema" | ||
"github.com/shopspring/decimal" | ||
) | ||
|
||
/** | ||
* Lite: 'lite' (Free) | ||
* Essentials: 'essentials' | ||
* Standard V2 == 'standard-v2' | ||
*/ | ||
func GetWGOVCostComponents(r *ResourceInstance) []*schema.CostComponent { | ||
if r.Plan == "essentials" { | ||
return []*schema.CostComponent{ | ||
WGOVResourceUnitsCostComponent(r), | ||
} | ||
} else if r.Plan == "standard-v2" { | ||
return []*schema.CostComponent{ | ||
WGOVModelCostComponent(r), | ||
} | ||
} else if r.Plan == "lite" { | ||
costComponent := &schema.CostComponent{ | ||
Name: "Lite plan", | ||
UnitMultiplier: decimal.NewFromInt(1), | ||
MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)), | ||
} | ||
costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0))) | ||
return []*schema.CostComponent{costComponent} | ||
} else { | ||
costComponent := schema.CostComponent{ | ||
Name: fmt.Sprintf("Plan %s with customized pricing", r.Plan), | ||
UnitMultiplier: decimal.NewFromInt(1), | ||
MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)), | ||
} | ||
costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0))) | ||
return []*schema.CostComponent{ | ||
&costComponent, | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* 1 RU for every: | ||
* 1 WGOV_PredictiveModelEvals | ||
* 1 WGOV_FoundationalModelEvals | ||
* 1 WGOV_GlobalExplanations | ||
* 500 WGOV_LocalExplanations | ||
* basically, everything converts into an RU for charging costs, with limits | ||
*/ | ||
func WGOVResourceUnitsCostComponent(r *ResourceInstance) *schema.CostComponent { | ||
var q *decimal.Decimal | ||
if r.WGOV_ru != nil { | ||
q = decimalPtr(decimal.NewFromFloat(*r.WGOV_ru)) | ||
} | ||
return &schema.CostComponent{ | ||
Name: "Resource Units", | ||
Unit: "RU", | ||
UnitMultiplier: decimal.NewFromInt(1), | ||
MonthlyQuantity: q, | ||
ProductFilter: &schema.ProductFilter{ | ||
VendorName: strPtr("ibm"), | ||
Region: strPtr(r.Location), | ||
Service: &r.Service, | ||
AttributeFilters: []*schema.AttributeFilter{ | ||
{Key: "planName", Value: &r.Plan}, | ||
}, | ||
}, | ||
PriceFilter: &schema.PriceFilter{ | ||
Unit: strPtr("RESOURCE_UNITS"), | ||
}, | ||
} | ||
} | ||
|
||
/** | ||
* No restrictions with unlimited evaluations performed on a model, charged on a per model basis instead | ||
*/ | ||
func WGOVModelCostComponent(r *ResourceInstance) *schema.CostComponent { | ||
var q *decimal.Decimal | ||
if r.WGOV_Models != nil { | ||
q = decimalPtr(decimal.NewFromFloat(*r.WGOV_Models)) | ||
} else { | ||
q = decimalPtr(decimal.NewFromInt(1)) | ||
} | ||
return &schema.CostComponent{ | ||
Name: "Deployed Models", | ||
Unit: "Model", | ||
UnitMultiplier: decimal.NewFromInt(1), | ||
MonthlyQuantity: q, | ||
ProductFilter: &schema.ProductFilter{ | ||
VendorName: strPtr("ibm"), | ||
Region: strPtr(r.Location), | ||
Service: &r.Service, | ||
AttributeFilters: []*schema.AttributeFilter{ | ||
{Key: "planName", Value: &r.Plan}, | ||
}, | ||
}, | ||
PriceFilter: &schema.PriceFilter{ | ||
Unit: strPtr("MODELS_PER_MONTH"), | ||
}, | ||
} | ||
} |