-
Notifications
You must be signed in to change notification settings - Fork 906
Fix required workflows for organization rulesets #2253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -472,6 +472,29 @@ func flattenRules(rules []*github.RepositoryRule, org bool) []interface{} { | |||||
| rule["required_check"] = requiredStatusChecksSlice | ||||||
| rule["strict_required_status_checks_policy"] = params.StrictRequiredStatusChecksPolicy | ||||||
| rulesMap[v.Type] = []map[string]interface{}{rule} | ||||||
|
|
||||||
| case "workflows": | ||||||
| var params github.RequiredWorkflowsRuleParameters | ||||||
| log.Printf("[DEBUG] osama test: %v", v.Parameters) | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you remove this before we merge? |
||||||
|
|
||||||
| err := json.Unmarshal(*v.Parameters, ¶ms) | ||||||
| if err != nil { | ||||||
| log.Printf("[INFO] Unexpected error unmarshalling rule %s with parameters: %v", | ||||||
| v.Type, v.Parameters) | ||||||
| } | ||||||
|
|
||||||
| requiredWorkflowsSlice := make([]map[string]interface{}, 0) | ||||||
| for _, workflow := range params.RequiredWorkflows { | ||||||
| requiredWorkflowsSlice = append(requiredWorkflowsSlice, map[string]interface{}{ | ||||||
| "repository_id": workflow.RepositoryID, | ||||||
| "ref": *workflow.Ref, | ||||||
| "path": workflow.Path, | ||||||
| }) | ||||||
| } | ||||||
|
|
||||||
| rule := make(map[string]interface{}) | ||||||
| rule["required_workflow"] = requiredWorkflowsSlice | ||||||
| rulesMap[v.Type] = []map[string]interface{}{rule} | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
you cannot use "v.Type" because it is named required_workflows in the scheme, not workflows. Look in my PR, I also add "do_not_enforce_on_create" to the scheme |
||||||
| } | ||||||
| } | ||||||
|
|
||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How might this behavior be unit tested?