Skip to content

Commit

Permalink
error checking for setting non-scalars in rate limits
Browse files Browse the repository at this point in the history
  • Loading branch information
benjvi committed Mar 5, 2018
1 parent 2d4d4d6 commit 117e978
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions cloudflare/resource_cloudflare_rate_limit.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,12 @@ func resourceCloudFlareRateLimitRead(d *schema.ResourceData, meta interface{}) e

d.Set("threshold", rateLimit.Threshold)
d.Set("period", rateLimit.Period)
d.Set("match", flattenRateLimitTrafficMatcher(rateLimit.Match))
d.Set("action", flattenRateLimitAction(rateLimit.Action))
if err := d.Set("match", flattenRateLimitTrafficMatcher(rateLimit.Match)); err != nil {
log.Printf("[WARN] Error setting match on rate limit %q: %s", d.Id(), err)
}
if err := d.Set("action", flattenRateLimitAction(rateLimit.Action)); err != nil {
log.Printf("[WARN] Error setting action on rate limit %q: %s", d.Id(), err)
}

d.Set("description", rateLimit.Description)
d.Set("disabled", rateLimit.Disabled)
Expand All @@ -392,7 +396,7 @@ func resourceCloudFlareRateLimitRead(d *schema.ResourceData, meta interface{}) e
bypassUrlPatterns = append(bypassUrlPatterns, bypassItem.Value)
} else {
// maybe a new type of bypass was added to api
log.Printf("[WARN] Unkown bypass type found in rate limit for zone: %s", bypassItem.Name)
log.Printf("[WARN] Unkown bypass type found in rate limit for zone %q: %s", d.Id(), bypassItem.Name)
}
}
d.Set("bypass_url_patterns", bypassUrlPatterns)
Expand Down

0 comments on commit 117e978

Please sign in to comment.