Skip to content

Commit

Permalink
Merge pull request #245 from rollbar/pawel/converting_number_to_string
Browse files Browse the repository at this point in the history
converting float/int to string for value
  • Loading branch information
pawelsz-rb authored Sep 15, 2021
2 parents 86e42a0 + b75ac48 commit 39bcd3d
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions rollbar/resource_notification.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,26 @@ 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)
}
}
m["filters"] = filters
out = append(out, m)
m["trigger"] = trigger
Expand Down

0 comments on commit 39bcd3d

Please sign in to comment.