Skip to content

Commit 2d83c7b

Browse files
committed
feat: add ruleset option do_not_enforce_on_create
Optional attribute added to rules.required_status_checks.
1 parent 84c6bd2 commit 2d83c7b

File tree

4 files changed

+11
-0
lines changed

4 files changed

+11
-0
lines changed

github/resource_github_repository_ruleset.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,11 @@ func resourceGithubRepositoryRuleset() *schema.Resource {
244244
},
245245
},
246246
},
247+
"do_not_enforce_on_create": {
248+
Type: schema.TypeBool,
249+
Optional: true,
250+
Description: "Allow repositories and branches to be created if a check would otherwise prohibit it.",
251+
},
247252
"strict_required_status_checks_policy": {
248253
Type: schema.TypeBool,
249254
Optional: true,

github/resource_github_repository_ruleset_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ func TestGithubRepositoryRulesets(t *testing.T) {
6464
}
6565
6666
required_status_checks {
67+
do_not_enforce_on_create = true
6768
6869
required_check {
6970
context = "ci"
@@ -313,6 +314,7 @@ func TestGithubRepositoryRulesets(t *testing.T) {
313314
}
314315
315316
required_status_checks {
317+
do_not_enforce_on_create = true
316318
317319
required_check {
318320
context = "ci"

github/respository_rules_utils.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,7 @@ func expandRules(input []interface{}, org bool) []*github.RepositoryRule {
325325
}
326326

327327
params := &github.RequiredStatusChecksRuleParameters{
328+
DoNotEnforceOnCreate: requiredStatusMap["do_not_enforce_on_create"].(bool),
328329
RequiredStatusChecks: requiredStatusChecks,
329330
StrictRequiredStatusChecksPolicy: requiredStatusMap["strict_required_status_checks_policy"].(bool),
330331
}
@@ -501,6 +502,7 @@ func flattenRules(rules []*github.RepositoryRule, org bool) []interface{} {
501502
}
502503

503504
rule := make(map[string]interface{})
505+
rule["do_not_enforce_on_create"] = params.DoNotEnforceOnCreate
504506
rule["required_check"] = requiredStatusChecksSlice
505507
rule["strict_required_status_checks_policy"] = params.StrictRequiredStatusChecksPolicy
506508
rulesMap[v.Type] = []map[string]interface{}{rule}

website/docs/r/repository_ruleset.html.markdown

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

172172
#### rules.required_status_checks ####
173173

174+
* `do_not_enforce_on_create` - (Optional) (Boolean) Allow repositories and branches to be created if a check would otherwise prohibit it. Defaults to `false`.
175+
174176
* `required_check` - (Required) (Block Set, Min: 1) Status checks that are required. Several can be defined. (see [below for nested schema](#rules.required_status_checks.required_check))
175177

176178
* `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`.

0 commit comments

Comments
 (0)