Skip to content

Commit

Permalink
Move to v4
Browse files Browse the repository at this point in the history
  • Loading branch information
paul1r committed Nov 19, 2024
1 parent 0ebca89 commit b3817d0
Show file tree
Hide file tree
Showing 20 changed files with 2,217 additions and 854 deletions.
27 changes: 24 additions & 3 deletions clients/pkg/promtail/targets/file/filetarget.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"sync"
"time"

"github.com/bmatcuk/doublestar"
"github.com/bmatcuk/doublestar/v4"
"github.com/fsnotify/fsnotify"
"github.com/go-kit/log"
"github.com/go-kit/log/level"
Expand Down Expand Up @@ -246,19 +246,40 @@ func (t *FileTarget) sync() error {
matches = []string{t.path}
} else {
// Gets current list of files to tail.
matches, err = doublestar.Glob(t.path)
base, pattern := doublestar.SplitPattern(t.path)
relMatches, err := doublestar.Glob(os.DirFS(base), pattern)
if err != nil {
return errors.Wrap(err, "filetarget.sync.filepath.Glob")
}
// Convert relative paths to absolute
matches = make([]string, len(relMatches))
for i, match := range relMatches {
matches[i] = filepath.Join(base, match)
matches[i], err = filepath.Abs(matches[i])
if err != nil {
return errors.Wrap(err, "filetarget.sync.filepath.Abs")
}
}
}

if fi, err := os.Stat(t.pathExclude); err == nil && !fi.IsDir() {
matchesExcluded = []string{t.pathExclude}
} else {
matchesExcluded, err = doublestar.Glob(t.pathExclude)
base, pattern := doublestar.SplitPattern(t.pathExclude)
relMatchesExcluded, err := doublestar.Glob(os.DirFS(base), pattern)
//matchesExcluded, err = doublestar.Glob(os.DirFS("/"), t.pathExclude)
if err != nil {
return errors.Wrap(err, "filetarget.sync.filepathexclude.Glob")
}
// Convert relative paths to absolute
matchesExcluded = make([]string, len(relMatchesExcluded))
for i, match := range relMatchesExcluded {
matchesExcluded[i] = filepath.Join(base, match)
matchesExcluded[i], err = filepath.Abs(matchesExcluded[i])
if err != nil {
return errors.Wrap(err, "filetarget.sync.filepath.Abs")
}
}
}

for i := 0; i < len(matchesExcluded); i++ {
Expand Down
2 changes: 1 addition & 1 deletion clients/pkg/promtail/targets/file/filetargetmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strings"
"sync"

"github.com/bmatcuk/doublestar"
"github.com/bmatcuk/doublestar/v4"
"github.com/fsnotify/fsnotify"
"github.com/go-kit/log"
"github.com/go-kit/log/level"
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ require (
github.com/IBM/go-sdk-core/v5 v5.18.1
github.com/IBM/ibm-cos-sdk-go v1.11.1
github.com/axiomhq/hyperloglog v0.2.0
github.com/bmatcuk/doublestar v1.3.4
github.com/buger/jsonparser v1.1.1
github.com/coder/quartz v0.1.2
github.com/d4l3k/messagediff v1.2.1
Expand Down
3 changes: 1 addition & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1026,8 +1026,7 @@ github.com/bitly/go-hostpool v0.1.0 h1:XKmsF6k5el6xHG3WPJ8U0Ku/ye7njX7W81Ng7O2io
github.com/bitly/go-hostpool v0.1.0/go.mod h1:4gOCgp6+NZnVqlKyZ/iBZFTAJKembaVENUpMkpg42fw=
github.com/bluele/gcache v0.0.2 h1:WcbfdXICg7G/DGBh1PFfcirkWOQV+v077yF1pSy3DGw=
github.com/bluele/gcache v0.0.2/go.mod h1:m15KV+ECjptwSPxKhOhQoAFQVtUFjTVkc3H8o0t/fp0=
github.com/bmatcuk/doublestar v1.3.4 h1:gPypJ5xD31uhX6Tf54sDPUOBXTqKH4c9aPY66CyQrS0=
github.com/bmatcuk/doublestar v1.3.4/go.mod h1:wiQtGV+rzVYxB7WIlirSN++5HPtPlXEo9MEoZQC/PmE=
github.com/bmatcuk/doublestar/v4 v4.7.1 h1:fdDeAqgT47acgwd9bd9HxJRDmc9UAmPpc+2m0CXv75Q=
github.com/bmatcuk/doublestar/v4 v4.7.1/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc=
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=
Expand Down
20 changes: 0 additions & 20 deletions vendor/github.com/bmatcuk/doublestar/.travis.yml

This file was deleted.

140 changes: 0 additions & 140 deletions vendor/github.com/bmatcuk/doublestar/README.md

This file was deleted.

Loading

0 comments on commit b3817d0

Please sign in to comment.