Skip to content

Commit

Permalink
fixing conversion problems (#168)
Browse files Browse the repository at this point in the history
  • Loading branch information
OrNovo authored Nov 1, 2023
1 parent 393ef95 commit 3f96653
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
12 changes: 6 additions & 6 deletions coralogix/resource_coralogix_alert.go
Original file line number Diff line number Diff line change
Expand Up @@ -2436,9 +2436,9 @@ func expandNotificationSubgroup(v interface{}) (*alerts.AlertNotification, error
var isWebhookIdDefined bool
if webhookID, ok := m["integration_id"].(string); ok && webhookID != "" {
isWebhookIdDefined = true
id, _ := strconv.Atoi(webhookID)
id := parseNumUint32(webhookID)
notification.IntegrationType = &alerts.AlertNotification_IntegrationId{
IntegrationId: wrapperspb.UInt32(uint32(id)),
IntegrationId: wrapperspb.UInt32(id),
}
}

Expand Down Expand Up @@ -3429,10 +3429,10 @@ func expandUniqueValueTimeFrame(s string) alerts.Timeframe {

func expandTimeInDay(v interface{}) *alerts.Time {
timeArr := strings.Split(v.(string), ":")
hours, _ := strconv.Atoi(timeArr[0])
minutes, _ := strconv.Atoi(timeArr[1])
hours := parseNumInt32(timeArr[0])
minutes := parseNumInt32(timeArr[1])
return &alerts.Time{
Hours: int32(hours),
Minutes: int32(minutes),
Hours: hours,
Minutes: minutes,
}
}
16 changes: 16 additions & 0 deletions coralogix/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -730,3 +730,19 @@ func GetKeys[K, V comparable](m map[K]V) []K {
}
return result
}

func parseNumInt32(desired string) int32 {
parsed, err := strconv.ParseInt(desired, 10, 32)
if err != nil {
return 0
}
return int32(parsed)
}

func parseNumUint32(desired string) uint32 {
parsed, err := strconv.ParseUint(desired, 10, 32)
if err != nil {
return 0
}
return uint32(parsed)
}

0 comments on commit 3f96653

Please sign in to comment.