Skip to content

Conversation

@o-sama
Copy link
Contributor

@o-sama o-sama commented May 4, 2024

Resolves #2113


Before the change?

  • When you apply the Terraform plan, you have the following: "required_workflows": [] in state. This happens because there was no code that flattens this specific rule.

After the change?

  • Added the required code to flatten this rule when flattening the ruleset's rules. When you apply the Terraform plan, you have the following in state if successful:
                "required_workflows": [
                  {
                    "required_workflow": [
                      {
                        "path": "<PATH>",
                        "ref": "<REF>",
                        "repository_id": <REPO_ID>
                      }
                    ]
                  }
                ]

Pull request checklist

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)

Does this introduce a breaking change?

Please see our docs on breaking changes to help!

  • Yes
  • No


case "workflows":
var params github.RequiredWorkflowsRuleParameters
log.Printf("[DEBUG] osama test: %v", v.Parameters)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove this before we merge?

rule["strict_required_status_checks_policy"] = params.StrictRequiredStatusChecksPolicy
rulesMap[v.Type] = []map[string]interface{}{rule}

case "workflows":
Copy link
Contributor

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?

@ihor-hrytskiv
Copy link
Contributor

I do the same in my PR and also fix required_code_scanning


rule := make(map[string]interface{})
rule["required_workflow"] = requiredWorkflowsSlice
rulesMap[v.Type] = []map[string]interface{}{rule}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
rulesMap[v.Type] = []map[string]interface{}{rule}
rulesMap["required_workflows"] = []map[string]interface{}{rule}

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

@github-actions
Copy link

👋 Hey Friends, this pull request has been automatically marked as stale because it has no recent activity. It will be closed if no further activity occurs. Please add the Status: Pinned label if you feel that this issue needs to remain open/active. Thank you for your contributions and help in keeping things tidy!

@github-actions github-actions bot added the Status: Stale Used by stalebot to clean house label Aug 31, 2025
@github-actions github-actions bot closed this Sep 8, 2025
@github-project-automation github-project-automation bot moved this from 👀 In review to ✅ Done in 🧰 Octokit Active Sep 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Status: Stale Used by stalebot to clean house

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: Resource github_organization_ruleset knows nothing about attribute required_workflows after creation of the Rule(s)

3 participants