Skip to content

Commit

Permalink
fix(serve): handle nil values
Browse files Browse the repository at this point in the history
  • Loading branch information
maxime1907 committed Sep 23, 2024
1 parent 85c787e commit 8d94f1f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ go.work.sum
# Custom part
ovh-exporter
vendor
*.env
12 changes: 11 additions & 1 deletion pkg/network/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,18 @@ func updateCloudProviderInstanceBilling(ovhClient *ovh.Client) {
planType = "monthly"
}
}
instancePlanCode := "undefined"
if instance.PlanCode != nil {
instancePlanCode = *instance.PlanCode
}
instanceMonthlyBillingSince := time.Unix(0, 0)
instanceMonthlyBillingStatus := "undefined"
if instance.MonthlyBilling != nil {
instanceMonthlyBillingSince = instance.MonthlyBilling.Since
instanceMonthlyBillingStatus = instance.MonthlyBilling.Status
}

setCloudProjectInstanceBilling(projectID, instance.ID, instance.Name, planType, *instance.PlanCode, instance.MonthlyBilling.Since, instance.MonthlyBilling.Status, 1)
setCloudProjectInstanceBilling(projectID, instance.ID, instance.Name, planType, instancePlanCode, instanceMonthlyBillingSince, instanceMonthlyBillingStatus, 1)
}
}

Expand Down

0 comments on commit 8d94f1f

Please sign in to comment.