From 8fdb687f84265b5e6b44d4c8cc0f82f58059dc94 Mon Sep 17 00:00:00 2001 From: Pawel Szczodruch Date: Wed, 15 Sep 2021 11:38:21 -0700 Subject: [PATCH 1/2] converting float/int to string for value --- rollbar/resource_notification.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/rollbar/resource_notification.go b/rollbar/resource_notification.go index 4d58d820..b07a1bfb 100644 --- a/rollbar/resource_notification.go +++ b/rollbar/resource_notification.go @@ -282,6 +282,27 @@ func flattenConfig(config map[string]interface{}) *schema.Set { func flattenRule(filters []interface{}, trigger string) *schema.Set { var out = make([]interface{}, 0) m := make(map[string]interface{}) + for _, filter := range filters { + filterConv := filter.(map[string]interface{}) + filterValue := filterConv["value"] + switch v := filterValue.(type) { + case int: + filterConv["value"] = strconv.Itoa(v) + case int8: + filterConv["value"] = strconv.FormatInt(int64(v), 10) + case int16: + filterConv["value"] = strconv.FormatInt(int64(v), 10) + case int32: + filterConv["value"] = strconv.FormatInt(int64(v), 10) + case int64: + filterConv["value"] = strconv.FormatInt(v, 10) + case float32: + filterConv["value"] = strconv.FormatFloat(float64(v), 'f', -1, 32) + case float64: + filterConv["value"] = strconv.FormatFloat(v, 'f', -1, 64) + } + filter = filterConv + } m["filters"] = filters out = append(out, m) m["trigger"] = trigger From b75ac485ba9b986d102a6d9959867c857228bbec Mon Sep 17 00:00:00 2001 From: Pawel Szczodruch Date: Wed, 15 Sep 2021 13:39:44 -0700 Subject: [PATCH 2/2] removed inefective assignment --- rollbar/resource_notification.go | 1 - 1 file changed, 1 deletion(-) diff --git a/rollbar/resource_notification.go b/rollbar/resource_notification.go index b07a1bfb..61840d8a 100644 --- a/rollbar/resource_notification.go +++ b/rollbar/resource_notification.go @@ -301,7 +301,6 @@ func flattenRule(filters []interface{}, trigger string) *schema.Set { case float64: filterConv["value"] = strconv.FormatFloat(v, 'f', -1, 64) } - filter = filterConv } m["filters"] = filters out = append(out, m)