-
Notifications
You must be signed in to change notification settings - Fork 741
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
feat: Add GitHub Organization Custom Role Resource and Data Source #1700
Conversation
This commit adds a new Terraform resource for creating, reading, updating and deleting GitHub organization custom roles. The `resourceGithubOrganizationCustomRole` function is added to the `github/provider.go` file. The function creates a new schema with four fields: name, base_role, permissions and description. It also includes functions for create, read, update and delete operations on the resource. A new data source is also added in this commit that allows users to query an existing custom repository role by its name. The `dataSourceGithubOrganizationCustomRole` function is added to the `github/data_source_github_organization_custom_role.go` file. Finally, a test case is included in the `github/data_source_github_organization_custom_role_test.go` file that tests querying of an existing custom repository role using the newly created data source.
…om Role This commit updates the formatting of the test and resource files for Github Organization Custom Role. It also removes the ForceNew attribute from one of the required fields in the resource file and updates the tests to reflect it.
This commit fixes the arguments for creating an organization custom role.
Updates to the documentation to reflect this change.
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.
Confirming that the added integration tests are passing for me. Thank you for contributing!
Sorry about the delay here; this slipped through the cracks for me somehow. I'll get this merged and released soon! |
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [github](https://registry.terraform.io/providers/integrations/github) ([source](https://togithub.com/integrations/terraform-provider-github)) | required_provider | minor | `5.28.1` -> `5.29.0` | --- ### Release Notes <details> <summary>integrations/terraform-provider-github (github)</summary> ### [`v5.29.0`](https://togithub.com/integrations/terraform-provider-github/releases/tag/v5.29.0) [Compare Source](https://togithub.com/integrations/terraform-provider-github/compare/v5.28.1...v5.29.0) #### What's Changed - fix: support team slug in github_team_membership by [@​kristian-lesko](https://togithub.com/kristian-lesko) in [https://github.com/integrations/terraform-provider-github/pull/1751](https://togithub.com/integrations/terraform-provider-github/pull/1751) - Fixes accidental deletion of Repository resource from state by [@​t0yv0](https://togithub.com/t0yv0) in [https://github.com/integrations/terraform-provider-github/pull/1750](https://togithub.com/integrations/terraform-provider-github/pull/1750) - feat: Add GitHub Organization Custom Role Resource and Data Source by [@​cailen](https://togithub.com/cailen) in [https://github.com/integrations/terraform-provider-github/pull/1700](https://togithub.com/integrations/terraform-provider-github/pull/1700) - Fix typo in deployment branch policy import by [@​bpaquet](https://togithub.com/bpaquet) in [https://github.com/integrations/terraform-provider-github/pull/1758](https://togithub.com/integrations/terraform-provider-github/pull/1758) - Fix `resourceGithubDependabotOrganizationSecretCreateOrUpdate` by [@​frankywahl](https://togithub.com/frankywahl) in [https://github.com/integrations/terraform-provider-github/pull/1759](https://togithub.com/integrations/terraform-provider-github/pull/1759) - \[Bug]: Renaming github_repository doesn't taint full_name attribute by [@​KenSpur](https://togithub.com/KenSpur) in [https://github.com/integrations/terraform-provider-github/pull/1756](https://togithub.com/integrations/terraform-provider-github/pull/1756) - feat: Ability to Manage Codespaces Secrets by [@​KenSpur](https://togithub.com/KenSpur) in [https://github.com/integrations/terraform-provider-github/pull/1729](https://togithub.com/integrations/terraform-provider-github/pull/1729) #### New Contributors - [@​kristian-lesko](https://togithub.com/kristian-lesko) made their first contribution in [https://github.com/integrations/terraform-provider-github/pull/1751](https://togithub.com/integrations/terraform-provider-github/pull/1751) - [@​t0yv0](https://togithub.com/t0yv0) made their first contribution in [https://github.com/integrations/terraform-provider-github/pull/1750](https://togithub.com/integrations/terraform-provider-github/pull/1750) - [@​cailen](https://togithub.com/cailen) made their first contribution in [https://github.com/integrations/terraform-provider-github/pull/1700](https://togithub.com/integrations/terraform-provider-github/pull/1700) - [@​frankywahl](https://togithub.com/frankywahl) made their first contribution in [https://github.com/integrations/terraform-provider-github/pull/1759](https://togithub.com/integrations/terraform-provider-github/pull/1759) - [@​KenSpur](https://togithub.com/KenSpur) made their first contribution in [https://github.com/integrations/terraform-provider-github/pull/1756](https://togithub.com/integrations/terraform-provider-github/pull/1756) **Full Changelog**: integrations/terraform-provider-github@v5.28.1...v5.29.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://togithub.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNS4xNDQuMCIsInVwZGF0ZWRJblZlciI6IjM1LjE0NC4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9--> Co-authored-by: greyrock-bot <1583719+greyrock-bot[bot]@users.noreply.github.com>
Type: schema.TypeSet, | ||
Required: true, | ||
Elem: &schema.Schema{Type: schema.TypeString}, | ||
MinItems: 1, // At least one permission should be passed. |
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.
Sorry to comment on an old/merged PR, but is this a necessary constraint? The API permits creation of a repository role without additional permissions, and it makes perfect sense if the role's only purpose is to designate who can bypass a repository ruleset, for example:
gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/orgs/$ORG/custom-repository-roles \
-f name='rule-breaker' \
-f description='Can bypass repository rulesets' \
-f base_role='read' \
-f "permissions[]"
If you can confirm, shall I open another issue (or PR) to correct this? Thanks!
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.
I believe you may be right about this. I was however unable to get it to post to the API at the time, so I was thinking it did require something, but I may have just passed in the wrong blank value.
…ntegrations#1700) * feat: Add GitHub organization custom role resource This commit adds a new Terraform resource for creating, reading, updating and deleting GitHub organization custom roles. The `resourceGithubOrganizationCustomRole` function is added to the `github/provider.go` file. The function creates a new schema with four fields: name, base_role, permissions and description. It also includes functions for create, read, update and delete operations on the resource. A new data source is also added in this commit that allows users to query an existing custom repository role by its name. The `dataSourceGithubOrganizationCustomRole` function is added to the `github/data_source_github_organization_custom_role.go` file. Finally, a test case is included in the `github/data_source_github_organization_custom_role_test.go` file that tests querying of an existing custom repository role using the newly created data source. * refactor: Update test and resource files for Github Organization Custom Role This commit updates the formatting of the test and resource files for Github Organization Custom Role. It also removes the ForceNew attribute from one of the required fields in the resource file and updates the tests to reflect it. * docs: Fix arguments for organization custom role This commit fixes the arguments for creating an organization custom role. * docs: Update documentation with organization_custom_role Updates to the documentation to reflect this change. * docs: Fix errant parenthesis * Fix bad merge --------- Co-authored-by: Keegan Campbell <me@kfcampbell.com>
Resolves #1069
Behavior
Before the change?
After the change?
Other information
N/A
Additional info
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)
Added the appropriate label for the given change
Does this introduce a breaking change?
I do not believe so.
Please see our docs on breaking changes to help!
Type: Breaking change
label)If
Yes
, what's the impact:Pull request type
Type: Feature
Type: Documentation