Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Event Notifications #232

Merged
merged 55 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from 54 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
3fb1178
Add all resources as free
luisarojas Nov 22, 2024
54cf463
Add usage variables to root yml
luisarojas Nov 22, 2024
825844f
Fix root usage yml formatting
luisarojas Nov 22, 2024
aa845e0
Add event-notifications to Global Catalog & sort
luisarojas Nov 22, 2024
b755aaa
Add event-notifications under resource_instance
luisarojas Nov 22, 2024
2ea1362
Add event-notifications unit test usage
luisarojas Nov 22, 2024
74ff730
Fix unit test usage yml formatting
luisarojas Nov 22, 2024
fbee9c9
Add Terraform unit tests for Event Notifications
luisarojas Nov 22, 2024
cc394dd
Change some usage from int to float
luisarojas Nov 22, 2024
7d286df
Set DefaultValue property to 0
luisarojas Nov 23, 2024
0e95597
Add no-usage Terraform unit test
luisarojas Nov 23, 2024
f05db53
Set test usage to the minimum to show in results
luisarojas Nov 23, 2024
5ee9a75
Updated golden file to include Event Notifications
luisarojas Nov 23, 2024
b673401
Add all Cost Components
luisarojas Nov 23, 2024
1199b60
Remove destinations & subscriptions as free
luisarojas Nov 24, 2024
6cdd953
Update EN golden file to only 1 cost component
luisarojas Nov 24, 2024
17b9b69
Update EN golden file to only 1 cost component
luisarojas Nov 24, 2024
03cbaa5
Better output for lite EN instances
luisarojas Nov 24, 2024
cd5ef82
Add support for en_destination_android resource
luisarojas Nov 24, 2024
bc4a424
Add support for android subscriptions
luisarojas Nov 24, 2024
4e211e2
Add destination android info in comments
luisarojas Nov 24, 2024
74e4bc5
Update function name for clarity
luisarojas Nov 24, 2024
270dd9b
Add support for push notifications in Chrome
luisarojas Nov 24, 2024
55fe978
Add support for destinations in Chrome
luisarojas Nov 24, 2024
cc6ceda
Update function name for clarity
luisarojas Nov 24, 2024
8c25ddd
Add support for destinations in Firefox
luisarojas Nov 24, 2024
a9a2230
Add support for destinations in Huawei
luisarojas Nov 24, 2024
493fb99
Add support for destinations in iOS
luisarojas Nov 24, 2024
5b4504f
Add support for destinations in Safari
luisarojas Nov 24, 2024
d611bfe
Add support for subscriptions in Firefox
luisarojas Nov 24, 2024
f25d78e
Add support for subscriptions in Huawei
luisarojas Nov 24, 2024
2a30f3b
Fix output text
luisarojas Nov 24, 2024
14e0c65
Add support for subscriptions in iOS
luisarojas Nov 24, 2024
29606de
Add support for subscriptions in Safaro
luisarojas Nov 24, 2024
49791ec
Add support for subscriptions in Slack
luisarojas Nov 24, 2024
daa8b8c
Fix bug in referencing struct
luisarojas Nov 24, 2024
e4770ba
Add support for subscriptions in MS Teams
luisarojas Nov 24, 2024
947fc37
Add support for subscriptions in PagerDuty
luisarojas Nov 24, 2024
13f5a45
Remove 'lite' as option; not listed in description
luisarojas Nov 24, 2024
2fcc45b
Account for free 1000 notifications in lite
luisarojas Nov 24, 2024
2363f57
Add support for subscriptions in webhooks
luisarojas Nov 24, 2024
ace1533
Add support for subscriptions in ServiceNow
luisarojas Nov 24, 2024
3c95b3e
Add support for subscriptions in Code Engine
luisarojas Nov 24, 2024
15e7785
Add support for subscriptions in COS
luisarojas Nov 24, 2024
ef8b983
Add support for SMS subscriptions
luisarojas Nov 24, 2024
dd4d574
Add more usage for SMS subcription
luisarojas Nov 24, 2024
059cb40
Fix typo in variable name
luisarojas Nov 24, 2024
7b69347
Add explicit mention of lite plans
luisarojas Nov 24, 2024
0041b8b
Add support for IBM e-mail subscriptions
luisarojas Nov 24, 2024
986d4ed
Remove unused comments
luisarojas Nov 24, 2024
58d6f4c
Add support for custom domain email subscriptions
luisarojas Nov 24, 2024
9766179
Account for free 20 emails in lite
luisarojas Nov 24, 2024
7c4ad86
Sort
luisarojas Nov 24, 2024
4b3a9cc
Add more EN free resources
luisarojas Nov 24, 2024
6e781a5
Make note of one-time setup fee
luisarojas Nov 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
642 changes: 333 additions & 309 deletions infracost-usage-example.yml

Large diffs are not rendered by default.

46 changes: 46 additions & 0 deletions internal/providers/terraform/ibm/en_destination.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package ibm

import (
"github.com/infracost/infracost/internal/resources/ibm"
"github.com/infracost/infracost/internal/schema"
)

func getEnDestinationRegistryItem() *schema.RegistryItem {
return &schema.RegistryItem{
Name: "ibm_en_destination_android",
RFunc: newEnDestination,
ReferenceAttributes: []string{"instance_guid"},
}
}

func newEnDestination(d *schema.ResourceData, u *schema.UsageData) *schema.Resource {

region := d.Get("region").String()
name := d.Get("name").String()
is_pre_prod := d.Get("config.0.params.0.pre_prod").Bool()
var plan string

enReferenceAttributes := d.References("instance_guid")
if len(enReferenceAttributes) > 0 {
plan = enReferenceAttributes[0].Get("plan").String()
}

r := &ibm.EnDestination{
Address: d.Address,
IsPreProd: is_pre_prod,
Name: name,
Plan: plan,
Region: region,
}
r.PopulateUsage(u)

configuration := make(map[string]any)
configuration["name"] = name
configuration["plan"] = plan
configuration["pre-prod"] = is_pre_prod
configuration["region"] = region

SetCatalogMetadata(d, d.Type, configuration)

return r.BuildResource()
}
46 changes: 46 additions & 0 deletions internal/providers/terraform/ibm/en_destination_chrome.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package ibm

import (
"github.com/infracost/infracost/internal/resources/ibm"
"github.com/infracost/infracost/internal/schema"
)

func getEnDestinationChromeRegistryItem() *schema.RegistryItem {
return &schema.RegistryItem{
Name: "ibm_en_destination_chrome",
RFunc: newEnDestinationChrome,
ReferenceAttributes: []string{"instance_guid"},
}
}

func newEnDestinationChrome(d *schema.ResourceData, u *schema.UsageData) *schema.Resource {

region := d.Get("region").String()
name := d.Get("name").String()
is_pre_prod := d.Get("config.0.params.0.pre_prod").Bool()

var plan string
enReferenceAttributes := d.References("instance_guid")
if len(enReferenceAttributes) > 0 {
plan = enReferenceAttributes[0].Get("plan").String()
}

r := &ibm.EnDestinationChrome{
Address: d.Address,
IsPreProd: is_pre_prod,
Name: name,
Plan: plan,
Region: region,
}
r.PopulateUsage(u)

configuration := make(map[string]any)
configuration["name"] = name
configuration["plan"] = plan
configuration["pre-prod"] = is_pre_prod
configuration["region"] = region

SetCatalogMetadata(d, d.Type, configuration)

return r.BuildResource()
}
16 changes: 16 additions & 0 deletions internal/providers/terraform/ibm/en_destination_chrome_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package ibm_test

import (
"testing"

"github.com/infracost/infracost/internal/providers/terraform/tftest"
)

func TestEnDestinationChrome(t *testing.T) {
t.Parallel()
if testing.Short() {
t.Skip("skipping test in short mode")
}

tftest.GoldenFileResourceTests(t, "en_destination_chrome_test")
}
46 changes: 46 additions & 0 deletions internal/providers/terraform/ibm/en_destination_firefox.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package ibm

import (
"github.com/infracost/infracost/internal/resources/ibm"
"github.com/infracost/infracost/internal/schema"
)

func getEnDestinationFirefoxRegistryItem() *schema.RegistryItem {
return &schema.RegistryItem{
Name: "ibm_en_destination_firefox",
RFunc: newEnDestinationFirefox,
ReferenceAttributes: []string{"instance_guid"},
}
}

func newEnDestinationFirefox(d *schema.ResourceData, u *schema.UsageData) *schema.Resource {

region := d.Get("region").String()
name := d.Get("name").String()
is_pre_prod := d.Get("config.0.params.0.pre_prod").Bool()

var plan string
enReferenceAttributes := d.References("instance_guid")
if len(enReferenceAttributes) > 0 {
plan = enReferenceAttributes[0].Get("plan").String()
}

r := &ibm.EnDestinationFirefox{
Address: d.Address,
IsPreProd: is_pre_prod,
Name: name,
Plan: plan,
Region: region,
}
r.PopulateUsage(u)

configuration := make(map[string]any)
configuration["name"] = name
configuration["plan"] = plan
configuration["pre-prod"] = is_pre_prod
configuration["region"] = region

SetCatalogMetadata(d, d.Type, configuration)

return r.BuildResource()
}
16 changes: 16 additions & 0 deletions internal/providers/terraform/ibm/en_destination_firefox_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package ibm_test

import (
"testing"

"github.com/infracost/infracost/internal/providers/terraform/tftest"
)

func TestEnDestinationFirefox(t *testing.T) {
t.Parallel()
if testing.Short() {
t.Skip("skipping test in short mode")
}

tftest.GoldenFileResourceTests(t, "en_destination_firefox_test")
}
46 changes: 46 additions & 0 deletions internal/providers/terraform/ibm/en_destination_huawei.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package ibm

import (
"github.com/infracost/infracost/internal/resources/ibm"
"github.com/infracost/infracost/internal/schema"
)

func getEnDestinationHuaweiRegistryItem() *schema.RegistryItem {
return &schema.RegistryItem{
Name: "ibm_en_destination_huawei",
RFunc: newEnDestinationHuawei,
ReferenceAttributes: []string{"instance_guid"},
}
}

func newEnDestinationHuawei(d *schema.ResourceData, u *schema.UsageData) *schema.Resource {

region := d.Get("region").String()
name := d.Get("name").String()
is_pre_prod := d.Get("config.0.params.0.pre_prod").Bool()

var plan string
enReferenceAttributes := d.References("instance_guid")
if len(enReferenceAttributes) > 0 {
plan = enReferenceAttributes[0].Get("plan").String()
}

r := &ibm.EnDestinationHuawei{
Address: d.Address,
IsPreProd: is_pre_prod,
Name: name,
Plan: plan,
Region: region,
}
r.PopulateUsage(u)

configuration := make(map[string]any)
configuration["name"] = name
configuration["plan"] = plan
configuration["pre-prod"] = is_pre_prod
configuration["region"] = region

SetCatalogMetadata(d, d.Type, configuration)

return r.BuildResource()
}
16 changes: 16 additions & 0 deletions internal/providers/terraform/ibm/en_destination_huawei_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package ibm_test

import (
"testing"

"github.com/infracost/infracost/internal/providers/terraform/tftest"
)

func TestEnDestinationHuawei(t *testing.T) {
t.Parallel()
if testing.Short() {
t.Skip("skipping test in short mode")
}

tftest.GoldenFileResourceTests(t, "en_destination_huawei_test")
}
46 changes: 46 additions & 0 deletions internal/providers/terraform/ibm/en_destination_iphoneos.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package ibm

import (
"github.com/infracost/infracost/internal/resources/ibm"
"github.com/infracost/infracost/internal/schema"
)

func getEnDestinationIphoneosRegistryItem() *schema.RegistryItem {
return &schema.RegistryItem{
Name: "ibm_en_destination_ios",
RFunc: newEnDestinationIphoneos,
ReferenceAttributes: []string{"instance_guid"},
}
}

func newEnDestinationIphoneos(d *schema.ResourceData, u *schema.UsageData) *schema.Resource {

region := d.Get("region").String()
name := d.Get("name").String()
is_pre_prod := d.Get("config.0.params.0.pre_prod").Bool()

var plan string
enReferenceAttributes := d.References("instance_guid")
if len(enReferenceAttributes) > 0 {
plan = enReferenceAttributes[0].Get("plan").String()
}

r := &ibm.EnDestinationIphoneos{
Address: d.Address,
IsPreProd: is_pre_prod,
Name: name,
Plan: plan,
Region: region,
}
r.PopulateUsage(u)

configuration := make(map[string]any)
configuration["name"] = name
configuration["plan"] = plan
configuration["pre-prod"] = is_pre_prod
configuration["region"] = region

SetCatalogMetadata(d, d.Type, configuration)

return r.BuildResource()
}
16 changes: 16 additions & 0 deletions internal/providers/terraform/ibm/en_destination_iphoneos_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package ibm_test

import (
"testing"

"github.com/infracost/infracost/internal/providers/terraform/tftest"
)

func TestEnDestinationIphoneos(t *testing.T) {
t.Parallel()
if testing.Short() {
t.Skip("skipping test in short mode")
}

tftest.GoldenFileResourceTests(t, "en_destination_iphoneos_test")
}
46 changes: 46 additions & 0 deletions internal/providers/terraform/ibm/en_destination_safari.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package ibm

import (
"github.com/infracost/infracost/internal/resources/ibm"
"github.com/infracost/infracost/internal/schema"
)

func getEnDestinationSafariRegistryItem() *schema.RegistryItem {
return &schema.RegistryItem{
Name: "ibm_en_destination_safari",
RFunc: newEnDestinationSafari,
ReferenceAttributes: []string{"instance_guid"},
}
}

func newEnDestinationSafari(d *schema.ResourceData, u *schema.UsageData) *schema.Resource {

region := d.Get("region").String()
name := d.Get("name").String()
is_pre_prod := d.Get("config.0.params.0.pre_prod").Bool()

var plan string
enReferenceAttributes := d.References("instance_guid")
if len(enReferenceAttributes) > 0 {
plan = enReferenceAttributes[0].Get("plan").String()
}

r := &ibm.EnDestinationSafari{
Address: d.Address,
IsPreProd: is_pre_prod,
Name: name,
Plan: plan,
Region: region,
}
r.PopulateUsage(u)

configuration := make(map[string]any)
configuration["name"] = name
configuration["plan"] = plan
configuration["pre-prod"] = is_pre_prod
configuration["region"] = region

SetCatalogMetadata(d, d.Type, configuration)

return r.BuildResource()
}
16 changes: 16 additions & 0 deletions internal/providers/terraform/ibm/en_destination_safari_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package ibm_test

import (
"testing"

"github.com/infracost/infracost/internal/providers/terraform/tftest"
)

func TestEnDestinationSafari(t *testing.T) {
t.Parallel()
if testing.Short() {
t.Skip("skipping test in short mode")
}

tftest.GoldenFileResourceTests(t, "en_destination_safari_test")
}
16 changes: 16 additions & 0 deletions internal/providers/terraform/ibm/en_destination_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package ibm_test

import (
"testing"

"github.com/infracost/infracost/internal/providers/terraform/tftest"
)

func TestEnDestination(t *testing.T) {
t.Parallel()
if testing.Short() {
t.Skip("skipping test in short mode")
}

tftest.GoldenFileResourceTests(t, "en_destination_test")
}
Loading
Loading