fix(tags): add missing error handling EE-4622 (#8102)

pull/7907/head
andres-portainer 2022-11-24 14:16:04 -03:00 committed by GitHub
parent e26a607d28
commit 9dfac98a26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 5 additions and 7 deletions

View File

@ -91,11 +91,9 @@ func (service *Service) UpdateTagFunc(ID portainer.TagID, updateFunc func(tag *p
id := service.connection.ConvertToKey(int(ID))
tag := &portainer.Tag{}
service.connection.UpdateObjectFunc(BucketName, id, tag, func() {
return service.connection.UpdateObjectFunc(BucketName, id, tag, func() {
updateFunc(tag)
})
return nil
}
// DeleteTag deletes a tag.

View File

@ -91,7 +91,7 @@ func (handler *Handler) endpointGroupCreate(w http.ResponseWriter, r *http.Reque
}
for _, tagID := range endpointGroup.TagIDs {
handler.DataStore.Tag().UpdateTagFunc(tagID, func(tag *portainer.Tag) {
err = handler.DataStore.Tag().UpdateTagFunc(tagID, func(tag *portainer.Tag) {
tag.EndpointGroups[endpointGroup.ID] = true
})

View File

@ -66,7 +66,7 @@ func (handler *Handler) endpointGroupDelete(w http.ResponseWriter, r *http.Reque
}
for _, tagID := range endpointGroup.TagIDs {
handler.DataStore.Tag().UpdateTagFunc(tagID, func(tag *portainer.Tag) {
err = handler.DataStore.Tag().UpdateTagFunc(tagID, func(tag *portainer.Tag) {
delete(tag.EndpointGroups, endpointGroup.ID)
})

View File

@ -81,7 +81,7 @@ func (handler *Handler) endpointGroupUpdate(w http.ResponseWriter, r *http.Reque
removeTags := tag.Difference(endpointGroupTagSet, payloadTagSet)
for tagID := range removeTags {
handler.DataStore.Tag().UpdateTagFunc(tagID, func(tag *portainer.Tag) {
err = handler.DataStore.Tag().UpdateTagFunc(tagID, func(tag *portainer.Tag) {
delete(tag.EndpointGroups, endpointGroup.ID)
})
@ -94,7 +94,7 @@ func (handler *Handler) endpointGroupUpdate(w http.ResponseWriter, r *http.Reque
endpointGroup.TagIDs = payload.TagIDs
for _, tagID := range payload.TagIDs {
handler.DataStore.Tag().UpdateTagFunc(tagID, func(tag *portainer.Tag) {
err = handler.DataStore.Tag().UpdateTagFunc(tagID, func(tag *portainer.Tag) {
tag.EndpointGroups[endpointGroup.ID] = true
})