[BUG] Ensure github_emu_group_mapping behaves correctly if mapping changes upstream#3118
Conversation
|
👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labeled with |
stevehipwell
left a comment
There was a problem hiding this comment.
I've added some review comments, but please could you remove the new deps. I don't think we should be introducing new dependencies with functional changes and I'm not sold on the value of doing something like this especially where we get a whole old copy of go-github in the vendor dir.
Regarding
Regarding I would propose we keep both package additions as neither should be posing a risk for the functionality of the provider, while trying to make maintenance simpler |
|
RE RE |
8af4f04 to
705b3b0
Compare
@stevehipwell Thanks for the |
stevehipwell
left a comment
There was a problem hiding this comment.
Sorry, but I'm not following the point of matchTeamID()? Given that the team ID can't change without recreating the resource I'd only expect there to be a call to client.Teams.GetTeamBySlug() in create, to set it into the schema, and also in the diff if the slug changes. Other than that there shouldn't be any need to call that API during the general lifecycle.
FYI I like the addition of team_id to the schema, I'll add that into my team changes.
@stevehipwell My idea with But I just realize that in You're right. it's unnecessary! |
stevehipwell
left a comment
There was a problem hiding this comment.
This is coming along well, I've added some questions/suggestions but the main one is to remove the unnecessary API call to get the team ID in read.
0d4e974 to
0da08b1
Compare
0da08b1 to
c12065a
Compare
stevehipwell
left a comment
There was a problem hiding this comment.
I should have clarified the table test comment, I'm expecting the table tests to be self contained. Otherwise there isn't much point as it's non-trivial to add new cases.
c12065a to
2649046
Compare
|
@deiga this PR has conflicts. |
2649046 to
7f04918
Compare
|
@stevehipwell Conflicts resolved |
stevehipwell
left a comment
There was a problem hiding this comment.
@deiga could you remove the migration test from this PR and add it to a new PR? I think that pattern needs more discussion and may benefit from being looked at from a simpler perspective, such as actions secret. If this is done I think we're ready to merge.
fa53c43 to
4d3de7a
Compare
|
@stevehipwell Done |
Signed-off-by: Timo Sand <[email protected]>
…alGroupsForTeamBySlug` to ensure we match state and reality Signed-off-by: Timo Sand <[email protected]>
…nnecessary code Signed-off-by: Timo Sand <[email protected]>
Signed-off-by: Timo Sand <[email protected]>
- Adds `github.com/migueleliasweb/go-github-mock` package for mocking go-github endpoints - Adds `github.com/go-test/deep` package for better error messages when types of fields differ Signed-off-by: Timo Sand <[email protected]>
Signed-off-by: Timo Sand <[email protected]>
Signed-off-by: Timo Sand <[email protected]>
… `ForceNew` Signed-off-by: Timo Sand <[email protected]>
Signed-off-by: Timo Sand <[email protected]>
Signed-off-by: Timo Sand <[email protected]>
Signed-off-by: Timo Sand <[email protected]>
Signed-off-by: Timo Sand <[email protected]>
…ice. We need to directly lookup TeamID Signed-off-by: Timo Sand <[email protected]>
Signed-off-by: Timo Sand <[email protected]>
Signed-off-by: Timo Sand <[email protected]>
Signed-off-by: Timo Sand <[email protected]>
Signed-off-by: Timo Sand <[email protected]>
Signed-off-by: Timo Sand <[email protected]>
Signed-off-by: Timo Sand <[email protected]>
Signed-off-by: Timo Sand <[email protected]>
Signed-off-by: Timo Sand <[email protected]>
Signed-off-by: Timo Sand <[email protected]>
4d3de7a to
9c3367d
Compare
|
@stevehipwell Done |
…changes upstream (integrations#3118) * Move `toInt` and `toInt64` functions to `util.go` Signed-off-by: Timo Sand <[email protected]> * `resource_github_emu_group_mapping`) Change `Read` to use `ListExternalGroupsForTeamBySlug` to ensure we match state and reality Signed-off-by: Timo Sand <[email protected]> * `resource_github_emu_group_mapping`: Refactor `Create` to have less unnecessary code Signed-off-by: Timo Sand <[email protected]> * `emu_group_mapping`: Add `group_name` computed attribute Signed-off-by: Timo Sand <[email protected]> * Add matching of team ID into Read * Split Create and Update to separate functions * Update Importer to use new ID pattern * Add Schema migration for new ID format - Adds `github.com/migueleliasweb/go-github-mock` package for mocking go-github endpoints - Adds `github.com/go-test/deep` package for better error messages when types of fields differ Signed-off-by: Timo Sand <[email protected]> * Changes `group_id` to `ForceNew` Signed-off-by: Timo Sand <[email protected]> * Add skipped test while waiting for `terraform-plugin-testing` Signed-off-by: Timo Sand <[email protected]> * Add `CustomizeDiff` function to determine if `team_slug` change needs `ForceNew` Signed-off-by: Timo Sand <[email protected]> * Update docs Signed-off-by: Timo Sand <[email protected]> * Use `lookupTeamID` instead of `getTeamID` Signed-off-by: Timo Sand <[email protected]> * Move `Create` before `Read` Signed-off-by: Timo Sand <[email protected]> * Replace `deep` package with `go-cmp` Signed-off-by: Timo Sand <[email protected]> * `ListExternalGroupsForTeamBySlug` does not return a nested `Teams` slice. We need to directly lookup TeamID Signed-off-by: Timo Sand <[email protected]> * Replace `go-github-mock` with `githubApiMock` Signed-off-by: Timo Sand <[email protected]> * Remove unnecessry `matchTeamID` function Signed-off-by: Timo Sand <[email protected]> * Address review comments Signed-off-by: Timo Sand <[email protected]> * Rename state migartion functions Signed-off-by: Timo Sand <[email protected]> * Inline unnecessary function Signed-off-by: Timo Sand <[email protected]> * Use new reusable diffing pattern Signed-off-by: Timo Sand <[email protected]> * Address review comments Signed-off-by: Timo Sand <[email protected]> * Refactor mockResponse builder to accept inputs Signed-off-by: Timo Sand <[email protected]> * Delete test Signed-off-by: Timo Sand <[email protected]> --------- Signed-off-by: Timo Sand <[email protected]>
Before the change?
Readwould not check if the Team and External Group we're still connected to each othergroup_idwould not force a new resource, potentially leaving dangling connectionsCreateandUpdateshared same functionality, leading to potentially wasted API callsAfter the change?
<team_id>:<team_slug>:<group_id>Readproperly checks that Team ID ofteam_slugand any Team mapped togroup_idmatchgroup_idforces new resource creationCreateandUpdateto allow fine-grained control inUpdateteam_slugchange to vlaidate if it's a team rename or switchPull request checklist
Does this introduce a breaking change?
Please see our docs on breaking changes to help!