diff --git a/docs/getting-started.md b/docs/getting-started.md index 2d9ec07..9235125 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -22,6 +22,11 @@ $ ./output/modctl -h Build the model artifact you need to prepare a Modelfile describe your expected layout of the model artifact in your model repo. +Notes: We support Unix-like glob path patterns, where: +- `*` matches any number of characters except path separators (`/`). +- `**` matches any number of directories, including zero directories. +For example, `**/*.py` matches all `.py` files in the current directory and its subdirectories. + Example of Modelfile: ```shell diff --git a/go.mod b/go.mod index 07446cd..467ba72 100644 --- a/go.mod +++ b/go.mod @@ -25,6 +25,7 @@ require ( github.com/VividCortex/ewma v1.2.0 // indirect github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d // indirect github.com/beorn7/perks v1.0.1 // indirect + github.com/bmatcuk/doublestar/v4 v4.8.1 github.com/cenkalti/backoff/v4 v4.3.0 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect diff --git a/go.sum b/go.sum index 9f76ae1..7aef594 100644 --- a/go.sum +++ b/go.sum @@ -10,6 +10,8 @@ github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24 github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/bmatcuk/doublestar/v4 v4.8.1 h1:54Bopc5c2cAvhLRAzqOGCYHYyhcDHsFF4wWIR5wKP38= +github.com/bmatcuk/doublestar/v4 v4.8.1/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc= github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8= github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= diff --git a/pkg/backend/processor/base.go b/pkg/backend/processor/base.go index bb12a6b..29ce2aa 100644 --- a/pkg/backend/processor/base.go +++ b/pkg/backend/processor/base.go @@ -19,6 +19,7 @@ package processor import ( "context" "fmt" + "os" "path/filepath" "sort" "sync" @@ -26,6 +27,7 @@ import ( "github.com/CloudNativeAI/modctl/pkg/backend/build" "github.com/CloudNativeAI/modctl/pkg/storage" + doublestar "github.com/bmatcuk/doublestar/v4" "github.com/chelnak/ysmrr" humanize "github.com/dustin/go-humanize" @@ -58,11 +60,14 @@ func (b *base) Process(ctx context.Context, workDir, repo string, opts ...Option var matchedPaths []string for _, pattern := range b.patterns { - matches, err := filepath.Glob(filepath.Join(absWorkDir, pattern)) + matches, err := doublestar.Glob(os.DirFS(absWorkDir), pattern) if err != nil { return nil, err } - + // convert to absolute paths + for i := range matches { + matches[i] = filepath.Join(absWorkDir, matches[i]) + } matchedPaths = append(matchedPaths, matches...) }