From 7575ea914b6e89ef0820bc3ca30397f5fb12c7e8 Mon Sep 17 00:00:00 2001 From: Edward Sun <42220489+edwardmedia@users.noreply.github.com> Date: Mon, 3 May 2021 13:34:22 -0700 Subject: [PATCH] Added ForceNew on labels (#4734) * Added ForeNew on labels * set ForceNew on key & key_value * added a test --- mmv1/products/logging/api.yaml | 2 + .../tests/resource_logging_metric_test.go | 59 +++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/mmv1/products/logging/api.yaml b/mmv1/products/logging/api.yaml index 49375dddf39a..99b63447de58 100644 --- a/mmv1/products/logging/api.yaml +++ b/mmv1/products/logging/api.yaml @@ -114,6 +114,7 @@ objects: description: | The label key. required: true + input: true - !ruby/object:Api::Type::String name: description description: | @@ -129,6 +130,7 @@ objects: - :STRING required: false default_value: :STRING + input: true - !ruby/object:Api::Type::String name: displayName description: | 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) +}