Skip to content

Commit

Permalink
fix data sources
Browse files Browse the repository at this point in the history
  • Loading branch information
yacut committed Oct 22, 2020
1 parent af34f26 commit 1c9ef42
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 15 deletions.
3 changes: 1 addition & 2 deletions ilert/data_source_alert_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,9 @@ func dataSourceAlertSourceRead(d *schema.ResourceData, meta interface{}) error {
log.Printf("[DEBUG] Reading iLert alert source")

searchName := d.Get("name").(string)
o := &ilert.GetAlertSourcesInput{}

return resource.Retry(2*time.Minute, func() *resource.RetryError {
resp, err := client.GetAlertSources(o)
resp, err := client.GetAlertSources(&ilert.GetAlertSourcesInput{})
if err != nil {
time.Sleep(2 * time.Second)
return resource.RetryableError(err)
Expand Down
3 changes: 1 addition & 2 deletions ilert/data_source_escalation_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,9 @@ func dataSourceEscalationPolicyRead(d *schema.ResourceData, meta interface{}) er
log.Printf("[DEBUG] Reading iLert escalation policy")

searchName := d.Get("name").(string)
o := &ilert.GetEscalationPoliciesInput{}

return resource.Retry(2*time.Minute, func() *resource.RetryError {
resp, err := client.GetEscalationPolicies(o)
resp, err := client.GetEscalationPolicies(&ilert.GetEscalationPoliciesInput{})
if err != nil {
time.Sleep(2 * time.Second)
return resource.RetryableError(err)
Expand Down
3 changes: 1 addition & 2 deletions ilert/data_source_schedule.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,9 @@ func dataSourceScheduleRead(d *schema.ResourceData, meta interface{}) error {
log.Printf("[DEBUG] Reading iLert schedule")

searchName := d.Get("name").(string)
o := &ilert.GetSchedulesInput{}

return resource.Retry(2*time.Minute, func() *resource.RetryError {
resp, err := client.GetSchedules(o)
resp, err := client.GetSchedules(&ilert.GetSchedulesInput{})
if err != nil {
time.Sleep(2 * time.Second)
return resource.RetryableError(err)
Expand Down
20 changes: 13 additions & 7 deletions ilert/data_source_uptime_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,9 @@ func dataSourceUptimeMonitorRead(d *schema.ResourceData, meta interface{}) error
log.Printf("[DEBUG] Reading iLert uptime monitor")

searchName := d.Get("name").(string)
o := &ilert.GetUptimeMonitorsInput{}

return resource.Retry(2*time.Minute, func() *resource.RetryError {
resp, err := client.GetUptimeMonitors(o)
resp, err := client.GetUptimeMonitors(&ilert.GetUptimeMonitorsInput{})
if err != nil {
time.Sleep(2 * time.Second)
return resource.RetryableError(err)
Expand All @@ -66,11 +65,18 @@ func dataSourceUptimeMonitorRead(d *schema.ResourceData, meta interface{}) error
)
}

d.SetId(strconv.FormatInt(found.ID, 10))
d.Set("name", found.Name)
d.Set("status", found.Status)
d.Set("embed_url", found.EmbedURL)
d.Set("share_url", found.ShareURL)
// Fetch uptime monitor again because the list route does not return report urls
result, err := client.GetUptimeMonitor(&ilert.GetUptimeMonitorInput{UptimeMonitorID: ilert.Int64(found.ID)})
if err != nil {
time.Sleep(2 * time.Second)
return resource.RetryableError(err)
}

d.SetId(strconv.FormatInt(result.UptimeMonitor.ID, 10))
d.Set("name", result.UptimeMonitor.Name)
d.Set("status", result.UptimeMonitor.Status)
d.Set("embed_url", result.UptimeMonitor.EmbedURL)
d.Set("share_url", result.UptimeMonitor.ShareURL)

return nil
})
Expand Down
3 changes: 1 addition & 2 deletions ilert/data_source_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,9 @@ func dataSourceUserRead(d *schema.ResourceData, meta interface{}) error {
log.Printf("[DEBUG] Reading iLert user")

searchEmail := d.Get("email").(string)
o := &ilert.GetUsersInput{}

return resource.Retry(2*time.Minute, func() *resource.RetryError {
resp, err := client.GetUsers(o)
resp, err := client.GetUsers(&ilert.GetUsersInput{})
if err != nil {
time.Sleep(2 * time.Second)
return resource.RetryableError(err)
Expand Down

0 comments on commit 1c9ef42

Please sign in to comment.