mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-05-18 00:47:48 +08:00
store: move regex to where it's used
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
6804bcbf12
commit
aa21ff7efd
@ -4,7 +4,6 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
|
||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
"github.com/docker/docker/pkg/ioutils"
|
"github.com/docker/docker/pkg/ioutils"
|
||||||
@ -199,8 +198,6 @@ type current struct {
|
|||||||
Global bool
|
Global bool
|
||||||
}
|
}
|
||||||
|
|
||||||
var namePattern = regexp.MustCompile(`^[a-zA-Z][a-zA-Z0-9\.\-_]*$`)
|
|
||||||
|
|
||||||
func toHash(in string) string {
|
func toHash(in string) string {
|
||||||
return digest.FromBytes([]byte(in)).Hex()[:20]
|
return digest.FromBytes([]byte(in)).Hex()[:20]
|
||||||
}
|
}
|
||||||
|
@ -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)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user