Skip to content

Commit

Permalink
add matcher attribute to contentmatchers (#3607) (#6558)
Browse files Browse the repository at this point in the history
* add matcher attribute to contentmatcher

* removed the required field as its mandatory

* tab removed and used spaces

Signed-off-by: Modular Magician <magic-modules@google.com>
  • Loading branch information
modular-magician committed Jun 9, 2020
1 parent 01103b6 commit 8ac6f38
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .changelog/3607.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
```release-note:enhancement
monitoring: added `matcher` attribute to `content_matchers` block for
`google_monitoring_uptime_check_config`
```
22 changes: 22 additions & 0 deletions google/resource_monitoring_uptime_check_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ func resourceMonitoringUptimeCheckConfig() *schema.Resource {
Required: true,
Description: `String or regex content to match (max 1024 bytes)`,
},
"matcher": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{"CONTAINS_STRING", "NOT_CONTAINS_STRING", "MATCHES_REGEX", "NON_MATCHES_REGEX", ""}, false),
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"]`,
},
},
},
},
Expand Down Expand Up @@ -629,6 +635,7 @@ func flattenMonitoringUptimeCheckConfigContentMatchers(v interface{}, d *schema.
}
transformed = append(transformed, map[string]interface{}{
"content": flattenMonitoringUptimeCheckConfigContentMatchersContent(original["content"], d, config),
"matcher": flattenMonitoringUptimeCheckConfigContentMatchersMatcher(original["matcher"], d, config),
})
}
return transformed
Expand All @@ -637,6 +644,10 @@ func flattenMonitoringUptimeCheckConfigContentMatchersContent(v interface{}, d *
return v
}

func flattenMonitoringUptimeCheckConfigContentMatchersMatcher(v interface{}, d *schema.ResourceData, config *Config) interface{} {
return v
}

func flattenMonitoringUptimeCheckConfigSelectedRegions(v interface{}, d *schema.ResourceData, config *Config) interface{} {
return v
}
Expand Down Expand Up @@ -832,6 +843,13 @@ func expandMonitoringUptimeCheckConfigContentMatchers(v interface{}, d Terraform
transformed["content"] = transformedContent
}

transformedMatcher, err := expandMonitoringUptimeCheckConfigContentMatchersMatcher(original["matcher"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedMatcher); val.IsValid() && !isEmptyValue(val) {
transformed["matcher"] = transformedMatcher
}

req = append(req, transformed)
}
return req, nil
Expand All @@ -841,6 +859,10 @@ func expandMonitoringUptimeCheckConfigContentMatchersContent(v interface{}, d Te
return v, nil
}

func expandMonitoringUptimeCheckConfigContentMatchersMatcher(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
return v, nil
}

func expandMonitoringUptimeCheckConfigSelectedRegions(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
return v, nil
}
Expand Down
1 change: 1 addition & 0 deletions google/resource_monitoring_uptime_check_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ resource "google_monitoring_uptime_check_config" "http" {
content_matchers {
content = "example"
matcher = "CONTAINS_STRING"
}
}
`, suffix, path, project, pwd, host,
Expand Down
10 changes: 10 additions & 0 deletions website/docs/r/monitoring_uptime_check_config.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,16 @@ The `content_matchers` block supports:
(Required)
String or regex content to match (max 1024 bytes)

* `matcher` -
(Optional)
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 are:
* `CONTAINS_STRING`
* `NOT_CONTAINS_STRING`
* `MATCHES_REGEX`
* `NON_MATCHES_REGEX`

The `http_check` block supports:

* `auth_info` -
Expand Down

0 comments on commit 8ac6f38

Please sign in to comment.