Skip to content

Commit

Permalink
fix roks cluster estimate
Browse files Browse the repository at this point in the history
  • Loading branch information
hiltol committed Apr 2, 2024
1 parent 0089cfa commit 0c55cac
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions internal/resources/ibm/container_vpc_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,26 +54,23 @@ func (r *ContainerVpcCluster) PopulateUsage(u *schema.UsageData) {
func (r *ContainerVpcCluster) BuildResource() *schema.Resource {
isOpenshift := strings.HasSuffix(strings.ToLower(r.KubeVersion), "openshift")
operatingSystem := "UBUNTU"
useOcpPrices := false
if isOpenshift {
operatingSystem = "RHEL"
// if an entitlement is specified, then ocp licensing is already covered. use pricing that
// does not include ocp charges.
if !r.Entitlement {
useOcpPrices = true
}
}
var attributeFilters = []*schema.AttributeFilter{
{Key: "provider", Value: strPtr("vpc-gen2")},
{Key: "flavor", Value: strPtr(r.Flavor)},
{Key: "serverType", Value: strPtr("virtual")},
{Key: "isolation", Value: strPtr("public")},
{Key: "catalogRegion", Value: strPtr(r.Region)},
{Key: "operatingSystem", ValueRegex: strPtr(fmt.Sprintf("/%s/i", operatingSystem))},
}
// if an entitlement is specified, then ocp licensing is already covered. use pricing that
// does not include ocp charges.
if r.Entitlement {
attributeFilters = append(attributeFilters, &schema.AttributeFilter{
Key: "ocpIncluded", Value: strPtr(""),
})
} else {
// if there's no entitlement, then ocp licenses will be added to the hourly pricing.
// set filter for prices that include ocp costs.
if useOcpPrices {
attributeFilters = append(attributeFilters, &schema.AttributeFilter{
Key: "ocpIncluded", Value: strPtr("true"),
})
Expand Down Expand Up @@ -101,6 +98,7 @@ func (r *ContainerVpcCluster) BuildResource() *schema.Resource {
ProductFilter: &schema.ProductFilter{
VendorName: strPtr("ibm"),
Service: strPtr("containers-kubernetes"),
Region: strPtr(r.Region),
AttributeFilters: attributeFilters,
},
}
Expand Down

0 comments on commit 0c55cac

Please sign in to comment.