Skip to content
This repository was archived by the owner on Jun 30, 2025. It is now read-only.

Handle LABEL_REPEATED proto Label in type validation - #336

Open
Yohan460 wants to merge 1 commit into
hashicorp:mainfrom
Yohan460:chrome_policy_arrays
Open

Handle LABEL_REPEATED proto Label in type validation#336
Yohan460 wants to merge 1 commit into
hashicorp:mainfrom
Yohan460:chrome_policy_arrays

Conversation

@Yohan460

Copy link
Copy Markdown

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"
        ])
   } 
  }
}

@Yohan460
Yohan460 force-pushed the chrome_policy_arrays branch from 986cb26 to 49ade44 Compare June 29, 2022 22:41
@Yohan460

Copy link
Copy Markdown
Author

This PR should be ready for review

@SarahFrench
SarahFrench requested review from SarahFrench and removed request for SarahFrench July 5, 2022 16:30
@Yohan460

Yohan460 commented Jul 5, 2022

Copy link
Copy Markdown
Author

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant