Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for ** glob #99

Merged
merged 2 commits into from
Jan 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ require (
github.com/google/go-containerregistry v0.1.2
github.com/imdario/mergo v0.3.11 // indirect
github.com/magiconair/properties v1.8.4 // indirect
github.com/mattn/go-zglob v0.0.3
github.com/mitchellh/mapstructure v1.3.3 // indirect
// using buildkit from master rather than a tagged release because
// https://github.com/moby/buildkit/pull/1425
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,8 @@ github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzp
github.com/mattn/go-shellwords v1.0.10/go.mod h1:EZzvwXDESEeg03EKmM+RmDnNOPKG4lLtQsUlTZDWQ8Y=
github.com/mattn/go-sqlite3 v1.9.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
github.com/mattn/go-zglob v0.0.1/go.mod h1:9fxibJccNxU2cnpIKLRRFA7zX7qhkJIQWBb449FYHOo=
github.com/mattn/go-zglob v0.0.3 h1:6Ry4EYsScDyt5di4OI6xw1bYhOqfE5S33Z1OPy+d+To=
github.com/mattn/go-zglob v0.0.3/go.mod h1:9fxibJccNxU2cnpIKLRRFA7zX7qhkJIQWBb449FYHOo=
github.com/mattn/goveralls v0.0.2/go.mod h1:8d1ZMHsd7fW6IRPKQh46F2WRpyib5/X4FOpevwGNQEw=
github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
Expand Down
22 changes: 7 additions & 15 deletions pkg/generate/collect/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"strings"
"sync"

"github.com/mattn/go-zglob"
"github.com/safe-waters/docker-lock/pkg/kind"
)

Expand Down Expand Up @@ -255,7 +256,7 @@ func (p *pathCollector) collectGlobs(
for _, val := range p.globVals {
val = filepath.Join(p.baseDir, val)

vals, err := filepath.Glob(val)
vals, err := zglob.Glob(val)
if err != nil {
select {
case <-done:
Expand All @@ -266,6 +267,8 @@ func (p *pathCollector) collectGlobs(
}

for _, val := range vals {
val = filepath.FromSlash(val)

if !couldBeSubPath(val) {
select {
case <-done:
Expand All @@ -287,23 +290,12 @@ func (p *pathCollector) collectGlobs(
return
}

if isDir {
if !isDir {
select {
case <-done:
case paths <- NewPath(
p.kind, "", fmt.Errorf(
"'%s' is a directory rather than a file", val,
),
):
return
case paths <- NewPath(p.kind, val, nil):
}

return
}

select {
case <-done:
return
case paths <- NewPath(p.kind, val, nil):
}
}
}
Expand Down