terraform-provider-github icon indicating copy to clipboard operation
terraform-provider-github copied to clipboard

feat: Enable custom protection rule on GH environment

Open ishan11 opened this issue 1 year ago • 2 comments

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

image


ishan11 avatar Aug 18 '24 01:08 ishan11

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

ishan11 avatar Aug 21 '24 22:08 ishan11

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

ishan11 avatar Sep 29 '24 20:09 ishan11

@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?

benjamin-scc avatar Nov 06 '24 12:11 benjamin-scc

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 avatar Nov 09 '24 03:11 ishan11

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

stevehipwell avatar Nov 25 '24 16:11 stevehipwell

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

@stevehipwell both have been completed.

ishan11 avatar Dec 11 '24 15:12 ishan11

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

stevehipwell avatar Dec 11 '24 21:12 stevehipwell

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

kzhou57 avatar Dec 12 '24 20:12 kzhou57

@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 avatar Dec 12 '24 22:12 ishan11

@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 avatar Dec 12 '24 22:12 stevehipwell

@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 avatar Jan 29 '25 17:01 ishan11

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?

ishan11 avatar Jan 30 '25 21:01 ishan11

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 avatar Feb 28 '25 00:02 mw-root

@mw-root don't hold your breath, this TF provider has impossibly become even less of a priority to GitHub than before!

stevehipwell avatar Feb 28 '25 15:02 stevehipwell