1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-08-05 05:45:22 +02:00

feat(dataservices): unify access methods and abstract away redundant code [EE-5628] (#9115)

This commit is contained in:
andres-portainer 2023-06-22 18:28:07 -03:00 committed by GitHub
parent 4c6bbe9a2f
commit 4cc96b4b30
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
171 changed files with 714 additions and 1590 deletions

View file

@ -78,7 +78,7 @@ func (handler *Handler) fdoConfigureDevice(w http.ResponseWriter, r *http.Reques
return httperror.BadRequest("Invalid request payload", err)
}
profile, err := handler.DataStore.FDOProfile().FDOProfile(portainer.FDOProfileID(payload.ProfileID))
profile, err := handler.DataStore.FDOProfile().Read(portainer.FDOProfileID(payload.ProfileID))
if handler.DataStore.IsErrObjectNotFound(err) {
return httperror.NotFound("Unable to find a FDO Profile with the specified identifier inside the database", err)
} else if err != nil {

View file

@ -99,7 +99,7 @@ func (handler *Handler) fdoConfigure(w http.ResponseWriter, r *http.Request) *ht
return httperror.BadRequest("Error saving FDO settings", err)
}
profiles, err := handler.DataStore.FDOProfile().FDOProfiles()
profiles, err := handler.DataStore.FDOProfile().ReadAll()
if err != nil {
return httperror.InternalServerError("Error saving FDO settings", err)
}

View file

@ -31,7 +31,7 @@ func (handler *Handler) duplicateProfile(w http.ResponseWriter, r *http.Request)
return httperror.BadRequest("Bad request", errors.New("missing 'id' query parameter"))
}
originalProfile, err := handler.DataStore.FDOProfile().FDOProfile(portainer.FDOProfileID(id))
originalProfile, err := handler.DataStore.FDOProfile().Read(portainer.FDOProfileID(id))
if handler.DataStore.IsErrObjectNotFound(err) {
return httperror.NotFound("Unable to find a FDO Profile with the specified identifier inside the database", err)
} else if err != nil {

View file

@ -33,7 +33,7 @@ func (handler *Handler) fdoProfileInspect(w http.ResponseWriter, r *http.Request
return httperror.BadRequest("Bad request", errors.New("missing 'id' query parameter"))
}
profile, err := handler.DataStore.FDOProfile().FDOProfile(portainer.FDOProfileID(id))
profile, err := handler.DataStore.FDOProfile().Read(portainer.FDOProfileID(id))
if err != nil {
return httperror.InternalServerError("Unable to retrieve Profile", err)
}

View file

@ -22,7 +22,7 @@ import (
// @router /fdo/profiles [get]
func (handler *Handler) fdoProfileList(w http.ResponseWriter, r *http.Request) *httperror.HandlerError {
profiles, err := handler.DataStore.FDOProfile().FDOProfiles()
profiles, err := handler.DataStore.FDOProfile().ReadAll()
if err != nil {
return httperror.InternalServerError(err.Error(), err)
}

View file

@ -37,7 +37,7 @@ func (handler *Handler) updateProfile(w http.ResponseWriter, r *http.Request) *h
return httperror.BadRequest("Invalid request payload", err)
}
profile, err := handler.DataStore.FDOProfile().FDOProfile(portainer.FDOProfileID(id))
profile, err := handler.DataStore.FDOProfile().Read(portainer.FDOProfileID(id))
if handler.DataStore.IsErrObjectNotFound(err) {
return httperror.NotFound("Unable to find a FDO Profile with the specified identifier inside the database", err)
} else if err != nil {

View file

@ -1,7 +1,7 @@
package fdo
func (handler *Handler) checkUniqueProfileName(name string, id int) (bool, error) {
profiles, err := handler.DataStore.FDOProfile().FDOProfiles()
profiles, err := handler.DataStore.FDOProfile().ReadAll()
if err != nil {
return false, err
}