Skip to content

Commit 9836813

Browse files
add matcher attribute to contentmatchers (#3607) (#2150)
* add matcher attribute to contentmatcher * removed the required field as its mandatory * tab removed and used spaces Signed-off-by: Modular Magician <[email protected]>
1 parent 2a9c4ed commit 9836813

File tree

4 files changed

+37
-0
lines changed

4 files changed

+37
-0
lines changed

.changelog/3607.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
```release-note:enhancement
2+
monitoring: added `matcher` attribute to `content_matchers` block for
3+
`google_monitoring_uptime_check_config`
4+
```

google-beta/resource_monitoring_uptime_check_config.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@ func resourceMonitoringUptimeCheckConfig() *schema.Resource {
6565
Required: true,
6666
Description: `String or regex content to match (max 1024 bytes)`,
6767
},
68+
"matcher": {
69+
Type: schema.TypeString,
70+
Optional: true,
71+
ValidateFunc: validation.StringInSlice([]string{"CONTAINS_STRING", "NOT_CONTAINS_STRING", "MATCHES_REGEX", "NON_MATCHES_REGEX", ""}, false),
72+
Description: `The type of content matcher that will be applied to the server output, compared to the content string when the check is run. Possible values: ["CONTAINS_STRING", "NOT_CONTAINS_STRING", "MATCHES_REGEX", "NON_MATCHES_REGEX"]`,
73+
},
6874
},
6975
},
7076
},
@@ -629,6 +635,7 @@ func flattenMonitoringUptimeCheckConfigContentMatchers(v interface{}, d *schema.
629635
}
630636
transformed = append(transformed, map[string]interface{}{
631637
"content": flattenMonitoringUptimeCheckConfigContentMatchersContent(original["content"], d, config),
638+
"matcher": flattenMonitoringUptimeCheckConfigContentMatchersMatcher(original["matcher"], d, config),
632639
})
633640
}
634641
return transformed
@@ -637,6 +644,10 @@ func flattenMonitoringUptimeCheckConfigContentMatchersContent(v interface{}, d *
637644
return v
638645
}
639646

647+
func flattenMonitoringUptimeCheckConfigContentMatchersMatcher(v interface{}, d *schema.ResourceData, config *Config) interface{} {
648+
return v
649+
}
650+
640651
func flattenMonitoringUptimeCheckConfigSelectedRegions(v interface{}, d *schema.ResourceData, config *Config) interface{} {
641652
return v
642653
}
@@ -832,6 +843,13 @@ func expandMonitoringUptimeCheckConfigContentMatchers(v interface{}, d Terraform
832843
transformed["content"] = transformedContent
833844
}
834845

846+
transformedMatcher, err := expandMonitoringUptimeCheckConfigContentMatchersMatcher(original["matcher"], d, config)
847+
if err != nil {
848+
return nil, err
849+
} else if val := reflect.ValueOf(transformedMatcher); val.IsValid() && !isEmptyValue(val) {
850+
transformed["matcher"] = transformedMatcher
851+
}
852+
835853
req = append(req, transformed)
836854
}
837855
return req, nil
@@ -841,6 +859,10 @@ func expandMonitoringUptimeCheckConfigContentMatchersContent(v interface{}, d Te
841859
return v, nil
842860
}
843861

862+
func expandMonitoringUptimeCheckConfigContentMatchersMatcher(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
863+
return v, nil
864+
}
865+
844866
func expandMonitoringUptimeCheckConfigSelectedRegions(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
845867
return v, nil
846868
}

google-beta/resource_monitoring_uptime_check_config_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ resource "google_monitoring_uptime_check_config" "http" {
106106
107107
content_matchers {
108108
content = "example"
109+
matcher = "CONTAINS_STRING"
109110
}
110111
}
111112
`, suffix, path, project, pwd, host,

website/docs/r/monitoring_uptime_check_config.html.markdown

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,16 @@ The `content_matchers` block supports:
182182
(Required)
183183
String or regex content to match (max 1024 bytes)
184184

185+
* `matcher` -
186+
(Optional)
187+
The type of content matcher that will be applied to the server output, compared to the content string when the check is run.
188+
189+
Possible values are:
190+
* `CONTAINS_STRING`
191+
* `NOT_CONTAINS_STRING`
192+
* `MATCHES_REGEX`
193+
* `NON_MATCHES_REGEX`
194+
185195
The `http_check` block supports:
186196

187197
* `auth_info` -

0 commit comments

Comments
 (0)