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

client, identity: remove unnecessary guards around delete() #10148

Merged
merged 1 commit into from Feb 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 1 addition & 3 deletions pkg/client/endpoint.go
Expand Up @@ -143,9 +143,7 @@ func (c *Client) EndpointLabelsPatch(id string, toAdd, toDelete models.Labels) e
}
for _, lbl := range toDelete {
lblParsed := labels.ParseLabel(lbl)
if _, found := userLbl[lblParsed.Key]; found {
delete(userLbl, lblParsed.Key)
}
delete(userLbl, lblParsed.Key)
}
currentCfg.Spec.User = userLbl.GetModel()

Expand Down
8 changes: 2 additions & 6 deletions pkg/identity/cache/cache.go
Expand Up @@ -116,9 +116,7 @@ func collectEvent(event allocator.AllocatorEvent, added, deleted IdentityCache)
// Un-delete the added ID if previously
// 'deleted' so that collected events can be
// processed in any order.
if _, exists := deleted[id]; exists {
delete(deleted, id)
}
delete(deleted, id)
added[id] = gi.LabelArray
return true
}
Expand All @@ -127,9 +125,7 @@ func collectEvent(event allocator.AllocatorEvent, added, deleted IdentityCache)
return false
}
// Reverse an add when subsequently deleted
if _, exists := added[id]; exists {
delete(added, id)
}
delete(added, id)
// record the id deleted even if an add was reversed, as the
// id may also have previously existed, in which case the
// result is not no-op!
Expand Down