mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-08-14 07:45:55 +08:00
Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
5fac64c2c4 | ||
![]() |
24ad37a5d2 | ||
![]() |
106651877d | ||
![]() |
35bcd88f08 |
13
bake/bake.go
13
bake/bake.go
@@ -28,8 +28,10 @@ var (
|
||||
httpPrefix = regexp.MustCompile(`^https?://`)
|
||||
gitURLPathWithFragmentSuffix = regexp.MustCompile(`\.git(?:#.+)?$`)
|
||||
|
||||
validTargetNameChars = `[a-zA-Z0-9_-]+`
|
||||
targetNamePattern = regexp.MustCompile(`^` + validTargetNameChars + `$`)
|
||||
validTargetNameChars = `[a-zA-Z0-9_-]+`
|
||||
validTargetNameCharsCompose = `[a-zA-Z0-9._-]+`
|
||||
targetNamePattern = regexp.MustCompile(`^` + validTargetNameChars + `$`)
|
||||
targetNamePatternCompose = regexp.MustCompile(`^` + validTargetNameCharsCompose + `$`)
|
||||
)
|
||||
|
||||
type File struct {
|
||||
@@ -968,6 +970,13 @@ func validateTargetName(name string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func validateTargetNameCompose(name string) error {
|
||||
if !targetNamePatternCompose.MatchString(name) {
|
||||
return errors.Errorf("only %q are allowed", validTargetNameCharsCompose)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func sliceEqual(s1, s2 []string) bool {
|
||||
if len(s1) != len(s2) {
|
||||
return false
|
||||
|
@@ -60,7 +60,7 @@ func ParseCompose(dt []byte) (*Config, error) {
|
||||
continue
|
||||
}
|
||||
|
||||
if err = validateTargetName(s.Name); err != nil {
|
||||
if err = validateTargetNameCompose(s.Name); err != nil {
|
||||
return nil, errors.Wrapf(err, "invalid service name %q", s.Name)
|
||||
}
|
||||
|
||||
|
@@ -330,6 +330,10 @@ func TestServiceName(t *testing.T) {
|
||||
},
|
||||
{
|
||||
svc: "a.b",
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
svc: "a?b",
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
|
1
go.mod
1
go.mod
@@ -42,6 +42,7 @@ require (
|
||||
github.com/spf13/pflag v1.0.5
|
||||
github.com/stretchr/testify v1.7.0
|
||||
github.com/theupdateframework/notary v0.6.1 // indirect
|
||||
github.com/tonistiigi/fsutil v0.0.0-20220315205639-9ed612626da3 // indirect
|
||||
github.com/zclconf/go-cty v1.10.0
|
||||
go.opentelemetry.io/otel v1.4.1
|
||||
go.opentelemetry.io/otel/trace v1.4.1
|
||||
|
3
go.sum
3
go.sum
@@ -1286,8 +1286,9 @@ github.com/tmc/grpc-websocket-proxy v0.0.0-20201229170055-e5319fda7802/go.mod h1
|
||||
github.com/tommy-muehle/go-mnd v1.1.1/go.mod h1:dSUh0FtTP8VhvkL1S+gUR1OKd9ZnSaozuI6r3m6wOig=
|
||||
github.com/tommy-muehle/go-mnd v1.3.1-0.20200224220436-e6f9a994e8fa/go.mod h1:dSUh0FtTP8VhvkL1S+gUR1OKd9ZnSaozuI6r3m6wOig=
|
||||
github.com/tonistiigi/fsutil v0.0.0-20201103201449-0834f99b7b85/go.mod h1:a7cilN64dG941IOXfhJhlH0qB92hxJ9A1ewrdUmJ6xo=
|
||||
github.com/tonistiigi/fsutil v0.0.0-20220115021204-b19f7f9cb274 h1:wbyZxD6IPFp0sl5uscMOJRsz5UKGFiNiD16e+MVfKZY=
|
||||
github.com/tonistiigi/fsutil v0.0.0-20220115021204-b19f7f9cb274/go.mod h1:oPAfvw32vlUJSjyDcQ3Bu0nb2ON2B+G0dtVN/SZNJiA=
|
||||
github.com/tonistiigi/fsutil v0.0.0-20220315205639-9ed612626da3 h1:T1pEe+WB3SCPVAfVquvfPfagKZU2Z8c1OP3SuGB+id0=
|
||||
github.com/tonistiigi/fsutil v0.0.0-20220315205639-9ed612626da3/go.mod h1:oPAfvw32vlUJSjyDcQ3Bu0nb2ON2B+G0dtVN/SZNJiA=
|
||||
github.com/tonistiigi/go-actions-cache v0.0.0-20211202175116-9642704158ff/go.mod h1:qqvyZqkfwkoJuPU/bw61bItaoO0SJ8YSW0vSVRRvsRg=
|
||||
github.com/tonistiigi/go-archvariant v1.0.0/go.mod h1:TxFmO5VS6vMq2kvs3ht04iPXtu2rUT/erOnGFYfk5Ho=
|
||||
github.com/tonistiigi/units v0.0.0-20180711220420-6950e57a87ea h1:SXhTLE6pb6eld/v/cCndK0AMpt1wiVFb/YYmqB3/QG0=
|
||||
|
20
vendor/github.com/tonistiigi/fsutil/walker.go
generated
vendored
20
vendor/github.com/tonistiigi/fsutil/walker.go
generated
vendored
@@ -123,7 +123,13 @@ func Walk(ctx context.Context, p string, opt *WalkOpt, fn filepath.WalkFunc) err
|
||||
return nil
|
||||
}
|
||||
|
||||
var dir visitedDir
|
||||
var (
|
||||
dir visitedDir
|
||||
isDir bool
|
||||
)
|
||||
if fi != nil {
|
||||
isDir = fi.IsDir()
|
||||
}
|
||||
|
||||
if includeMatcher != nil || excludeMatcher != nil {
|
||||
for len(parentDirs) != 0 {
|
||||
@@ -134,7 +140,7 @@ func Walk(ctx context.Context, p string, opt *WalkOpt, fn filepath.WalkFunc) err
|
||||
parentDirs = parentDirs[:len(parentDirs)-1]
|
||||
}
|
||||
|
||||
if fi.IsDir() {
|
||||
if isDir {
|
||||
dir = visitedDir{
|
||||
fi: fi,
|
||||
path: path,
|
||||
@@ -156,12 +162,12 @@ func Walk(ctx context.Context, p string, opt *WalkOpt, fn filepath.WalkFunc) err
|
||||
return errors.Wrap(err, "failed to match includepatterns")
|
||||
}
|
||||
|
||||
if fi.IsDir() {
|
||||
if isDir {
|
||||
dir.includeMatchInfo = matchInfo
|
||||
}
|
||||
|
||||
if !m {
|
||||
if fi.IsDir() && onlyPrefixIncludes {
|
||||
if isDir && onlyPrefixIncludes {
|
||||
// Optimization: we can skip walking this dir if no include
|
||||
// patterns could match anything inside it.
|
||||
dirSlash := path + string(filepath.Separator)
|
||||
@@ -191,12 +197,12 @@ func Walk(ctx context.Context, p string, opt *WalkOpt, fn filepath.WalkFunc) err
|
||||
return errors.Wrap(err, "failed to match excludepatterns")
|
||||
}
|
||||
|
||||
if fi.IsDir() {
|
||||
if isDir {
|
||||
dir.excludeMatchInfo = matchInfo
|
||||
}
|
||||
|
||||
if m {
|
||||
if fi.IsDir() && onlyPrefixExcludeExceptions {
|
||||
if isDir && onlyPrefixExcludeExceptions {
|
||||
// Optimization: we can skip walking this dir if no
|
||||
// exceptions to exclude patterns could match anything
|
||||
// inside it.
|
||||
@@ -230,7 +236,7 @@ func Walk(ctx context.Context, p string, opt *WalkOpt, fn filepath.WalkFunc) err
|
||||
|
||||
if includeMatcher != nil || excludeMatcher != nil {
|
||||
defer func() {
|
||||
if fi.IsDir() {
|
||||
if isDir {
|
||||
parentDirs = append(parentDirs, dir)
|
||||
}
|
||||
}()
|
||||
|
3
vendor/modules.txt
vendored
3
vendor/modules.txt
vendored
@@ -436,7 +436,8 @@ github.com/theupdateframework/notary/tuf/data
|
||||
github.com/theupdateframework/notary/tuf/signed
|
||||
github.com/theupdateframework/notary/tuf/utils
|
||||
github.com/theupdateframework/notary/tuf/validation
|
||||
# github.com/tonistiigi/fsutil v0.0.0-20220115021204-b19f7f9cb274
|
||||
# github.com/tonistiigi/fsutil v0.0.0-20220315205639-9ed612626da3
|
||||
## explicit
|
||||
github.com/tonistiigi/fsutil
|
||||
github.com/tonistiigi/fsutil/types
|
||||
# github.com/tonistiigi/units v0.0.0-20180711220420-6950e57a87ea
|
||||
|
Reference in New Issue
Block a user