Skip to content

Commit

Permalink
in_tail: Preserve backward compatiblity for glob
Browse files Browse the repository at this point in the history
This is because square brackets are permitted to use filename in macOS
and Windows.
So, we need to take care of.

Signed-off-by: Hiroshi Hatake <[email protected]>
  • Loading branch information
cosmo0920 committed Feb 15, 2024
1 parent 0e1707b commit 5f02c39
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/fluent/plugin/in_tail.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ def initialize
config_param :path, :string
desc 'path delimiter used for spliting path config'
config_param :path_delimiter, :string, default: ','
desc 'Use extended glob patterns. Adding a capability to handle [] and ?.'
config_param :use_extended_glob, :bool, default: false
desc 'The tag of the event.'
config_param :tag, :string
desc 'The paths to exclude the files from watcher list.'
Expand Down Expand Up @@ -286,7 +288,11 @@ def have_read_capability?
# Curly braces is not supported for now because the default delimiter of path is ",".
# This should be collided for wildcard pattern for curly braces.
def use_glob?(path)
path.include?('*') || path.include?('?') || /\[.*\]/.match(path)
if @use_extended_glob
path.include?('*') || path.include?('?') || /\[.*\]/.match(path)
else
path.include?('*')
end
end

def expand_paths
Expand Down
2 changes: 2 additions & 0 deletions test/plugin/test_in_tail.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1552,6 +1552,7 @@ def test_expand_paths_with_use_glob_p
"pos_file" => "#{@tmp_dir}/tail.pos",
"read_from_head" => true,
"refresh_interval" => 30,
"use_extended_glob" => true,
"rotate_wait" => "#{EX_ROTATE_WAIT}s",
"follow_inodes" => "#{EX_FOLLOW_INODES}",
})
Expand All @@ -1568,6 +1569,7 @@ def ex_config_with_brackets
"pos_file" => "#{@tmp_dir}/tail.pos",
"read_from_head" => true,
"refresh_interval" => 30,
"use_extended_glob" => true,
"rotate_wait" => "#{EX_ROTATE_WAIT}s",
"follow_inodes" => "#{EX_FOLLOW_INODES}",
})
Expand Down

0 comments on commit 5f02c39

Please sign in to comment.