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

Check repository_deployment_branch_policy for 404 in read #1875

Merged

Conversation

o-sama
Copy link
Contributor

@o-sama o-sama commented Sep 5, 2023

Resolves #1853


Before the change?

  • Deleting this resource outside of TF currently breaks the configuration.

After the change?

  • The provider should be able to recognize when this resource no longer exists.

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)

Neither of the above is required, there's no functionality change outside of checking for a 404 status when reading the resource.

Does this introduce a breaking change?

Please see our docs on breaking changes to help!

  • Yes
  • No

@kfcampbell
Copy link
Member

Is this the desired behavior? Perhaps when deleted outside of GitHub, the provider should reinstate the resource as described in the HCL. Can you talk to me a little more about what prompted this PR and the scenarios you're hoping to avoid?

@o-sama
Copy link
Contributor Author

o-sama commented Sep 5, 2023

That is the intended behaviour, previously the read would just return the error if it isn't a 304 not found and so nothing would happen. The goal here is to remove the resource from state if it's deleted outside of Terraform, which would then recreate on the next apply to match the code.

I did forget to remove the old error checks though which should not be hit anymore so I'll do that in a commit in a few mins.

This issue is behind opening this PR and shows what a 404 looks like currently for this resource.

Copy link
Member

@kfcampbell kfcampbell left a comment

Choose a reason for hiding this comment

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

@o-sama thank you for the context and explanation!

@kfcampbell kfcampbell merged commit 2d764d2 into integrations:main Sep 8, 2023
3 checks passed
avidspartan1 pushed a commit to avidspartan1/terraform-provider-github that referenced this pull request Feb 5, 2024
…ns#1875)

* Check repository_deployment_branch_policy for 404 in read

* Remove unneeded error checks

---------

Co-authored-by: Keegan Campbell <me@kfcampbell.com>
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.

[Bug] Terraform refresh fails if deployment environment's branch policy has been deleted
2 participants