Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
telegraf-nftables
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Due to inactivity, this project is scheduled to be deleted on 2035-04-24.
Why is this scheduled?
Show more breadcrumbs
vqgroup
telegraf-nftables
Commits
52134555
Commit
52134555
authored
8 years ago
by
Cameron Sparr
Browse files
Options
Downloads
Patches
Plain Diff
globpath: only walk tree if ** is defined
closes #1517
parent
e7e39df6
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CHANGELOG.md
+1
-0
1 addition, 0 deletions
CHANGELOG.md
internal/globpath/globpath.go
+25
-7
25 additions, 7 deletions
internal/globpath/globpath.go
with
26 additions
and
7 deletions
CHANGELOG.md
+
1
−
0
View file @
52134555
...
...
@@ -36,6 +36,7 @@
-
[
#1768
](
https://github.com/influxdata/telegraf/pull/1768
)
: Speed up statsd parsing.
-
[
#1751
](
https://github.com/influxdata/telegraf/issues/1751
)
: Fix powerdns integer parse error handling.
-
[
#1752
](
https://github.com/influxdata/telegraf/issues/1752
)
: Fix varnish plugin defaults not being used.
-
[
#1517
](
https://github.com/influxdata/telegraf/issues/1517
)
: Fix windows glob paths.
## v1.0.1 [unreleased]
...
...
This diff is collapsed.
Click to expand it.
internal/globpath/globpath.go
+
25
−
7
View file @
52134555
...
...
@@ -12,21 +12,23 @@ import (
var
sepStr
=
fmt
.
Sprintf
(
"%v"
,
string
(
os
.
PathSeparator
))
type
GlobPath
struct
{
path
string
hasMeta
bool
g
glob
.
Glob
root
string
path
string
hasMeta
bool
hasSuperMeta
bool
g
glob
.
Glob
root
string
}
func
Compile
(
path
string
)
(
*
GlobPath
,
error
)
{
out
:=
GlobPath
{
hasMeta
:
hasMeta
(
path
),
path
:
path
,
hasMeta
:
hasMeta
(
path
),
hasSuperMeta
:
hasSuperMeta
(
path
),
path
:
path
,
}
// if there are no glob meta characters in the path, don't bother compiling
// a glob object or finding the root directory. (see short-circuit in Match)
if
!
out
.
hasMeta
{
if
!
out
.
hasMeta
||
!
out
.
hasSuperMeta
{
return
&
out
,
nil
}
...
...
@@ -48,6 +50,17 @@ func (g *GlobPath) Match() map[string]os.FileInfo {
}
return
out
}
if
!
g
.
hasSuperMeta
{
out
:=
make
(
map
[
string
]
os
.
FileInfo
)
files
,
_
:=
filepath
.
Glob
(
g
.
path
)
for
_
,
file
:=
range
files
{
info
,
err
:=
os
.
Stat
(
file
)
if
!
os
.
IsNotExist
(
err
)
{
out
[
file
]
=
info
}
}
return
out
}
return
walkFilePath
(
g
.
root
,
g
.
g
)
}
...
...
@@ -96,3 +109,8 @@ func findRootDir(path string) string {
func
hasMeta
(
path
string
)
bool
{
return
strings
.
IndexAny
(
path
,
"*?["
)
>=
0
}
// hasSuperMeta reports whether path contains any super magic glob characters (**).
func
hasSuperMeta
(
path
string
)
bool
{
return
strings
.
Index
(
path
,
"**"
)
>=
0
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment