-
Notifications
You must be signed in to change notification settings - Fork 83
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
Conversation
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 | ||
} |
There was a problem hiding this comment.
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.
alreadyMemberIDs := make([]string, len(alreadyMembers)) | ||
for _, member := range alreadyMembers { | ||
alreadyMemberIDs = append(alreadyMemberIDs, member.GetUserID()) | ||
} | ||
|
||
if cmp.Equal(memberIDsToAdd, alreadyMemberIDs) { | ||
return nil | ||
} | ||
|
There was a problem hiding this comment.
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.
72a013e
to
3388f02
Compare
3388f02
to
edff628
Compare
🔧 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