1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-22 14:59: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

@ -30,3 +30,16 @@ func hasEndpointPredicate(endpointService dataservices.EndpointService, endpoint
return false, nil
}
func hasWrongEnvironmentType(endpointService dataservices.EndpointService, endpointIDs []portainer.EndpointID, deploymentType portainer.EdgeStackDeploymentType) (bool, error) {
return hasEndpointPredicate(endpointService, endpointIDs, func(e *portainer.Endpoint) bool {
switch deploymentType {
case portainer.EdgeStackDeploymentKubernetes:
return !endpointutils.IsKubernetesEndpoint(e)
case portainer.EdgeStackDeploymentCompose:
return !endpointutils.IsDockerEndpoint(e)
default:
return true
}
})
}