Skip to content

Commit e31eb8f

Browse files
committed
refactor(enterprise_ruleset): update validation functions to use ValidateDiagFunc for improved error handling
1 parent 3ac4706 commit e31eb8f

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

github/resource_github_enterprise_ruleset.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func resourceGithubEnterpriseRuleset() *schema.Resource {
3939
"name": {
4040
Type: schema.TypeString,
4141
Required: true,
42-
ValidateFunc: validation.StringLenBetween(1, 100),
42+
ValidateDiagFunc: validation.ToDiagFunc(validation.StringLenBetween(1, 100)),
4343
Description: "The name of the ruleset.",
4444
},
4545
"target": {
@@ -51,7 +51,7 @@ func resourceGithubEnterpriseRuleset() *schema.Resource {
5151
"enforcement": {
5252
Type: schema.TypeString,
5353
Required: true,
54-
ValidateFunc: validation.StringInSlice([]string{"disabled", "active", "evaluate"}, false),
54+
ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"disabled", "active", "evaluate"}, false)),
5555
Description: "Possible values for Enforcement are `disabled`, `active`, `evaluate`. Note: `evaluate` is currently only supported for owners of type `organization`.",
5656
},
5757
"bypass_actors": {
@@ -70,13 +70,13 @@ func resourceGithubEnterpriseRuleset() *schema.Resource {
7070
"actor_type": {
7171
Type: schema.TypeString,
7272
Required: true,
73-
ValidateFunc: validation.StringInSlice([]string{"Integration", "OrganizationAdmin", "RepositoryRole", "Team", "DeployKey", "EnterpriseOwner"}, false),
73+
ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"Integration", "OrganizationAdmin", "RepositoryRole", "Team", "DeployKey", "EnterpriseOwner"}, false)),
7474
Description: "The type of actor that can bypass a ruleset. See https://docs.github.com/en/rest/enterprise-admin/rules for more information",
7575
},
7676
"bypass_mode": {
7777
Type: schema.TypeString,
7878
Required: true,
79-
ValidateFunc: validation.StringInSlice([]string{"always", "pull_request", "exempt"}, false),
79+
ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"always", "pull_request", "exempt"}, false)),
8080
Description: "When the specified actor can bypass the ruleset. pull_request means that an actor can only bypass rules on pull requests. Can be one of: `always`, `pull_request`, `exempt`.",
8181
},
8282
},

0 commit comments

Comments
 (0)