Skip to content

Commit 5f9d9a5

Browse files
Merge branch 'main' into maintenance/add-attestation
2 parents 8ce6580 + a3b39ed commit 5f9d9a5

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

github/respository_rules_utils.go

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,10 @@ func expandConditions(input []any, org bool) *github.RulesetConditions {
144144
}
145145
}
146146

147-
protected := inputRepositoryName["protected"].(bool)
147+
protected, ok := inputRepositoryName["protected"].(bool)
148+
if !ok {
149+
protected = false
150+
}
148151

149152
rulesetConditions.RepositoryName = &github.RulesetRepositoryNamesConditionParameters{
150153
Include: include,
@@ -277,7 +280,10 @@ func expandRules(input []any, org bool) []*github.RepositoryRule {
277280
patternParametersMap := v[0].(map[string]any)
278281

279282
name := patternParametersMap["name"].(string)
280-
negate := patternParametersMap["negate"].(bool)
283+
negate, ok := patternParametersMap["negate"].(bool)
284+
if !ok {
285+
negate = false
286+
}
281287

282288
params := &github.RulePatternParameters{
283289
Name: &name,
@@ -355,10 +361,17 @@ func expandRules(input []any, org bool) []*github.RepositoryRule {
355361
}
356362
}
357363

358-
doNotEnforceOnCreate := requiredStatusMap["do_not_enforce_on_create"].(bool)
364+
doNotEnforceOnCreate, ok := requiredStatusMap["do_not_enforce_on_create"].(bool)
365+
if !ok {
366+
doNotEnforceOnCreate = false
367+
}
368+
strictRequiredStatusChecksPolicy, ok := requiredStatusMap["strict_required_status_checks_policy"].(bool)
369+
if !ok {
370+
strictRequiredStatusChecksPolicy = false
371+
}
359372
params := &github.RequiredStatusChecksRuleParameters{
360373
RequiredStatusChecks: requiredStatusChecks,
361-
StrictRequiredStatusChecksPolicy: requiredStatusMap["strict_required_status_checks_policy"].(bool),
374+
StrictRequiredStatusChecksPolicy: strictRequiredStatusChecksPolicy,
362375
DoNotEnforceOnCreate: &doNotEnforceOnCreate,
363376
}
364377
rulesSlice = append(rulesSlice, github.NewRequiredStatusChecksRule(params))
@@ -389,8 +402,13 @@ func expandRules(input []any, org bool) []*github.RepositoryRule {
389402
}
390403
}
391404

405+
doNotEnforceOnCreate, ok := requiredWorkflowsMap["do_not_enforce_on_create"].(bool)
406+
if !ok {
407+
doNotEnforceOnCreate = false
408+
}
409+
392410
params := &github.RequiredWorkflowsRuleParameters{
393-
DoNotEnforceOnCreate: requiredWorkflowsMap["do_not_enforce_on_create"].(bool),
411+
DoNotEnforceOnCreate: doNotEnforceOnCreate,
394412
RequiredWorkflows: requiredWorkflows,
395413
}
396414
rulesSlice = append(rulesSlice, github.NewRequiredWorkflowsRule(params))

0 commit comments

Comments
 (0)