fixup! Support for Librato Alerts and Services

This commit is contained in:
Anthony Stanton 2016-08-31 17:20:08 +02:00
parent 783b2e5780
commit 4b2e11ac63
No known key found for this signature in database
GPG Key ID: 42253AF31A97E303
2 changed files with 18 additions and 64 deletions

View File

@ -229,49 +229,20 @@ func resourceLibratoAlertRead(d *schema.ResourceData, meta interface{}) error {
func resourceLibratoAlertReadResult(d *schema.ResourceData, alert *librato.Alert) error { func resourceLibratoAlertReadResult(d *schema.ResourceData, alert *librato.Alert) error {
d.SetId(strconv.FormatUint(uint64(*alert.ID), 10)) d.SetId(strconv.FormatUint(uint64(*alert.ID), 10))
if alert.ID != nil { d.Set("id", *alert.ID)
if err := d.Set("id", *alert.ID); err != nil { d.Set("name", *alert.Name)
return err d.Set("description", *alert.Description)
} d.Set("active", *alert.Active)
} d.Set("rearm_seconds", *alert.RearmSeconds)
if alert.Name != nil {
if err := d.Set("name", *alert.Name); err != nil { services := resourceLibratoAlertServicesGather(d, alert.Services.([]interface{}))
return err d.Set("services", services)
}
} conditions := resourceLibratoAlertConditionsGather(d, alert.Conditions)
if alert.Description != nil { d.Set("condition", conditions)
if err := d.Set("description", *alert.Description); err != nil {
return err attributes := resourceLibratoAlertAttributesGather(d, alert.Attributes)
} d.Set("attributes", attributes)
}
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
}
}
return nil return nil
} }

View File

@ -138,27 +138,10 @@ func resourceLibratoServiceRead(d *schema.ResourceData, meta interface{}) error
func resourceLibratoServiceReadResult(d *schema.ResourceData, service *librato.Service) error { func resourceLibratoServiceReadResult(d *schema.ResourceData, service *librato.Service) error {
d.SetId(strconv.FormatUint(uint64(*service.ID), 10)) d.SetId(strconv.FormatUint(uint64(*service.ID), 10))
if service.ID != nil { d.Set("id", *service.ID)
if err := d.Set("id", *service.ID); err != nil { d.Set("type", *service.Type)
return err d.Set("title", *service.Title)
} d.Set("settings", settings)
}
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
}
}
return nil return nil
} }