Repository: cycloidio/terracost
Pull request #79 (2022-08-17 11:10:16)

aws/filter: Updated the filters with the new names
As they where changed they did no longer work as expected as the keys used are no longer correct


Patch:
diff --git a/aws/filter.go b/aws/filter.go
index cab7c35..111a8d8 100644
--- a/aws/filter.go
+++ b/aws/filter.go
@@ -32,10 +32,10 @@ func minimalFilterEC2(pp *price.WithProduct) bool {
 	switch pp.Product.Family {
 	case "Compute Instance":
 		allowedProductAttrs := map[string][]string{
-			"capacitystatus":  {"Used"},
-			"operatingSystem": {"Linux"},
-			"preInstalledSw":  {"NA"},
-			"tenancy":         {"Shared", "Dedicated"},
+			"CapacityStatus":  {"Used"},
+			"OperatingSystem": {"Linux"},
+			"PreInstalledSW":  {"NA"},
+			"Tenancy":         {"Shared", "Dedicated"},
 		}
 		for k, vals := range allowedProductAttrs {
 			if !isValueAllowed(pp.Product.Attributes[k], vals) {


Test patch:
diff --git a/aws/filter_test.go b/aws/filter_test.go
index 0118709..2d53e2e 100644
--- a/aws/filter_test.go
+++ b/aws/filter_test.go
@@ -15,16 +15,16 @@ func TestMinimalFilter(t *testing.T) {
 			{Product: &product.Product{Service: "AmazonEC2", Family: "Storage"}},
 			{Product: &product.Product{Service: "AmazonEC2", Family: "System Operation"}},
 			{Product: &product.Product{Service: "AmazonEC2", Family: "Compute Instance", Attributes: map[string]string{
-				"capacitystatus":  "Used",
-				"operatingSystem": "Linux",
-				"preInstalledSw":  "NA",
-				"tenancy":         "Shared",
+				"CapacityStatus":  "Used",
+				"OperatingSystem": "Linux",
+				"PreInstalledSW":  "NA",
+				"Tenancy":         "Shared",
 			}}},
 			{Product: &product.Product{Service: "AmazonEC2", Family: "Compute Instance", Attributes: map[string]string{
-				"capacitystatus":  "Used",
-				"operatingSystem": "Linux",
-				"preInstalledSw":  "NA",
-				"tenancy":         "Dedicated",
+				"CapacityStatus":  "Used",
+				"OperatingSystem": "Linux",
+				"PreInstalledSW":  "NA",
+				"Tenancy":         "Dedicated",
 			}}},
 			{Product: &product.Product{Service: "AmazonRDS", Family: "Database Instance"}},
 			{Product: &product.Product{Service: "AmazonRDS", Family: "Database Storage"}},
@@ -42,28 +42,28 @@ func TestMinimalFilter(t *testing.T) {
 			{Product: &product.Product{Service: "AmazonEC2", Family: "NAT Gateway"}},
 			{Product: &product.Product{Service: "AmazonEC2", Family: "Fee"}},
 			{Product: &product.Product{Service: "AmazonEC2", Family: "Compute Instance", Attributes: map[string]string{
-				"capacitystatus":  "Used",
-				"operatingSystem": "Linux",
-				"preInstalledSw":  "NA",
-				"tenancy":         "Host",
+				"CapacityStatus":  "Used",
+				"OperatingSystem": "Linux",
+				"PreInstalledSW":  "NA",
+				"Tenancy":         "Host",
 			}}},
 			{Product: &product.Product{Service: "AmazonEC2", Family: "Compute Instance", Attributes: map[string]string{
-				"capacitystatus":  "Used",
-				"operatingSystem": "SUSE",
-				"preInstalledSw":  "NA",
-				"tenancy":         "Shared",
+				"CapacityStatus":  "Used",
+				"OperatingSystem": "SUSE",
+				"PreInstalledSW":  "NA",
+				"Tenancy":         "Shared",
 			}}},
 			{Product: &product.Product{Service: "AmazonEC2", Family: "Compute Instance", Attributes: map[string]string{
-				"capacitystatus":  "Used",
-				"operatingSystem": "Linux",
-				"preInstalledSw":  "SQL Server",
-				"tenancy":         "Shared",
+				"CapacityStatus":  "Used",
+				"OperatingSystem": "Linux",
+				"PreInstalledSW":  "SQL Server",
+				"Tenancy":         "Shared",
 			}}},
 			{Product: &product.Product{Service: "AmazonEC2", Family: "Compute Instance", Attributes: map[string]string{
-				"capacitystatus":  "AllocatedCapacityReservation",
-				"operatingSystem": "Linux",
-				"preInstalledSw":  "NA",
-				"tenancy":         "Shared",
+				"CapacityStatus":  "AllocatedCapacityReservation",
+				"OperatingSystem": "Linux",
+				"PreInstalledSW":  "NA",
+				"Tenancy":         "Shared",
 			}}},
 			{Product: &product.Product{Service: "AmazonRDS", Family: "CPU Credits"}},
 			{Product: &product.Product{Service: "AmazonRDS", Family: "Performance Insights"}},