Skip to content

Commit

Permalink
Fileglob parsing fixes (#1485)
Browse files Browse the repository at this point in the history
* Update doublestar module to version 1.2.2.

* Add absolute path for each element in list.

* Remove doublestar test and update vendore module version.
  • Loading branch information
p37ruh4 authored and cyriltovena committed Jan 13, 2020
1 parent 073258c commit 4f314f3
Show file tree
Hide file tree
Showing 8 changed files with 327 additions and 146 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.13
require (
github.com/Microsoft/go-winio v0.4.12 // indirect
github.com/blang/semver v3.5.1+incompatible // indirect
github.com/bmatcuk/doublestar v1.1.1
github.com/bmatcuk/doublestar v1.2.2
github.com/containerd/containerd v1.3.2 // indirect
github.com/containerd/fifo v0.0.0-20190226154929-a9fb20d87448 // indirect
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ github.com/bitly/go-hostpool v0.0.0-20171023180738-a3a6125de932/go.mod h1:NOuUCS
github.com/blang/semver v3.5.0+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk=
github.com/blang/semver v3.5.1+incompatible h1:cQNTCjp13qL8KC3Nbxr/y2Bqb63oX6wdnnjpJbkM4JQ=
github.com/blang/semver v3.5.1+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk=
github.com/bmatcuk/doublestar v1.1.1 h1:YroD6BJCZBYx06yYFEWvUuKVWQn3vLLQAVmDmvTSaiQ=
github.com/bmatcuk/doublestar v1.1.1/go.mod h1:UD6OnuiIn0yFxxA2le/rnRU1G4RaI4UvFv1sNto9p6w=
github.com/bmatcuk/doublestar v1.2.2 h1:oC24CykoSAB8zd7XgruHo33E0cHJf/WhQA/7BeXj+x0=
github.com/bmatcuk/doublestar v1.2.2/go.mod h1:wiQtGV+rzVYxB7WIlirSN++5HPtPlXEo9MEoZQC/PmE=
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 h1:DDGfHa7BWjL4YnC6+E63dPcxHo2sUxDIu8g3QgEJdRY=
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4=
github.com/bradfitz/gomemcache v0.0.0-20190329173943-551aad21a668 h1:U/lr3Dgy4WK+hNk4tyD+nuGjpVLPEHuJSFXMw11/HPA=
Expand Down
19 changes: 12 additions & 7 deletions pkg/promtail/targets/filetarget.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,18 +195,23 @@ func (t *FileTarget) run() {

func (t *FileTarget) sync() error {

// Find list of directories to add to watcher.
path, err := filepath.Abs(t.path)
if err != nil {
return errors.Wrap(err, "filetarget.sync.filepath.Abs")
}

// Gets current list of files to tail.
matches, err := doublestar.Glob(path)
matches, err := doublestar.Glob(t.path)
if err != nil {
return errors.Wrap(err, "filetarget.sync.filepath.Glob")
}

// Gets absolute path for each pattern.
for i := 0; i < len(matches); i++ {
if !filepath.IsAbs(matches[i]) {
path, err := filepath.Abs(matches[i])
if err != nil {
return errors.Wrap(err, "filetarget.sync.filepath.Abs")
}
matches[i] = path
}
}

// Record the size of all the files matched by the Glob pattern.
t.reportSize(matches)

Expand Down
3 changes: 3 additions & 0 deletions vendor/github.com/bmatcuk/doublestar/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions vendor/github.com/bmatcuk/doublestar/.travis.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 4f314f3

Please sign in to comment.