Skip to content

Commit 02b402a

Browse files
committed
Add missing validations to org ruleset attributes
1 parent dc8953e commit 02b402a

1 file changed

Lines changed: 17 additions & 13 deletions

File tree

github/resource_github_organization_ruleset.go

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -237,10 +237,11 @@ func resourceGithubOrganizationRuleset() *schema.Resource {
237237
Description: "Whether the most recent reviewable push must be approved by someone other than the person who pushed it. Defaults to `false`.",
238238
},
239239
"required_approving_review_count": {
240-
Type: schema.TypeInt,
241-
Optional: true,
242-
Default: 0,
243-
Description: "The number of approving reviews that are required before a pull request can be merged. Defaults to `0`.",
240+
Type: schema.TypeInt,
241+
Optional: true,
242+
Default: 0,
243+
ValidateDiagFunc: validation.ToDiagFunc(validation.IntBetween(0, 10)),
244+
Description: "The number of approving reviews that are required before a pull request can be merged. Defaults to `0`.",
244245
},
245246
"required_review_thread_resolution": {
246247
Type: schema.TypeBool,
@@ -535,14 +536,16 @@ func resourceGithubOrganizationRuleset() *schema.Resource {
535536
Elem: &schema.Resource{
536537
Schema: map[string]*schema.Schema{
537538
"alerts_threshold": {
538-
Type: schema.TypeString,
539-
Required: true,
540-
Description: "The severity level at which code scanning results that raise alerts block a reference update. Can be one of: `none`, `errors`, `errors_and_warnings`, `all`.",
539+
Description: "The severity level at which code scanning results that raise alerts block a reference update. Can be one of: `none`, `errors`, `errors_and_warnings`, `all`.",
540+
Required: true,
541+
Type: schema.TypeString,
542+
ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"none", "errors", "errors_and_warnings", "all"}, false)),
541543
},
542544
"security_alerts_threshold": {
543-
Type: schema.TypeString,
544-
Required: true,
545-
Description: "The severity level at which code scanning results that raise security alerts block a reference update. Can be one of: `none`, `critical`, `high_or_higher`, `medium_or_higher`, `all`.",
545+
Description: "The severity level at which code scanning results that raise security alerts block a reference update. Can be one of: `none`, `critical`, `high_or_higher`, `medium_or_higher`, `all`.",
546+
Required: true,
547+
Type: schema.TypeString,
548+
ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"none", "critical", "high_or_higher", "medium_or_higher", "all"}, false)),
546549
},
547550
"tool": {
548551
Type: schema.TypeString,
@@ -598,9 +601,10 @@ func resourceGithubOrganizationRuleset() *schema.Resource {
598601
Elem: &schema.Resource{
599602
Schema: map[string]*schema.Schema{
600603
"max_file_path_length": {
601-
Type: schema.TypeInt,
602-
Required: true,
603-
Description: "The maximum allowed length of a file path.",
604+
Type: schema.TypeInt,
605+
Required: true,
606+
Description: "The maximum allowed length of a file path.",
607+
ValidateDiagFunc: validation.ToDiagFunc(validation.IntBetween(1, 32767)),
604608
},
605609
},
606610
},

0 commit comments

Comments
 (0)