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

fix: normalize stack name only for libcompose (#4862)

* fix: normilize stack name only for libcompose

* fix
This commit is contained in:
Dmitry Salakhov 2021-03-15 08:08:31 +13:00 committed by GitHub
parent 6d5877ca1c
commit 4cbd231a5f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 54 additions and 40 deletions

View file

@ -5,6 +5,8 @@ import (
"fmt"
"path"
"path/filepath"
"regexp"
"strings"
"github.com/portainer/libcompose/config"
"github.com/portainer/libcompose/docker"
@ -64,6 +66,14 @@ func (manager *ComposeStackManager) ComposeSyntaxMaxVersion() string {
return composeSyntaxMaxVersion
}
// NormalizeStackName returns a new stack name with unsupported characters replaced
func (manager *ComposeStackManager) NormalizeStackName(name string) string {
// this is coming from libcompose
// https://github.com/portainer/libcompose/blob/master/project/context.go#L117-L120
r := regexp.MustCompile("[^a-z0-9]+")
return r.ReplaceAllString(strings.ToLower(name), "")
}
// Up will deploy a compose stack (equivalent of docker-compose up)
func (manager *ComposeStackManager) Up(stack *portainer.Stack, endpoint *portainer.Endpoint) error {