terraform-provider-googleworkspace
terraform-provider-googleworkspace copied to clipboard
Handle LABEL_REPEATED proto Label in type validation
When defining chrome policies and doing the field interpretation the label
proto field has the option of being returned as a LABEL_REPEATED
which requires the value to be an array of the defined type.
This PR fixes the validation function upon the label
being that LABEL_REPEATED
option as well as adds some more verbose erroring to call out specific values not complying with the spec.
An example chrome policy schema with hits this issue is the chrome.users.UrlBlocking
policy which has the following definition
"definition": {
"messageType": [
{
"field": [
{
"label": "LABEL_REPEATED",
"name": "urlBlocklist",
"number": 1,
"type": "TYPE_STRING"
},
{
"label": "LABEL_REPEATED",
"name": "urlAllowlist",
"number": 2,
"type": "TYPE_STRING"
}
],
"name": "UrlBlocking"
}
]
}
Allowing the following resource definitions to work
resource "googleworkspace_org_unit" "bleh" {
name = "bleh"
parent_org_unit_path = "/"
}
resource "googleworkspace_chrome_policy" "url_blocklist" {
org_unit_id = googleworkspace_org_unit.bleh.id
policies {
schema_name = "chrome.users.UrlBlocking"
schema_values = {
urlBlocklist = jsonencode([
"example.com",
"bleh.com"
])
}
}
}
This PR should be ready for review
Seems like unit test failure is a CI issue and unrelated to my change. https://github.com/hashicorp/terraform-provider-googleworkspace/runs/7200398697?check_suite_focus=true#step:5:17
@SarahFrench