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:
parent
1ff19f8604
commit
426c132f97
15 changed files with 1225 additions and 1123 deletions
|
@ -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,
|
||||
}
|
||||
}
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue