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

DXCDT-473: Fix how we guard against erasing unwanted changes in resources #645

Merged
merged 1 commit into from
Jun 20, 2023

Conversation

sergiught
Copy link
Contributor

@sergiught sergiught commented Jun 20, 2023

🔧 Changes

We have a few guards when creating specific resources spread across the provider, this is to ensure we don't overwrite blindly attributes when dealing with Auth0 resources that already exist. However some of these functions had a few issues in the diffing mechanism, please check comments for more details.

These guards are already covered by tests, however further tweaks will follow in another PR.

📚 References

🔬 Testing

📝 Checklist

  • All new/changed/fixed functionality is covered by tests (or N/A)
  • I have added documentation for all new/changed functionality (or N/A)

@sergiught sergiught changed the base branch from main to patch/DXCDT-471-sweep June 20, 2023 13:00
@sergiught sergiught changed the title Fix custom domains sweeper DXCDT-473: Fix guard against funcs Jun 20, 2023
@sergiught sergiught changed the title DXCDT-473: Fix guard against funcs DXCDT-473: Fix how we guard against erasing unwanted changes in resources Jun 20, 2023
Comment on lines 201 to 216
alreadyEnabledConnectionsIDs := make([]string, len(alreadyEnabledConnections))
for _, conn := range alreadyEnabledConnections {
alreadyEnabledConnectionsIDs = append(alreadyEnabledConnectionsIDs, conn.GetConnectionID())
}

connectionIDsToAdd := make([]string, len(connectionsToAdd))
for _, conn := range connectionsToAdd {
connectionIDsToAdd = append(connectionIDsToAdd, conn.GetConnectionID())
}

if cmp.Equal(connectionIDsToAdd, alreadyEnabledConnectionsIDs) {
return nil
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

While the two objects are of the same type, the organization connections retrieves by the API contain a few additional details that will make the diff always fail. Considering we only care about the diff between connection IDs we loop through both objects and only collect those.

Comment on lines 175 to 185
alreadyMemberIDs := make([]string, len(alreadyMembers))
for _, member := range alreadyMembers {
alreadyMemberIDs = append(alreadyMemberIDs, member.GetUserID())
}

if cmp.Equal(memberIDsToAdd, alreadyMemberIDs) {
return nil
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Similar to the above comment, in this case we're only interested in member IDs.

@sergiught sergiught marked this pull request as ready for review June 20, 2023 13:05
@sergiught sergiught requested a review from a team as a code owner June 20, 2023 13:05
@sergiught sergiught marked this pull request as draft June 20, 2023 13:44
@sergiught sergiught force-pushed the patch/DXCDT-473-fix-guard branch 2 times, most recently from 72a013e to 3388f02 Compare June 20, 2023 14:04
@sergiught sergiught marked this pull request as ready for review June 20, 2023 14:12
Base automatically changed from patch/DXCDT-471-sweep to main June 20, 2023 17:04
@sergiught sergiught merged commit 0684384 into main Jun 20, 2023
@sergiught sergiught deleted the patch/DXCDT-473-fix-guard branch June 20, 2023 17:13
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.

2 participants