mirror of
https://github.com/portainer/portainer.git
synced 2025-07-19 13:29:41 +02:00
fix(edge/stacks): validate deployment type [EE-4580] (#8875)
This commit is contained in:
parent
334eee0c8c
commit
5f6ddc2fad
5 changed files with 68 additions and 45 deletions
|
@ -146,6 +146,14 @@ func (handler *Handler) edgeStackUpdate(w http.ResponseWriter, r *http.Request)
|
|||
|
||||
stackFolder := strconv.Itoa(int(stack.ID))
|
||||
|
||||
hasWrongType, err := hasWrongEnvironmentType(handler.DataStore.Endpoint(), relatedEndpointIds, payload.DeploymentType)
|
||||
if err != nil {
|
||||
return httperror.BadRequest("unable to check for existence of non fitting environments: %w", err)
|
||||
}
|
||||
if hasWrongType {
|
||||
return httperror.BadRequest("edge stack with config do not match the environment type", nil)
|
||||
}
|
||||
|
||||
if payload.DeploymentType == portainer.EdgeStackDeploymentCompose {
|
||||
if stack.EntryPoint == "" {
|
||||
stack.EntryPoint = filesystem.ComposeFileDefaultName
|
||||
|
@ -171,15 +179,6 @@ func (handler *Handler) edgeStackUpdate(w http.ResponseWriter, r *http.Request)
|
|||
|
||||
stack.UseManifestNamespaces = payload.UseManifestNamespaces
|
||||
|
||||
hasDockerEndpoint, err := hasDockerEndpoint(handler.DataStore.Endpoint(), relatedEndpointIds)
|
||||
if err != nil {
|
||||
return httperror.InternalServerError("Unable to check for existence of docker environment", err)
|
||||
}
|
||||
|
||||
if hasDockerEndpoint {
|
||||
return httperror.BadRequest("Edge stack with docker environment cannot be deployed with kubernetes config", err)
|
||||
}
|
||||
|
||||
_, err = handler.FileService.StoreEdgeStackFileFromBytes(stackFolder, stack.ManifestPath, []byte(payload.StackFileContent))
|
||||
if err != nil {
|
||||
return httperror.InternalServerError("Unable to persist updated Kubernetes manifest file on disk", err)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue