Skip to content

Commit

Permalink
Added ForceNew on labels (#4734)
Browse files Browse the repository at this point in the history
* Added ForeNew on labels

* set ForceNew on key & key_value

* added a test
  • Loading branch information
edwardmedia authored May 3, 2021
1 parent 8319a65 commit 7575ea9
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
2 changes: 2 additions & 0 deletions mmv1/products/logging/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ objects:
description: |
The label key.
required: true
input: true
- !ruby/object:Api::Type::String
name: description
description: |
Expand All @@ -129,6 +130,7 @@ objects:
- :STRING
required: false
default_value: :STRING
input: true
- !ruby/object:Api::Type::String
name: displayName
description: |
Expand Down
59 changes: 59 additions & 0 deletions mmv1/third_party/terraform/tests/resource_logging_metric_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down Expand Up @@ -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)
}

0 comments on commit 7575ea9

Please sign in to comment.