mirror of https://github.com/portainer/portainer
fix(edgestacks): create new stack [EE-2178] (#6311)
* fix(edgestacks): create new stack [EE-2178] [EE-2178] * refactor(edgestacks): id is required on createpull/6270/head
parent
4e77d2d772
commit
87dda810fc
|
@ -67,14 +67,15 @@ func (service *Service) EdgeStack(ID portainer.EdgeStackID) (*portainer.EdgeStac
|
|||
return &stack, nil
|
||||
}
|
||||
|
||||
// CreateEdgeStack assign an ID to a new Edge stack and saves it.
|
||||
func (service *Service) Create(edgeStack *portainer.EdgeStack) error {
|
||||
return service.connection.CreateObject(
|
||||
// CreateEdgeStack saves an Edge stack object to db.
|
||||
func (service *Service) Create(id portainer.EdgeStackID, edgeStack *portainer.EdgeStack) error {
|
||||
|
||||
edgeStack.ID = id
|
||||
|
||||
return service.connection.CreateObjectWithId(
|
||||
BucketName,
|
||||
func(id uint64) (int, interface{}) {
|
||||
edgeStack.ID = portainer.EdgeStackID(id)
|
||||
return int(edgeStack.ID), edgeStack
|
||||
},
|
||||
int(edgeStack.ID),
|
||||
edgeStack,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ type (
|
|||
EdgeStackService interface {
|
||||
EdgeStacks() ([]portainer.EdgeStack, error)
|
||||
EdgeStack(ID portainer.EdgeStackID) (*portainer.EdgeStack, error)
|
||||
Create(edgeStack *portainer.EdgeStack) error
|
||||
Create(id portainer.EdgeStackID, edgeStack *portainer.EdgeStack) error
|
||||
UpdateEdgeStack(ID portainer.EdgeStackID, edgeStack *portainer.EdgeStack) error
|
||||
DeleteEdgeStack(ID portainer.EdgeStackID) error
|
||||
GetNextIdentifier() int
|
||||
|
|
|
@ -159,7 +159,7 @@ func (handler *Handler) createSwarmStackFromFileContent(r *http.Request) (*porta
|
|||
return nil, fmt.Errorf("Unable to update endpoint relations: %w", err)
|
||||
}
|
||||
|
||||
err = handler.DataStore.EdgeStack().Create(stack)
|
||||
err = handler.DataStore.EdgeStack().Create(stack.ID, stack)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -274,7 +274,7 @@ func (handler *Handler) createSwarmStackFromGitRepository(r *http.Request) (*por
|
|||
return nil, fmt.Errorf("Unable to update endpoint relations: %w", err)
|
||||
}
|
||||
|
||||
err = handler.DataStore.EdgeStack().Create(stack)
|
||||
err = handler.DataStore.EdgeStack().Create(stack.ID, stack)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -381,7 +381,7 @@ func (handler *Handler) createSwarmStackFromFileUpload(r *http.Request) (*portai
|
|||
return nil, fmt.Errorf("Unable to update endpoint relations: %w", err)
|
||||
}
|
||||
|
||||
err = handler.DataStore.EdgeStack().Create(stack)
|
||||
err = handler.DataStore.EdgeStack().Create(stack.ID, stack)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue