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
|
return &stack, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateEdgeStack assign an ID to a new Edge stack and saves it.
|
// CreateEdgeStack saves an Edge stack object to db.
|
||||||
func (service *Service) Create(edgeStack *portainer.EdgeStack) error {
|
func (service *Service) Create(id portainer.EdgeStackID, edgeStack *portainer.EdgeStack) error {
|
||||||
return service.connection.CreateObject(
|
|
||||||
|
edgeStack.ID = id
|
||||||
|
|
||||||
|
return service.connection.CreateObjectWithId(
|
||||||
BucketName,
|
BucketName,
|
||||||
func(id uint64) (int, interface{}) {
|
int(edgeStack.ID),
|
||||||
edgeStack.ID = portainer.EdgeStackID(id)
|
edgeStack,
|
||||||
return int(edgeStack.ID), edgeStack
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -84,7 +84,7 @@ type (
|
||||||
EdgeStackService interface {
|
EdgeStackService interface {
|
||||||
EdgeStacks() ([]portainer.EdgeStack, error)
|
EdgeStacks() ([]portainer.EdgeStack, error)
|
||||||
EdgeStack(ID portainer.EdgeStackID) (*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
|
UpdateEdgeStack(ID portainer.EdgeStackID, edgeStack *portainer.EdgeStack) error
|
||||||
DeleteEdgeStack(ID portainer.EdgeStackID) error
|
DeleteEdgeStack(ID portainer.EdgeStackID) error
|
||||||
GetNextIdentifier() int
|
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)
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
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)
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
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)
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue