1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-22 23:09:41 +02:00

fix(edge/stacks): validate deployment type [EE-4580] (#8875)

This commit is contained in:
Chaim Lev-Ari 2023-05-05 09:01:43 +07:00 committed by GitHub
parent 334eee0c8c
commit 5f6ddc2fad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 68 additions and 45 deletions

View file

@ -14,11 +14,10 @@ type edgeStackFromFileUploadPayload struct {
StackFileContent []byte
EdgeGroups []portainer.EdgeGroupID
// Deployment type to deploy this stack
// Valid values are: 0 - 'compose', 1 - 'kubernetes', 2 - 'nomad'
// for compose stacks will use kompose to convert to kubernetes manifest for kubernetes environments(endpoints)
// kubernetes deploytype is enabled only for kubernetes environments(endpoints)
// nomad deploytype is enabled only for nomad environments(endpoints)
DeploymentType portainer.EdgeStackDeploymentType `example:"0" enums:"0,1,2"`
// Valid values are: 0 - 'compose', 1 - 'kubernetes'
// compose is enabled only for docker environments
// kubernetes is enabled only for kubernetes environments
DeploymentType portainer.EdgeStackDeploymentType `example:"0" enums:"0,1"`
Registries []portainer.RegistryID
// Uses the manifest's namespaces instead of the default one
UseManifestNamespaces bool
@ -49,6 +48,9 @@ func (payload *edgeStackFromFileUploadPayload) Validate(r *http.Request) error {
return httperrors.NewInvalidPayloadError("Invalid deployment type")
}
payload.DeploymentType = portainer.EdgeStackDeploymentType(deploymentType)
if payload.DeploymentType != portainer.EdgeStackDeploymentCompose && payload.DeploymentType != portainer.EdgeStackDeploymentKubernetes {
return httperrors.NewInvalidPayloadError("Invalid deployment type")
}
var registries []portainer.RegistryID
err = request.RetrieveMultiPartFormJSONValue(r, "Registries", &registries, true)