feat: Enable custom protection rule on GH environment
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
- [x] Tests for the changes have been added (for bug fixes / features)
- [x] 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
- [x] No
Testing Results
@kfcampbell Could you please review this PR, getting it merged and released would be really helpful for my team?
@kfcampbell Can you take a look at this? would really help simplify my current workflow
@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?
We ended up using a Rest API TF Provider but u think using a null resource with local exec would be fine as well
@ishan11 could you rebase this PR and update the go-github version to match the rest of the provider?
@ishan11 could you rebase this PR and update the
go-githubversion to match the rest of the provider?
@stevehipwell both have been completed.
@ishan11 do you think it might be useful to also add the corresponding data source?
When can we expect this feature to be released ? It's an important feature we are looking for.
@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
@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.
@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
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?
Could we please get review of this?
We've had a hacky workaround for ages and this PR would allow us to remove it.
@mw-root don't hold your breath, this TF provider has impossibly become even less of a priority to GitHub than before!