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

Api Refactor: implements BatchDeleteEntry rpc #1623

Merged
merged 1 commit into from
Jun 9, 2020

Conversation

MarcosDY
Copy link
Collaborator

@MarcosDY MarcosDY commented Jun 8, 2020

Implement Batch delete entry rpc

Which issue this PR fixes
fixes #1602

@MarcosDY MarcosDY changed the title Api refactor impl delete entry Api Refactor: implements BatchDeleteEntry rpc Jun 8, 2020
log.WithError(err).Error("Failed to delete entry")
return &entry.BatchDeleteEntryResponse_Result{
Id: id,
Status: api.CreateStatus(codes.Internal, "failed to delete entry"),
Copy link
Member

Choose a reason for hiding this comment

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

Error information is missing here

func (s *Service) deleteEntry(ctx context.Context, id string) *entry.BatchDeleteEntryResponse_Result {
log := rpccontext.Logger(ctx)

if len(id) == 0 {
Copy link
Member

Choose a reason for hiding this comment

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

nit: == "" is more idiomatic for checking for an empty string

Comment on lines 106 to 122
cEntry, err := s.ds.FetchRegistrationEntry(ctx, &datastore.FetchRegistrationEntryRequest{
EntryId: id,
})
if err != nil {
log.WithError(err).Error("Failed to fetch entry")
return &entry.BatchDeleteEntryResponse_Result{
Id: id,
Status: api.CreateStatus(codes.Internal, "failed to fetch entry: %v", err),
}
}
if cEntry.Entry == nil {
log.Error("Invalid request: entry not found")
return &entry.BatchDeleteEntryResponse_Result{
Id: id,
Status: api.CreateStatus(codes.NotFound, "entry not found"),
}
}
Copy link
Member

Choose a reason for hiding this comment

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

The datastore is already supposed to handle failing if the entry does not already exist but I think it is broken and returns a code.Unknown status. We should fix the datastore to return codes.NotFound if the entry doesn't exist.

azdagron
azdagron previously approved these changes Jun 9, 2020
Signed-off-by: Marcos Yacob <marcos@scytale.io>
@azdagron azdagron merged commit e64a14e into spiffe:master Jun 9, 2020
@MarcosDY MarcosDY deleted the api-refactor-impl-delete-entry branch August 2, 2022 15:43
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.

API Refactor: Implement Entry.BatchDeleteEntry RPC
3 participants