Skip to content
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

Add github_organization_block resource #181

Merged
merged 9 commits into from
May 2, 2019
Merged

Add github_organization_block resource #181

merged 9 commits into from
May 2, 2019

Conversation

paultyng
Copy link
Contributor

@paultyng paultyng commented Jan 30, 2019

Fixes #179, #185, #89
Supersedes #215, #211, #207, #186, #160

@ghost ghost added the size/XXL label Jan 30, 2019
@paultyng paultyng requested a review from radeksimko January 30, 2019 20:50
@paultyng
Copy link
Contributor Author

This is based on the v0.12 upgrade branch.

@paultyng paultyng changed the base branch from radeksimko/v0.12-upgrade to master April 25, 2019 17:26
@paultyng paultyng requested review from a team and removed request for radeksimko April 25, 2019 17:27
@paultyng

This comment has been minimized.

paultyng added 3 commits May 2, 2019 15:43
Breaking changes to schema in this commit include:

* github_organization_webhook.name removed
* github_repository_webhook.name removed
@paultyng paultyng force-pushed the paultyng/blocks branch from 3939306 to 7d4f660 Compare May 2, 2019 20:43
@paultyng

This comment has been minimized.

@paultyng
Copy link
Contributor Author

paultyng commented May 2, 2019

@bltavares I've included a number of your fixes in here as well, tests are all green. I had to go to v25 due to a bug in the organization hook calls.

Copy link

@mbfrahry mbfrahry left a comment

Choose a reason for hiding this comment

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

LGTM with some minor changes

github/resource_github_repository_webhook.go Show resolved Hide resolved
github/resource_organization_block.go Show resolved Hide resolved
paultyng and others added 5 commits May 2, 2019 17:38
After bumping to go-github v24, a couple of signatures have changed.

One of them, the `name` on `webhooks` has been removed. Previously, the
only valid name was `web`, and now, it has been removed from the object.

This commit is a breaking change on the provider, as it will not accept
more taking `name` on the webhook resources.
This commit includes the `required_approving_review_count` field on the
`github_branch_protection` resource, allowing to manage the miminum
amount of reviewers to allow a merge to happen.

This field must be between 1 - 6, according to the docs, and must be
valid if present.

Bumping the `go-github` to `v24` made it default to `0` when not
present, causing the followin error

<detail>
<summary>GitHub API error when count is 0</summary>

```
422 Invalid request.

No subschema in "anyOf" matched.
0 must be greater than or equal to 1.
Not all subschemas of "allOf" matched.
For 'anyOf/1', {"dismissal_restrictions"=>{"users"=>[], "teams"=>[]}, "dismiss_stale_reviews"=>false, "require_code_owner_reviews"=>true, "required_approving_review_count"=>0} is not a null. []

Payload:
{
 "required_status_checks": {
  "strict": true,
  "contexts": [
   "lint",
   "test"
  ]
 },
 "required_pull_request_reviews": {
  "dismissal_restrictions": {
   "users": [],
   "teams": []
  },
  "dismiss_stale_reviews": false,
  "require_code_owner_reviews": true,
  "required_approving_review_count": 0
 },
 "enforce_admins": true,
 "restrictions": null
}
```
</detail>

This PR is important when upgrading `go-github`.

Built on top of: https://github.com/terraform-providers/terraform-provider-github/pull/207
@paultyng paultyng force-pushed the paultyng/blocks branch from 7d4f660 to 1c207f8 Compare May 2, 2019 21:38
@paultyng
Copy link
Contributor Author

paultyng commented May 2, 2019

$ make testacc
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test $(go list ./... |grep -v 'vendor') -v  -timeout 120m
?   	github.com/terraform-providers/terraform-provider-github	[no test files]
=== RUN   TestAccGithubIpRangesDataSource_existing
--- PASS: TestAccGithubIpRangesDataSource_existing (0.56s)
=== RUN   TestAccGithubRepositoriesDataSource_basic
--- PASS: TestAccGithubRepositoriesDataSource_basic (5.29s)
=== RUN   TestAccGithubRepositoriesDataSource_noMatch
--- PASS: TestAccGithubRepositoriesDataSource_noMatch (0.51s)
=== RUN   TestAccGithubRepositoryDataSource_fullName_noMatchReturnsError
--- PASS: TestAccGithubRepositoryDataSource_fullName_noMatchReturnsError (0.10s)
=== RUN   TestAccGithubRepositoryDataSource_name_noMatchReturnsError
--- PASS: TestAccGithubRepositoryDataSource_name_noMatchReturnsError (0.14s)
=== RUN   TestAccGithubRepositoryDataSource_fullName_existing
--- PASS: TestAccGithubRepositoryDataSource_fullName_existing (1.41s)
=== RUN   TestAccGithubRepositoryDataSource_name_existing
--- PASS: TestAccGithubRepositoryDataSource_name_existing (0.80s)
=== RUN   TestAccGithubTeamDataSource_noMatchReturnsError
--- PASS: TestAccGithubTeamDataSource_noMatchReturnsError (0.14s)
=== RUN   TestAccGithubUserDataSource_noMatchReturnsError
--- PASS: TestAccGithubUserDataSource_noMatchReturnsError (0.08s)
=== RUN   TestAccGithubUserDataSource_existing
--- PASS: TestAccGithubUserDataSource_existing (2.45s)
=== RUN   TestMigrateGithubWebhookStateV0toV1
--- PASS: TestMigrateGithubWebhookStateV0toV1 (0.00s)
=== RUN   TestProvider
--- PASS: TestProvider (0.00s)
=== RUN   TestProvider_impl
--- PASS: TestProvider_impl (0.00s)
=== RUN   TestProvider_insecure
--- PASS: TestProvider_insecure (0.12s)
=== RUN   TestAccGithubBranchProtection_basic
--- PASS: TestAccGithubBranchProtection_basic (13.49s)
=== RUN   TestAccGithubBranchProtection_teams
--- PASS: TestAccGithubBranchProtection_teams (41.36s)
=== RUN   TestAccGithubBranchProtection_emptyItems
--- PASS: TestAccGithubBranchProtection_emptyItems (8.60s)
=== RUN   TestAccGithubBranchProtection_importBasic
--- PASS: TestAccGithubBranchProtection_importBasic (9.04s)
=== RUN   TestAccGithubIssueLabel_basic
--- PASS: TestAccGithubIssueLabel_basic (9.59s)
=== RUN   TestAccGithubIssueLabel_existingLabel
--- PASS: TestAccGithubIssueLabel_existingLabel (8.27s)
=== RUN   TestAccGithubIssueLabel_importBasic
--- PASS: TestAccGithubIssueLabel_importBasic (8.81s)
=== RUN   TestAccGithubIssueLabel_description
--- PASS: TestAccGithubIssueLabel_description (17.29s)
=== RUN   TestAccGithubMembership_basic
--- PASS: TestAccGithubMembership_basic (3.50s)
=== RUN   TestAccGithubMembership_importBasic
--- PASS: TestAccGithubMembership_importBasic (3.07s)
=== RUN   TestAccGithubOrganizationProject_basic
--- PASS: TestAccGithubOrganizationProject_basic (3.48s)
=== RUN   TestAccGithubOrganizationProject_importBasic
--- PASS: TestAccGithubOrganizationProject_importBasic (3.49s)
=== RUN   TestAccGithubOrganizationWebhook_basic
--- PASS: TestAccGithubOrganizationWebhook_basic (4.38s)
=== RUN   TestAccGithubOrganizationWebhook_secret
--- PASS: TestAccGithubOrganizationWebhook_secret (2.89s)
=== RUN   TestAccGithubProjectColumn_basic
--- PASS: TestAccGithubProjectColumn_basic (8.64s)
=== RUN   TestAccGithubProjectColumn_importBasic
--- PASS: TestAccGithubProjectColumn_importBasic (7.07s)
=== RUN   TestAccGithubRepositoryCollaborator_basic
--- PASS: TestAccGithubRepositoryCollaborator_basic (9.28s)
=== RUN   TestAccGithubRepositoryCollaborator_importBasic
--- PASS: TestAccGithubRepositoryCollaborator_importBasic (9.32s)
=== RUN   TestSuppressDeployKeyDiff
--- PASS: TestSuppressDeployKeyDiff (0.00s)
=== RUN   TestAccGithubRepositoryDeployKey_basic
--- PASS: TestAccGithubRepositoryDeployKey_basic (11.97s)
=== RUN   TestAccGithubRepositoryDeployKey_importBasic
--- PASS: TestAccGithubRepositoryDeployKey_importBasic (8.24s)
=== RUN   TestAccGithubRepositoryProject_basic
--- PASS: TestAccGithubRepositoryProject_basic (8.93s)
=== RUN   TestAccGithubRepositoryProject_importBasic
--- PASS: TestAccGithubRepositoryProject_importBasic (8.83s)
=== RUN   TestAccGithubRepository_basic
--- PASS: TestAccGithubRepository_basic (7.77s)
=== RUN   TestAccGithubRepository_archive
--- PASS: TestAccGithubRepository_archive (6.54s)
=== RUN   TestAccGithubRepository_archiveUpdate
--- PASS: TestAccGithubRepository_archiveUpdate (9.84s)
=== RUN   TestAccGithubRepository_importBasic
--- PASS: TestAccGithubRepository_importBasic (5.78s)
=== RUN   TestAccGithubRepository_defaultBranch
--- PASS: TestAccGithubRepository_defaultBranch (10.34s)
=== RUN   TestAccGithubRepository_templates
--- PASS: TestAccGithubRepository_templates (6.45s)
=== RUN   TestAccGithubRepository_topics
--- PASS: TestAccGithubRepository_topics (16.26s)
=== RUN   TestAccGithubRepository_autoInitForceNew
--- PASS: TestAccGithubRepository_autoInitForceNew (16.48s)
=== RUN   TestAccGithubRepositoryWebhook_basic
--- PASS: TestAccGithubRepositoryWebhook_basic (11.07s)
=== RUN   TestAccGithubRepositoryWebhook_secret
--- PASS: TestAccGithubRepositoryWebhook_secret (8.75s)
=== RUN   TestAccGithubRepositoryWebhook_importBasic
--- PASS: TestAccGithubRepositoryWebhook_importBasic (8.46s)
=== RUN   TestAccGithubRepositoryWebhook_importSecret
--- PASS: TestAccGithubRepositoryWebhook_importSecret (9.53s)
=== RUN   TestAccGithubTeamMembership_basic
--- PASS: TestAccGithubTeamMembership_basic (12.08s)
=== RUN   TestAccGithubTeamMembership_importBasic
--- PASS: TestAccGithubTeamMembership_importBasic (11.09s)
=== RUN   TestAccGithubTeamRepository_basic
--- PASS: TestAccGithubTeamRepository_basic (14.60s)
=== RUN   TestAccGithubTeamRepository_importBasic
--- PASS: TestAccGithubTeamRepository_importBasic (12.43s)
=== RUN   TestAccCheckGetPermissions
--- PASS: TestAccCheckGetPermissions (0.00s)
=== RUN   TestAccGithubTeam_basic
--- PASS: TestAccGithubTeam_basic (5.60s)
=== RUN   TestAccGithubTeam_slug
--- PASS: TestAccGithubTeam_slug (2.96s)
=== RUN   TestAccGithubTeam_hierarchical
--- PASS: TestAccGithubTeam_hierarchical (6.29s)
=== RUN   TestAccGithubTeam_importBasic
--- PASS: TestAccGithubTeam_importBasic (4.56s)
=== RUN   TestAccGithubUserGpgKey_basic
--- PASS: TestAccGithubUserGpgKey_basic (2.79s)
=== RUN   TestAccGithubUserInvitationAccepter_basic
--- SKIP: TestAccGithubUserInvitationAccepter_basic (0.00s)
    resource_github_user_invitation_accepter_test.go:21: GITHUB_TEST_COLLABORATOR_TOKEN was not provided, skipping test
=== RUN   TestAccGithubUserSshKey_basic
--- PASS: TestAccGithubUserSshKey_basic (3.37s)
=== RUN   TestAccGithubUserSshKey_importBasic
--- PASS: TestAccGithubUserSshKey_importBasic (3.98s)
=== RUN   TestAccOrganizationBlock_basic
--- PASS: TestAccOrganizationBlock_basic (4.74s)
=== RUN   TestAccOrganizationBlock_importBasic
--- PASS: TestAccOrganizationBlock_importBasic (3.52s)
=== RUN   TestEtagTransport
--- PASS: TestEtagTransport (0.00s)
=== RUN   TestRateLimitTransport_abuseLimit_get
--- PASS: TestRateLimitTransport_abuseLimit_get (0.00s)
=== RUN   TestRateLimitTransport_abuseLimit_post
--- PASS: TestRateLimitTransport_abuseLimit_post (0.00s)
=== RUN   TestRateLimitTransport_abuseLimit_post_error
--- PASS: TestRateLimitTransport_abuseLimit_post_error (0.00s)
=== RUN   TestAccGithubUtilRole_validation
--- PASS: TestAccGithubUtilRole_validation (0.00s)
=== RUN   TestAccGithubUtilTwoPartID
--- PASS: TestAccGithubUtilTwoPartID (0.00s)
PASS
ok  	github.com/terraform-providers/terraform-provider-github/github	426.498s

kfcampbell pushed a commit to kfcampbell/terraform-provider-github that referenced this pull request Jul 26, 2022
…/blocks

Add github_organization_block resource, update github SDK, add 0.12 support, fix some other issues.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

We should add resources to manage blocked users on an organization
4 participants