Skip to content

Commit

Permalink
update explicit buckets name and make item_type of bounds integers
Browse files Browse the repository at this point in the history
Signed-off-by: Modular Magician <magic-modules@google.com>
  • Loading branch information
megan07 authored and modular-magician committed Aug 28, 2019
1 parent 2f0e36c commit 1adf4fe
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 3 deletions.
6 changes: 3 additions & 3 deletions google/resource_logging_metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func resourceLoggingMetric() *schema.Resource {
Type: schema.TypeList,
Optional: true,
Elem: &schema.Schema{
Type: schema.TypeString,
Type: schema.TypeInt,
},
},
},
Expand Down Expand Up @@ -529,7 +529,7 @@ func flattenLoggingMetricBucketOptions(v interface{}, d *schema.ResourceData) in
transformed["exponential_buckets"] =
flattenLoggingMetricBucketOptionsExponentialBuckets(original["exponentialBuckets"], d)
transformed["explicit"] =
flattenLoggingMetricBucketOptionsExplicit(original["explicit"], d)
flattenLoggingMetricBucketOptionsExplicit(original["explicitBuckets"], d)
return []interface{}{transformed}
}
func flattenLoggingMetricBucketOptionsLinearBuckets(v interface{}, d *schema.ResourceData) interface{} {
Expand Down Expand Up @@ -774,7 +774,7 @@ func expandLoggingMetricBucketOptions(v interface{}, d TerraformResourceData, co
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedExplicit); val.IsValid() && !isEmptyValue(val) {
transformed["explicit"] = transformedExplicit
transformed["explicitBuckets"] = transformedExplicit
}

return transformed, nil
Expand Down
44 changes: 44 additions & 0 deletions google/resource_logging_metric_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,29 @@ func TestAccLoggingMetric_update(t *testing.T) {
})
}

func TestAccLoggingMetric_explicitBucket(t *testing.T) {
t.Parallel()

suffix := acctest.RandString(10)
filter := "resource.type=gae_app AND severity>=ERROR"

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckLoggingMetricDestroy,
Steps: []resource.TestStep{
{
Config: testAccLoggingMetric_update(suffix, filter),
},
{
ResourceName: "google_logging_metric.logging_metric",
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func testAccLoggingMetric_update(suffix string, filter string) string {
return fmt.Sprintf(`
resource "google_logging_metric" "logging_metric" {
Expand All @@ -51,3 +74,24 @@ resource "google_logging_metric" "logging_metric" {
}
}`, suffix, filter)
}

func testAccLoggingMetric_explicitBucket(suffix string, filter string) string {
return fmt.Sprintf(`
resource "google_logging_metric" "logging_metric" {
name = "my-custom-metric-%s"
filter = "%s"
metric_descriptor {
metric_kind = "DELTA"
value_type = "DISTRIBUTION"
}
value_extractor = "EXTRACT(jsonPayload.metrics.running_jobs)"
bucket_options {
explicit {
bounds = [0,1,2,3,4]
}
}
}`, suffix, filter)
}

0 comments on commit 1adf4fe

Please sign in to comment.