Skip to content

Graphql / Uplift branch_protection resource - #337

Merged
jcudit merged 5 commits into
integrations:masterfrom
patrickmarabeas:graphql/r-protection
Sep 6, 2020
Merged

jcudit merged 5 commits into
integrations:masterfrom
patrickmarabeas:graphql/r-protection

Conversation

@patrickmarabeas

Copy link
Copy Markdown
Contributor

Uplifts the branch_protection resource to use v4 API.

API surface has changed slightly.

Migration function only worries about:

  • migration of id from repository name to the current branch protection's global object ID
  • branch -> pattern

notes:

  • This branch will be rebased as necessary
  • Shared consts and functions will be abstracted int util_* files as required, I've simply included them within the one file for simplicity for the time being
  • This constitutes a preliminary migration to the v4 API
  • Tests will be written / updated once the API surface is nailed down

@patrickmarabeas

Copy link
Copy Markdown
Contributor Author

Unfortunately it seems as though v3 has continued to provide some newer features - see #305. I'll do some testing to see whether conditionally updating branch protection with the v3 API if the branch exists is a feasible solution.

@twexler

twexler commented Apr 2, 2020

Copy link
Copy Markdown

Looks like this one kind of died, any chance we could revive it? Could really use the ability to specify patterns for branch protections!

Willing to help if needed.

@patrickmarabeas

Copy link
Copy Markdown
Contributor Author

@twexler Still alive. There's currently discussion on how to roll v4 resources into this provider.

If you are wanting something now - have a look at https://github.com/patrickmarabeas/terraform-provider-github-v4 I'm using this as a test bed for v4 resources. Documentation is certainly lacking, but happy to add to it if questions are raised.

@twexler

twexler commented Apr 2, 2020

Copy link
Copy Markdown

Not super urgent, just a nice thing to have! I saw the discussion in #83 after I wrote that message.

I'd be happy to help with docs or anything else that is needed on the v4 transition!

@jcudit jcudit added this to the v2.7.0 milestone Apr 3, 2020
@jcudit

jcudit commented Apr 24, 2020

Copy link
Copy Markdown
Contributor

@patrickmarabeas @twexler -

I'm hoping to cut a new release with the incremental GraphQL changes accumulated so far.

What are thoughts around deferring this uplift to another release? I am unclear on the confidence of what is outlined in this PR, but happy to resolve conflicts and merge if this approach is still favoured.

@patrickmarabeas

Copy link
Copy Markdown
Contributor Author

Yes, further work is required on this PR.

@jcudit jcudit modified the milestones: v2.7.0, v2.8.0 Apr 24, 2020
@patrickmarabeas
patrickmarabeas force-pushed the graphql/r-protection branch from db941c0 to d0f95ec Compare May 2, 2020 11:24
@wuurrd

wuurrd commented May 14, 2020

Copy link
Copy Markdown

👍 this PR is extremely useful to fill in the gaps of missing v3 API stuff

@anGie44 anGie44 modified the milestones: v2.8.0, v2.8.1 May 15, 2020
@patrickmarabeas

Copy link
Copy Markdown
Contributor Author

Apologies, haven't had the time recently to focus on getting this squared away.

@jcudit jcudit modified the milestones: v2.9.0, v2.10.0 Jun 3, 2020
@patrickmarabeas
patrickmarabeas force-pushed the graphql/r-protection branch 2 times, most recently from 8430e4b to 2e39980 Compare June 16, 2020 05:21
@ghost ghost added the Type: Documentation Improvements or additions to documentation label Jun 16, 2020
@patrickmarabeas

Copy link
Copy Markdown
Contributor Author

Uplifting the tests at the moment, but it would be good to have a review on the changes to the parameters and what not.

There is no available v3 API endpoints to add the missing functionality (required_linear_history, allow_force_pushes, allow_deletions ), that doesn't also require you to provide ALL the fields (https://developer.github.com/v3/repos/branches/#update-branch-protection) which simply doesn't align with v4 (actor_ids vs apps, teams, users for instance).

CC @jcudit @anGie44

@jcudit jcudit modified the milestones: v2.10.0, v3.1.0 Jul 10, 2020
@patrickmarabeas

Copy link
Copy Markdown
Contributor Author

I've pulled the uplifted resource into its own files to avoid merge hell, and commented out the legacy files. This can be corrected when it's ready to be merged.

* Uplift branch_protection resource to use v4 API
* Add state migration for branch_protection v0 to v1
* Update test for branch_protection resource
* Update README for branch_protection resource
@jcudit

jcudit commented Sep 6, 2020

Copy link
Copy Markdown
Contributor

🥇 for patience on seeing this one through. I'll merge this shortly and plan to follow on with a few commits to:

  • update the tests to run with the latest test suite
  • rename the branch_protection_v4 resources back to branch_protection

@jcudit
jcudit merged commit 3bc761a into integrations:master Sep 6, 2020
@patrickmarabeas

Copy link
Copy Markdown
Contributor Author

Awesome, great to have this in!

Just an FYI for the future, you can squash fixup! commits by way of: git rebase --autosquash --interactive master.

@xorima

xorima commented Oct 13, 2020

Copy link
Copy Markdown
Contributor

Why is this change not in the release notes as breaking change or updated in the docs?

@lsowen

lsowen commented Oct 15, 2020

Copy link
Copy Markdown

@patrickmarabeas in v3, you could specify apps for push restrictions. It doesn't look like it is possible to get the node_id for an app for use with v4?

@Krenair

Krenair commented Oct 16, 2020

Copy link
Copy Markdown

Yeah, this being listed as an enhancement for 3.1.0 instead of a breaking change seems like a mistake?

pushActors = append(pushActors, a.Actor.Team.ID.(string))
}
if a.Actor.User != (Actor{}) {
pushActors = append(pushActors, a.Actor.Team.ID.(string))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this a bug? Should it instead be:

Suggested change
pushActors = append(pushActors, a.Actor.Team.ID.(string))
pushActors = append(pushActors, a.Actor.User.ID.(string))

?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Will be rectified in #819

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I've just seen your comment—there's a more complete fix (since the copy-paste error propagated) in #824.

stefanwb added a commit to schubergphilis/terraform-github-mcaf-repository that referenced this pull request Sep 24, 2021
This resolves issue caused by moving to use the v4 API for this resouce, as part of provider version: 3.1.0

Issue: integrations/terraform-provider-github#908
Provider bump: integrations/terraform-provider-github#337

Signed-off-by: Stefan Wessels Beljaars <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XXL Type: Documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants