Skip to content

Commit

Permalink
Resigning commits (hashicorp#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yohan460 authored Jul 28, 2022
1 parent 90698c4 commit b55be9e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
## 0.8.0 (Unreleased)

BUG FIXES:
* chrome: fixed a bug where when validating a `googleworkspace_chrome_policy` schema value the proto `LABEL_REPEATED` label was not being respected to require an array of the associated type ([#336](https://github.com/hashicorp/terraform-provider-googleworkspace/pull/336))

## 0.7.0 (June 10, 2022)

FEATURES:
Expand Down
33 changes: 27 additions & 6 deletions internal/provider/resource_chrome_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,13 +357,34 @@ func validateChromePolicies(ctx context.Context, d *schema.ResourceData, client
})
}

validType := validatePolicyFieldValueType(schemaField.Type, polVal)
if !validType {
return append(diags, diag.Diagnostic{
Summary: fmt.Sprintf("value provided for %s is of incorrect type (expected type: %s)", schemaField.Name, schemaField.Type),
Severity: diag.Error,
})
if schemaField.Label == "LABEL_REPEATED" {
polValType := reflect.ValueOf(polVal).Kind()
if !((polValType == reflect.Array) || (polValType == reflect.Slice)) {
return append(diags, diag.Diagnostic{
Summary: fmt.Sprintf("value provided for %s is of incorrect type %v (expected type: []%v)", schemaField.Name, polValType, schemaField.Type),
Severity: diag.Error,
})
} else {
if polValArray, ok := polVal.([]interface{}); ok {
for _, polValItem := range polValArray {
if !validatePolicyFieldValueType(schemaField.Type, polValItem) {
return append(diags, diag.Diagnostic{
Summary: fmt.Sprintf("array value %v provided for %s is of incorrect type (expected type: %s)", polValItem, schemaField.Name, schemaField.Type),
Severity: diag.Error,
})
}
}
}
}
} else {
if !validatePolicyFieldValueType(schemaField.Type, polVal) {
return append(diags, diag.Diagnostic{
Summary: fmt.Sprintf("value %v provided for %s is of incorrect type (expected type: %s)", polVal, schemaField.Name, schemaField.Type),
Severity: diag.Error,
})
}
}

}
}
}
Expand Down

0 comments on commit b55be9e

Please sign in to comment.