|
|
@ -2,12 +2,15 @@ package store
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"os"
|
|
|
|
|
|
|
|
"regexp"
|
|
|
|
"strings"
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/docker/docker/pkg/namesgenerator"
|
|
|
|
"github.com/docker/docker/pkg/namesgenerator"
|
|
|
|
"github.com/pkg/errors"
|
|
|
|
"github.com/pkg/errors"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var namePattern = regexp.MustCompile(`^[a-zA-Z][a-zA-Z0-9\.\-_]*$`)
|
|
|
|
|
|
|
|
|
|
|
|
func ValidateName(s string) (string, error) {
|
|
|
|
func ValidateName(s string) (string, error) {
|
|
|
|
if !namePattern.MatchString(s) {
|
|
|
|
if !namePattern.MatchString(s) {
|
|
|
|
return "", errors.Errorf("invalid name %s, name needs to start with a letter and may not contain symbols, except ._-", s)
|
|
|
|
return "", errors.Errorf("invalid name %s, name needs to start with a letter and may not contain symbols, except ._-", s)
|
|
|
|