From c3c07f8b4e6e6abeb3bbf085882c2f71b9e041aa Mon Sep 17 00:00:00 2001 From: Edward Sun Date: Tue, 27 Apr 2021 08:02:58 -0700 Subject: [PATCH 1/3] Added ForeNew on labels --- mmv1/products/logging/api.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/mmv1/products/logging/api.yaml b/mmv1/products/logging/api.yaml index 49375dddf39a..d43d4af98da5 100644 --- a/mmv1/products/logging/api.yaml +++ b/mmv1/products/logging/api.yaml @@ -107,6 +107,7 @@ objects: for the HTTP response code, response_code, so you can look at latencies for successful responses or just for responses that failed. required: false + input: true item_type: !ruby/object:Api::Type::NestedObject properties: - !ruby/object:Api::Type::String From df5119e0842a81dbb04a45463a2cea48cc9c656d Mon Sep 17 00:00:00 2001 From: Edward Sun Date: Fri, 30 Apr 2021 16:20:30 -0700 Subject: [PATCH 2/3] set ForceNew on key & key_value --- mmv1/products/logging/api.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mmv1/products/logging/api.yaml b/mmv1/products/logging/api.yaml index d43d4af98da5..99b63447de58 100644 --- a/mmv1/products/logging/api.yaml +++ b/mmv1/products/logging/api.yaml @@ -107,7 +107,6 @@ objects: for the HTTP response code, response_code, so you can look at latencies for successful responses or just for responses that failed. required: false - input: true item_type: !ruby/object:Api::Type::NestedObject properties: - !ruby/object:Api::Type::String @@ -115,6 +114,7 @@ objects: description: | The label key. required: true + input: true - !ruby/object:Api::Type::String name: description description: | @@ -130,6 +130,7 @@ objects: - :STRING required: false default_value: :STRING + input: true - !ruby/object:Api::Type::String name: displayName description: | From 3002c3b376ecf72d3a8efc4b6c59773b03413674 Mon Sep 17 00:00:00 2001 From: Edward Sun Date: Sat, 1 May 2021 06:17:45 -0700 Subject: [PATCH 3/3] added a test --- .../tests/resource_logging_metric_test.go | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/mmv1/third_party/terraform/tests/resource_logging_metric_test.go b/mmv1/third_party/terraform/tests/resource_logging_metric_test.go index 5555291066cc..8281366c5c2b 100644 --- a/mmv1/third_party/terraform/tests/resource_logging_metric_test.go +++ b/mmv1/third_party/terraform/tests/resource_logging_metric_test.go @@ -62,6 +62,36 @@ func TestAccLoggingMetric_explicitBucket(t *testing.T) { }) } +func TestAccLoggingMetric_descriptionUpdated(t *testing.T) { + t.Parallel() + + suffix := randString(t, 10) + + vcrTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckLoggingMetricDestroyProducer(t), + Steps: []resource.TestStep{ + { + Config: testAccLoggingMetric_descriptionUpdated(suffix, "original"), + }, + { + ResourceName: "google_logging_metric.logging_metric", + ImportState: true, + ImportStateVerify: true, + }, + { + Config: testAccLoggingMetric_descriptionUpdated(suffix, "Updated"), + }, + { + 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" { @@ -97,3 +127,32 @@ resource "google_logging_metric" "logging_metric" { } `, suffix, filter) } + +func testAccLoggingMetric_descriptionUpdated(suffix, description string) string { + return fmt.Sprintf(` +resource "google_logging_metric" "logging_metric" { + name = "my-custom-metric-%s" + description = "Counter for VM instances that have hostError's" + filter = "resource.type=gce_instance AND protoPayload.methodName=compute.instances.hostError" + metric_descriptor { + metric_kind = "DELTA" + value_type = "INT64" + labels { + key = "instance" + value_type = "STRING" + description = "%s" + } + labels { + key = "zone" + value_type = "STRING" + description = "Availability zone of instance" + } + display_name = "VM Host Errors" + } + label_extractors = { + "instance" = "REGEXP_EXTRACT(protoPayload.resourceName, \"projects/.+/zones/.+/instances/(.+)\")" + "zone" = "EXTRACT(resource.labels.zone)" + } + } +`, suffix, description) +}