Skip to content

Commit

Permalink
update display names and cost component name for volumes (#151)
Browse files Browse the repository at this point in the history
  • Loading branch information
hiltol authored May 10, 2023
1 parent 185b933 commit 506e37f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 8 deletions.
3 changes: 2 additions & 1 deletion internal/providers/terraform/ibm/ibm.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ var globalCatalogServiceId = map[string]catalogMetadata{
"ibm_is_floating_ip": {"is.floating-ip", []string{}, nil},
"ibm_is_flow_log": {"is.flow-log-collector", []string{}, nil},
"ibm_cloudant": {"Cloudant", []string{}, nil},
"ibm_pi_instance": {"Virtual Servers for PowerVS", []string{}, nil},
"ibm_pi_instance": {"Power Systems Virtual Server", []string{}, nil},
"ibm_pi_volume": {"Power Systems Storage Volume", []string{}, nil},
"ibm_cos_bucket": {"Object Storage Bucket", []string{}, nil},
"ibm_is_lb": {"is.load-balancer", []string{}, nil},
"ibm_is_public_gateway": {"is.public-gateway", []string{"ibm_is_floating_ip"}, nil},
Expand Down
17 changes: 13 additions & 4 deletions internal/providers/terraform/ibm/ibm_pi_volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,19 @@ func newIbmPiVolume(d *schema.ResourceData, u *schema.UsageData) *schema.Resourc
configuration["region"] = region
configuration["profile"] = r.Type
configuration["capacity"] = r.Size
configuration["volume_pool"] = r.VolumePool
configuration["affinity"] = r.AffinityPolicy
configuration["affinity_instance"] = r.AffinityInstance
configuration["affinity_volume"] = r.AffinityVolume

if r.VolumePool != "" {
configuration["volume_pool"] = r.VolumePool
}
if r.AffinityPolicy != "" {
configuration["affinity"] = r.AffinityPolicy
}
if r.AffinityInstance != "" {
configuration["affinity_instance"] = r.AffinityInstance
}
if r.AffinityVolume != "" {
configuration["affinity_volume"] = r.AffinityVolume
}

SetCatalogMetadata(d, d.Type, configuration)

Expand Down
2 changes: 2 additions & 0 deletions internal/providers/terraform/ibm/pi_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ func newPiInstance(d *schema.ResourceData, u *schema.UsageData) *schema.Resource
memory := d.Get("pi_memory").Float()
storageType := d.Get("pi_storage_type").String()
profile := d.Get("pi_sap_profile_id").String()
name := d.Get("pi_instance_name").String()

var os int64 = -1
var isLegacyIBMiImageVersion bool
Expand Down Expand Up @@ -106,6 +107,7 @@ func newPiInstance(d *schema.ResourceData, u *schema.UsageData) *schema.Resource
configuration["region"] = region
configuration["storageType"] = storageType
configuration["image"] = imageName
configuration["name"] = name

if profile != "" {
configuration["profile"] = profile
Expand Down
8 changes: 5 additions & 3 deletions internal/resources/ibm/ibm_pi_volume.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package ibm

import (
"fmt"

"github.com/infracost/infracost/internal/resources"
"github.com/infracost/infracost/internal/schema"
"github.com/shopspring/decimal"
Expand Down Expand Up @@ -68,7 +70,7 @@ func (r *IbmPiVolume) BuildResource() *schema.Resource {
if r.VolumePool != "" {
// How am I supposed to guess?
costComponent := &schema.CostComponent{
Name: "Price dependent upon volume pool settings",
Name: fmt.Sprintf("Volume pool (%d GB, %s) Price dependent on volume pool settings", r.Size, r.Name),
Unit: "Gigabyte Instance Hours",
UnitMultiplier: decimal.NewFromInt(1),
MonthlyQuantity: q,
Expand All @@ -86,7 +88,7 @@ func (r *IbmPiVolume) BuildResource() *schema.Resource {
} else if r.AffinityPolicy == "affinity" {
// How am I supposed to guess?
costComponent := &schema.CostComponent{
Name: "Price dependent upon affinity settings",
Name: fmt.Sprintf("Volume (%d GB, %s) Price dependent on affinity settings", r.Size, r.Name),
Unit: "Gigabyte Instance Hours",
UnitMultiplier: decimal.NewFromInt(1),
MonthlyQuantity: q,
Expand All @@ -104,7 +106,7 @@ func (r *IbmPiVolume) BuildResource() *schema.Resource {
} else if r.Type == "tier1" || r.Type == "tier3" || r.Type == "standard" || r.Type == "ssd" {

costComponent := &schema.CostComponent{
Name: "Price dependent upon affinity settings",
Name: fmt.Sprintf("Volume (%d GB, %s, %s)", r.Size, r.Type, r.Name),
Unit: "Gigabyte Instance Hours",
UnitMultiplier: decimal.NewFromInt(1),
MonthlyQuantity: q,
Expand Down

0 comments on commit 506e37f

Please sign in to comment.