Skip to content

Commit 9c785b1

Browse files
committed
1 parent 1c11053 commit 9c785b1

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

github/resource_github_repository_ruleset.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,18 +57,19 @@ func resourceGithubRepositoryRuleset() *schema.Resource {
5757
Schema: map[string]*schema.Schema{
5858
"actor_id": {
5959
Type: schema.TypeInt,
60-
Required: true,
60+
Optional: true,
61+
Default: nil,
6162
Description: "The ID of the actor that can bypass a ruleset. When `actor_type` is `OrganizationAdmin`, this should be set to `1`.",
6263
},
6364
"actor_type": {
64-
Type: schema.TypeString,
65-
Required: true,
66-
ValidateFunc: validation.StringInSlice([]string{"RepositoryRole", "Team", "Integration", "OrganizationAdmin"}, false),
67-
Description: "The type of actor that can bypass a ruleset. Can be one of: `RepositoryRole`, `Team`, `Integration`, `OrganizationAdmin`.",
65+
Type: schema.TypeString,
66+
Required: true,
67+
Description: "The type of actor that can bypass a ruleset. Can be one of: `RepositoryRole`, `Team`, `Integration`, `OrganizationAdmin`.",
6868
},
6969
"bypass_mode": {
7070
Type: schema.TypeString,
71-
Required: true,
71+
Optional: true,
72+
Default: "always",
7273
ValidateFunc: validation.StringInSlice([]string{"always", "pull_request"}, false),
7374
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`.",
7475
},

github/respository_rules_utils.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@ func expandBypassActors(input []interface{}) []*github.BypassActor {
4444
inputMap := v.(map[string]interface{})
4545
actor := &github.BypassActor{}
4646
if v, ok := inputMap["actor_id"].(int); ok {
47-
actor.ActorID = github.Int64(int64(v))
47+
if v == 0 {
48+
actor.ActorID = nil
49+
} else {
50+
actor.ActorID = github.Int64(int64(v))
51+
}
4852
}
4953

5054
if v, ok := inputMap["actor_type"].(string); ok {

0 commit comments

Comments
 (0)