Skip to content

Commit

Permalink
[BUGFIX] - Infracosts Bug
Browse files Browse the repository at this point in the history
Fixing a bug in the parsing of the infracost report which was introduced in v0.1.6 release by #96. We were expecting a float64 when actually it's a string
  • Loading branch information
gambol99 committed Jun 9, 2022
1 parent d357945 commit 1c20ee9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
4 changes: 2 additions & 2 deletions charts/terraform-controller/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ apiVersion: v2
name: terraform-controller
description: Controller used to provision a terraform workflow within kubernetes
type: application
version: v0.2.5
appVersion: v0.2.0
version: v0.2.6
appVersion: v0.2.1
sources:
- https://github.com/appvia/terraform-controller
- https://github.com/appvia/terranetes
Expand Down
4 changes: 2 additions & 2 deletions charts/terraform-controller/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ controller:
# policy is image for policy (wip)
policy: bridgecrew/checkov:2.0.1190
# is the controller image
controller: quay.io/appvia/terraform-controller:v0.2.0
controller: quay.io/appvia/terraform-controller:v0.2.1
# The terraform image used when running jobs
executor: quay.io/appvia/terraform-executor:v0.2.0
executor: quay.io/appvia/terraform-executor:v0.2.1

# driftInterval is the minimum time to check for drift
driftInterval: 5h
Expand Down
13 changes: 9 additions & 4 deletions pkg/controller/configuration/ensure.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"encoding/json"
"errors"
"fmt"
"strconv"
"strings"
"time"

Expand Down Expand Up @@ -578,11 +579,15 @@ func (c *Controller) ensureCostStatus(configuration *terraformv1alphav1.Configur

var monthly, hourly float64

if v, ok := report["totalMonthlyCost"].(float64); ok {
monthly = v
if v, ok := report["totalMonthlyCost"].(string); ok {
if x, err := strconv.ParseFloat(v, 64); err == nil {
monthly = x
}
}
if v, ok := report["totalHourlyCost"].(float64); ok {
hourly = v
if v, ok := report["totalHourlyCost"].(string); ok {
if x, err := strconv.ParseFloat(v, 64); err == nil {
hourly = x
}
}

configuration.Status.Costs = &terraformv1alphav1.CostStatus{
Expand Down

0 comments on commit 1c20ee9

Please sign in to comment.