1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-08-02 20:35:25 +02:00

refactor(edge/stacks): separate create by method [EE-4947] (#8898)

This commit is contained in:
Chaim Lev-Ari 2023-05-04 21:11:19 +07:00 committed by GitHub
parent 1ff19f8604
commit 426c132f97
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 1225 additions and 1123 deletions

View file

@ -1,15 +0,0 @@
package edgestacks
type InvalidPayloadError struct {
msg string
}
func (e *InvalidPayloadError) Error() string {
return e.msg
}
func NewInvalidPayloadError(errMsg string) *InvalidPayloadError {
return &InvalidPayloadError{
msg: errMsg,
}
}

View file

@ -9,6 +9,7 @@ import (
"github.com/pkg/errors"
portainer "github.com/portainer/portainer/api"
"github.com/portainer/portainer/api/dataservices"
httperrors "github.com/portainer/portainer/api/http/errors"
"github.com/portainer/portainer/api/internal/edge"
edgetypes "github.com/portainer/portainer/api/internal/edge/types"
)
@ -81,7 +82,7 @@ func (service *Service) PersistEdgeStack(
relatedEndpointIds, err := edge.EdgeStackRelatedEndpoints(stack.EdgeGroups, relationConfig.Endpoints, relationConfig.EndpointGroups, relationConfig.EdgeGroups)
if err != nil {
if err == edge.ErrEdgeGroupNotFound {
return nil, NewInvalidPayloadError(err.Error())
return nil, httperrors.NewInvalidPayloadError(err.Error())
}
return nil, fmt.Errorf("unable to persist environment relation in database: %w", err)
}