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

fix(github_repository_tag_protection): Handle non-existent tag protections in state refresh #2217

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

fixe
Copy link

@fixe fixe commented Apr 1, 2024

This commit updates the resourceGithubRepositoryTagProtectionRead function to remove tag protections from Terraform's state if they no longer exist in GitHub. This ensures that the state accurately reflects the actual infrastructure and that Terraform will recreate the tag protections if necessary.

@fixe fixe changed the title Handle non-existent tag protections in state refresh fix(github_repository_tag_protection): Handle non-existent tag protections in state refresh Apr 1, 2024
…tions in state refresh

This commit updates the `resourceGithubRepositoryTagProtectionRead` function to remove tag protections from Terraform's state if they no longer exist in GitHub. This ensures that the state accurately reflects the actual infrastructure and that Terraform will recreate the tag protections if necessary.
@@ -98,6 +98,13 @@ func resourceGithubRepositoryTagProtectionRead(d *schema.ResourceData, meta inte
}
return err
}

Copy link
Member

Choose a reason for hiding this comment

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

Wouldn't we also want to do this if the call to client.Repositories.ListTagProtection 404s? What happened when you tested this?

Copy link
Author

Choose a reason for hiding this comment

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

Returns [], worked as expected.

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.

None yet

2 participants