Skip to content

Commit

Permalink
fixup! Support for Librato Alerts and Services
Browse files Browse the repository at this point in the history
  • Loading branch information
elblivion committed Aug 31, 2016
1 parent e267db8 commit ba6fbc6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 64 deletions.
57 changes: 14 additions & 43 deletions resource_librato_alert.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,49 +229,20 @@ func resourceLibratoAlertRead(d *schema.ResourceData, meta interface{}) error {

func resourceLibratoAlertReadResult(d *schema.ResourceData, alert *librato.Alert) error {
d.SetId(strconv.FormatUint(uint64(*alert.ID), 10))
if alert.ID != nil {
if err := d.Set("id", *alert.ID); err != nil {
return err
}
}
if alert.Name != nil {
if err := d.Set("name", *alert.Name); err != nil {
return err
}
}
if alert.Description != nil {
if err := d.Set("description", *alert.Description); err != nil {
return err
}
}
if alert.Active != nil {
if err := d.Set("active", *alert.Active); err != nil {
return err
}
}
if alert.RearmSeconds != nil {
if err := d.Set("rearm_seconds", *alert.RearmSeconds); err != nil {
return err
}
}
if alert.Services != nil {
services := resourceLibratoAlertServicesGather(d, alert.Services.([]interface{}))
if err := d.Set("services", services); err != nil {
return err
}
}
if alert.Conditions != nil {
conditions := resourceLibratoAlertConditionsGather(d, alert.Conditions)
if err := d.Set("condition", conditions); err != nil {
return err
}
}
if alert.Attributes != nil {
attributes := resourceLibratoAlertAttributesGather(d, alert.Attributes)
if err := d.Set("attributes", attributes); err != nil {
return err
}
}
d.Set("id", *alert.ID)
d.Set("name", *alert.Name)
d.Set("description", *alert.Description)
d.Set("active", *alert.Active)
d.Set("rearm_seconds", *alert.RearmSeconds)

services := resourceLibratoAlertServicesGather(d, alert.Services.([]interface{}))
d.Set("services", services)

conditions := resourceLibratoAlertConditionsGather(d, alert.Conditions)
d.Set("condition", conditions)

attributes := resourceLibratoAlertAttributesGather(d, alert.Attributes)
d.Set("attributes", attributes)

return nil
}
Expand Down
25 changes: 4 additions & 21 deletions resource_librato_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,27 +138,10 @@ func resourceLibratoServiceRead(d *schema.ResourceData, meta interface{}) error

func resourceLibratoServiceReadResult(d *schema.ResourceData, service *librato.Service) error {
d.SetId(strconv.FormatUint(uint64(*service.ID), 10))
if service.ID != nil {
if err := d.Set("id", *service.ID); err != nil {
return err
}
}
if service.Type != nil {
if err := d.Set("type", *service.Type); err != nil {
return err
}
}
if service.Title != nil {
if err := d.Set("title", *service.Title); err != nil {
return err
}
}
if service.Settings != nil {
settings, _ := resourceLibratoServicesFlatten(service.Settings)
if err := d.Set("settings", settings); err != nil {
return err
}
}
d.Set("id", *service.ID)
d.Set("type", *service.Type)
d.Set("title", *service.Title)
d.Set("settings", settings)

return nil
}
Expand Down

0 comments on commit ba6fbc6

Please sign in to comment.