Skip to content

Commit cd804ee

Browse files
Make description and displayName optional and mutable (#14328) (#10233)
[upstream:7bdafeba3bff309fc04f21411f691387330b007d] Signed-off-by: Modular Magician <[email protected]>
1 parent 2a5a7c8 commit cd804ee

File tree

4 files changed

+57
-27
lines changed

4 files changed

+57
-27
lines changed

.changelog/14328.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:bug
2+
monitoring: made `description` and `displayName` optional and mutable in `google_monitoring_metric_descriptor`
3+
```

google-beta/services/monitoring/resource_monitoring_metric_descriptor.go

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,6 @@ func ResourceMonitoringMetricDescriptor() *schema.Resource {
5656
),
5757

5858
Schema: map[string]*schema.Schema{
59-
"description": {
60-
Type: schema.TypeString,
61-
Required: true,
62-
ForceNew: true,
63-
Description: `A detailed description of the metric, which can be used in documentation.`,
64-
},
65-
"display_name": {
66-
Type: schema.TypeString,
67-
Required: true,
68-
ForceNew: true,
69-
Description: `A concise name for the metric, which can be displayed in user interfaces. Use sentence case without an ending period, for example "Request count".`,
70-
},
7159
"metric_kind": {
7260
Type: schema.TypeString,
7361
Required: true,
@@ -88,6 +76,16 @@ func ResourceMonitoringMetricDescriptor() *schema.Resource {
8876
ValidateFunc: verify.ValidateEnum([]string{"BOOL", "INT64", "DOUBLE", "STRING", "DISTRIBUTION"}),
8977
Description: `Whether the measurement is an integer, a floating-point number, etc. Some combinations of metricKind and valueType might not be supported. Possible values: ["BOOL", "INT64", "DOUBLE", "STRING", "DISTRIBUTION"]`,
9078
},
79+
"description": {
80+
Type: schema.TypeString,
81+
Optional: true,
82+
Description: `A detailed description of the metric, which can be used in documentation.`,
83+
},
84+
"display_name": {
85+
Type: schema.TypeString,
86+
Optional: true,
87+
Description: `A concise name for the metric, which can be displayed in user interfaces. Use sentence case without an ending period, for example "Request count".`,
88+
},
9189
"labels": {
9290
Type: schema.TypeSet,
9391
Optional: true,
@@ -128,7 +126,6 @@ func ResourceMonitoringMetricDescriptor() *schema.Resource {
128126
"unit": {
129127
Type: schema.TypeString,
130128
Optional: true,
131-
ForceNew: true,
132129
Description: `The units in which the metric value is reported. It is only applicable if the
133130
valueType is INT64, DOUBLE, or DISTRIBUTION. The unit defines the representation of
134131
the stored metric values.

google-beta/services/monitoring/resource_monitoring_metric_descriptor_test.go

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func TestAccMonitoringMetricDescriptor_update(t *testing.T) {
3333
CheckDestroy: testAccCheckMonitoringMetricDescriptorDestroyProducer(t),
3434
Steps: []resource.TestStep{
3535
{
36-
Config: testAccMonitoringMetricDescriptor_update("30s", "30s"),
36+
Config: testAccMonitoringMetricDescriptor_update("initial description", "initial display name", "30s", "30s"),
3737
},
3838
{
3939
ResourceName: "google_monitoring_metric_descriptor.basic",
@@ -42,23 +42,32 @@ func TestAccMonitoringMetricDescriptor_update(t *testing.T) {
4242
ImportStateVerifyIgnore: []string{"metadata", "launch_stage"},
4343
},
4444
{
45-
Config: testAccMonitoringMetricDescriptor_update("60s", "60s"),
45+
Config: testAccMonitoringMetricDescriptor_update("updated description", "updated display name", "60s", "60s"),
4646
},
4747
{
4848
ResourceName: "google_monitoring_metric_descriptor.basic",
4949
ImportState: true,
5050
ImportStateVerify: true,
5151
ImportStateVerifyIgnore: []string{"metadata", "launch_stage"},
5252
},
53+
{
54+
Config: testAccMonitoringMetricDescriptor_omittedFields(),
55+
},
56+
{
57+
ResourceName: "google_monitoring_metric_descriptor.basic",
58+
ImportState: true,
59+
ImportStateVerify: true,
60+
ImportStateVerifyIgnore: []string{"metadata", "launch_stage", "description", "display_name"},
61+
},
5362
},
5463
})
5564
}
5665

57-
func testAccMonitoringMetricDescriptor_update(samplePeriod, ingestDelay string) string {
66+
func testAccMonitoringMetricDescriptor_update(description, displayName, samplePeriod, ingestDelay string) string {
5867
return fmt.Sprintf(`
5968
resource "google_monitoring_metric_descriptor" "basic" {
60-
description = "Daily sales records from all branch stores."
61-
display_name = "daily sales"
69+
description = "%s"
70+
display_name = "%s"
6271
type = "custom.googleapis.com/stores/daily_sales"
6372
metric_kind = "GAUGE"
6473
value_type = "DOUBLE"
@@ -74,6 +83,27 @@ resource "google_monitoring_metric_descriptor" "basic" {
7483
ingest_delay = "%s"
7584
}
7685
}
77-
`, samplePeriod, ingestDelay,
86+
`, description, displayName, samplePeriod, ingestDelay,
7887
)
7988
}
89+
90+
func testAccMonitoringMetricDescriptor_omittedFields() string {
91+
return `
92+
resource "google_monitoring_metric_descriptor" "basic" {
93+
type = "custom.googleapis.com/stores/daily_sales"
94+
metric_kind = "GAUGE"
95+
value_type = "DOUBLE"
96+
unit = "{USD}"
97+
labels {
98+
key = "key"
99+
value_type = "STRING"
100+
description = "description"
101+
}
102+
launch_stage = "BETA"
103+
metadata {
104+
sample_period = "30s"
105+
ingest_delay = "30s"
106+
}
107+
}
108+
`
109+
}

website/docs/r/monitoring_metric_descriptor.html.markdown

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,6 @@ The following arguments are supported:
109109
Whether the measurement is an integer, a floating-point number, etc. Some combinations of metricKind and valueType might not be supported.
110110
Possible values are: `BOOL`, `INT64`, `DOUBLE`, `STRING`, `DISTRIBUTION`.
111111

112-
* `description` -
113-
(Required)
114-
A detailed description of the metric, which can be used in documentation.
115-
116-
* `display_name` -
117-
(Required)
118-
A concise name for the metric, which can be displayed in user interfaces. Use sentence case without an ending period, for example "Request count".
119-
120112

121113
- - -
122114

@@ -146,6 +138,14 @@ The following arguments are supported:
146138
More info can be found in the API documentation
147139
(https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.metricDescriptors).
148140

141+
* `description` -
142+
(Optional)
143+
A detailed description of the metric, which can be used in documentation.
144+
145+
* `display_name` -
146+
(Optional)
147+
A concise name for the metric, which can be displayed in user interfaces. Use sentence case without an ending period, for example "Request count".
148+
149149
* `metadata` -
150150
(Optional)
151151
Metadata which can be used to guide usage of the metric.

0 commit comments

Comments
 (0)