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

feat: Enable custom protection rule on GH environment #2352

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

ishan11
Copy link

@ishan11 ishan11 commented Aug 18, 2024

Resolves #2225


Before the change?

  • No resource to enable custom protection rule on environment

After the change?

  • New resource introduced that will allow for enabling custom protection rule on environment via terraform

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

Testing Results

image


@ishan11 ishan11 changed the title Gh env custom protection rule feat: Enable custom protection rule on GH environment Aug 18, 2024
@ishan11
Copy link
Author

ishan11 commented Aug 21, 2024

@kfcampbell Could you please review this PR, getting it merged and released would be really helpful for my team?

@ishan11
Copy link
Author

ishan11 commented Sep 29, 2024

@kfcampbell Can you take a look at this? would really help simplify my current workflow

@benjamin-scc
Copy link

@ishan11 As a workaround until officially supported by the provider, are you using null_resource with local-exec to call the GitHub API directly via Terraform?

@ishan11
Copy link
Author

ishan11 commented Nov 9, 2024

We ended up using a Rest API TF Provider but u think using a null resource with local exec would be fine as well

@stevehipwell
Copy link
Contributor

@ishan11 could you rebase this PR and update the go-github version to match the rest of the provider?

@ishan11
Copy link
Author

ishan11 commented Dec 11, 2024

@ishan11 could you rebase this PR and update the go-github version to match the rest of the provider?

@stevehipwell both have been completed.

@stevehipwell
Copy link
Contributor

@ishan11 do you think it might be useful to also add the corresponding data source?

@kzhou57
Copy link

kzhou57 commented Dec 12, 2024

When can we expect this feature to be released ? It's an important feature we are looking for.

@ishan11
Copy link
Author

ishan11 commented Dec 12, 2024

@ishan11 do you think it might be useful to also add the corresponding data source?

@stevehipwell
Could we release this feature first and then we can explore how to add the data source? I can't remember now but there was some complications I was facing when trying to implement the data source

@stevehipwell
Copy link
Contributor

@ishan11 I'm not a maintainer, just a contributor. But it looks like the REST API would support data sources and given the lead time on a PR review it'd probably be best to bundle the work together.

@ishan11
Copy link
Author

ishan11 commented Jan 29, 2025

@stevehipwell Sorry, just getting back around to this topic. I went and did some more research on implementing the corresponding data resource. I was able to remember the issue that I was facing when originally trying to implement. According to the GitHub API docs this is the endpoint that will List custom deployment rule integrations available for an environment, which we could use to return a list object that contains the integration_id that is needed to enable the rule via the resource that I created in this PR. However the issue that comes in is that once the custom deployment rule has been enabled the API linked above will remove the GH app from the returned list. This causes an issue when ever executing a TF Plan/Apply as the data source will get called and return an empty list the second time and show drift in the config.

Sorry for the long winded answer and hopefully my statement above makes sense. I am open to ideas on what might be the best way to implement this

@ishan11
Copy link
Author

ishan11 commented Jan 30, 2025

Ok, I was able to come up with a solution that combines using two different APIs. Essentially it will merge the list of available integrations and already applied integrations so that whenever the datasource is called it won't show drift.

@kfcampbell Could you please take a look this one?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEAT]: Add support for deployment protection rules
5 participants