From 707247896adc1ab4b50b5b8d976afab85329e946 Mon Sep 17 00:00:00 2001 From: Chris Johnson Date: Wed, 17 May 2017 11:33:44 -0400 Subject: [PATCH] Fixup bad rebase --- provider.go | 1 + resource_librato_metric.go | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/provider.go b/provider.go index 7b1a640..203e06f 100644 --- a/provider.go +++ b/provider.go @@ -28,6 +28,7 @@ func Provider() terraform.ResourceProvider { ResourcesMap: map[string]*schema.Resource{ "librato_space": resourceLibratoSpace(), "librato_space_chart": resourceLibratoSpaceChart(), + "librato_metric": resourceLibratoMetric(), "librato_alert": resourceLibratoAlert(), "librato_service": resourceLibratoService(), }, diff --git a/resource_librato_metric.go b/resource_librato_metric.go index ad447c1..f1d7aa7 100644 --- a/resource_librato_metric.go +++ b/resource_librato_metric.go @@ -1,6 +1,7 @@ package librato import ( + "encoding/json" "fmt" "log" "reflect" @@ -166,6 +167,7 @@ func resourceLibratoMetricCreate(d *schema.ResourceData, meta interface{}) error _, err := client.Metrics.Edit(metric) if err != nil { + log.Printf("[INFO] ERROR creating Metric: %s", err) return fmt.Errorf("Error creating Librato service: %s", err) } @@ -259,7 +261,8 @@ func resourceLibratoMetricRead(d *schema.ResourceData, meta interface{}) error { } return fmt.Errorf("Error reading Librato Metric %s: %s", id, err) } - log.Printf("[INFO] Received Librato Metric: %+v", *metric) + + log.Printf("[INFO] Read Librato Metric: %s", structToString(metric)) return resourceLibratoMetricReadResult(d, metric) } @@ -400,7 +403,7 @@ func resourceLibratoMetricDelete(d *schema.ResourceData, meta interface{}) error if errResp, ok := err.(*librato.ErrorResponse); ok && errResp.Response.StatusCode == 404 { return nil } - log.Printf("[DEBUG] unknown error attempting to Get metric: %s", err) + log.Printf("[INFO] non-retryable error attempting to Get metric: %s", err) return resource.NonRetryableError(err) } return resource.RetryableError(fmt.Errorf("metric still exists")) @@ -409,3 +412,8 @@ func resourceLibratoMetricDelete(d *schema.ResourceData, meta interface{}) error d.SetId("") return nil } + +func structToString(i interface{}) string { + s, _ := json.Marshal(i) + return string(s) +}