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 {
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 {
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{}))
if err := d.Set("services", services); err != nil {
return err
}
}
if alert.Conditions != nil {
d.Set("services", services)
conditions := resourceLibratoAlertConditionsGather(d, alert.Conditions)
if err := d.Set("condition", conditions); err != nil {
return err
}
}
if alert.Attributes != nil {
d.Set("condition", conditions)
attributes := resourceLibratoAlertAttributesGather(d, alert.Attributes)
if err := d.Set("attributes", attributes); err != nil {
return err
}
}
d.Set("attributes", attributes)
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 {
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
}