Skip to content

Commit 4b77944

Browse files
Adds do_not_enforce_on_create option for github_repository_ruleset (#2525)
Co-authored-by: Keegan Campbell <me@kfcampbell.com>
1 parent dead927 commit 4b77944

File tree

4 files changed

+13
-0
lines changed

4 files changed

+13
-0
lines changed

github/resource_github_repository_ruleset.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,12 @@ func resourceGithubRepositoryRuleset() *schema.Resource {
249249
Optional: true,
250250
Description: "Whether pull requests targeting a matching branch must be tested with the latest code. This setting will not take effect unless at least one status check is enabled. Defaults to `false`.",
251251
},
252+
"do_not_enforce_on_create": {
253+
Type: schema.TypeBool,
254+
Optional: true,
255+
Description: "Allow repositories and branches to be created if a check would otherwise prohibit it.",
256+
Default: false,
257+
},
252258
},
253259
},
254260
},

github/resource_github_repository_ruleset_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ func TestGithubRepositoryRulesets(t *testing.T) {
7070
}
7171
7272
strict_required_status_checks_policy = true
73+
do_not_enforce_on_create = true
7374
}
7475
7576
non_fast_forward = true
@@ -319,6 +320,7 @@ func TestGithubRepositoryRulesets(t *testing.T) {
319320
}
320321
321322
strict_required_status_checks_policy = true
323+
do_not_enforce_on_create = true
322324
}
323325
324326
non_fast_forward = true

github/respository_rules_utils.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,9 +324,11 @@ func expandRules(input []interface{}, org bool) []*github.RepositoryRule {
324324
}
325325
}
326326

327+
doNotEnforceOnCreate := requiredStatusMap["do_not_enforce_on_create"].(bool)
327328
params := &github.RequiredStatusChecksRuleParameters{
328329
RequiredStatusChecks: requiredStatusChecks,
329330
StrictRequiredStatusChecksPolicy: requiredStatusMap["strict_required_status_checks_policy"].(bool),
331+
DoNotEnforceOnCreate: &doNotEnforceOnCreate,
330332
}
331333
rulesSlice = append(rulesSlice, github.NewRequiredStatusChecksRule(params))
332334
}
@@ -503,6 +505,7 @@ func flattenRules(rules []*github.RepositoryRule, org bool) []interface{} {
503505
rule := make(map[string]interface{})
504506
rule["required_check"] = requiredStatusChecksSlice
505507
rule["strict_required_status_checks_policy"] = params.StrictRequiredStatusChecksPolicy
508+
rule["do_not_enforce_on_create"] = params.DoNotEnforceOnCreate
506509
rulesMap[v.Type] = []map[string]interface{}{rule}
507510
}
508511
}

website/docs/r/repository_ruleset.html.markdown

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,8 @@ The `rules` block supports the following:
175175

176176
* `strict_required_status_checks_policy` - (Optional) (Boolean) Whether pull requests targeting a matching branch must be tested with the latest code. This setting will not take effect unless at least one status check is enabled. Defaults to `false`.
177177

178+
* `do_not_enforce_on_create` - (Optional) (Boolean) Allow repositories and branches to be created if a check would otherwise prohibit it. Defaults to `false`.
179+
178180
#### rules.required_status_checks.required_check ####
179181

180182
* `context` - (Required) (String) The status check context name that must be present on the commit.

0 commit comments

Comments
 (0)