Skip to content

Commit

Permalink
in_tail: Address comments
Browse files Browse the repository at this point in the history
Signed-off-by: Hiroshi Hatake <[email protected]>
  • Loading branch information
cosmo0920 committed Mar 26, 2024
1 parent 2d6c6cf commit 705d5ea
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions lib/fluent/plugin/in_tail.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def initialize
desc 'path delimiter used for spliting path config'
config_param :path_delimiter, :string, default: ','
desc 'Choose using glob patterns. Adding whether a capability to handle [] and ? or not.'
config_param :enable_glob, :enum, list: [:with_wildcards, :always], default: :with_wildcards
config_param :glob_policy, :enum, list: [:backward_compatible, :extended], default: :backward_compatible
desc 'The tag of the event.'
config_param :tag, :string
desc 'The paths to exclude the files from watcher list.'
Expand Down Expand Up @@ -288,9 +288,9 @@ 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)
if @enable_glob == :always
if @glob_policy == :extended
path.include?('*') || path.include?('?') || /\[.*\]/.match(path)
elsif @enable_glob == :with_wildcards
elsif @glob_policy == :backward_compatible
path.include?('*')
end
end
Expand Down
20 changes: 10 additions & 10 deletions test/plugin/test_in_tail.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1540,9 +1540,9 @@ def test_expand_paths

sub_test_case "expand_paths with glob" do |data|
sub_test_case "extended_glob" do
data("square brackets" => [true, "always", "test/plugin/data/log_numeric/[0-1][2-4].log"],
"asterisk" => [true, "always", "test/plugin/data/log/*.log"],
"one character matcher" => [true, "always", "test/plugin/data/log/tes?.log"],
data("square brackets" => [true, "extended", "test/plugin/data/log_numeric/[0-1][2-4].log"],
"asterisk" => [true, "extended", "test/plugin/data/log/*.log"],
"one character matcher" => [true, "extended", "test/plugin/data/log/tes?.log"],
)
def test_expand_paths_with_use_glob_p
result, option, path = data
Expand All @@ -1553,7 +1553,7 @@ def test_expand_paths_with_use_glob_p
"pos_file" => "#{@tmp_dir}/tail.pos",
"read_from_head" => true,
"refresh_interval" => 30,
"enable_glob" => option,
"glob_policy" => option,
"rotate_wait" => "#{EX_ROTATE_WAIT}s",
"follow_inodes" => "#{EX_FOLLOW_INODES}",
})
Expand All @@ -1562,10 +1562,10 @@ def test_expand_paths_with_use_glob_p
end
end

sub_test_case "only_use_with_wildcards" do
data("square brackets" => [false, "with_wildcards", "test/plugin/data/log_numeric/[0-1][2-4].log"],
"asterisk" => [true, "with_wildcards", "test/plugin/data/log/*.log"],
"one character matcher" => [false, "with_wildcards", "test/plugin/data/log/tes?.log"],
sub_test_case "only_use_backward_compatible" do
data("square brackets" => [false, "backward_compatible", "test/plugin/data/log_numeric/[0-1][2-4].log"],
"asterisk" => [true, "backward_compatible", "test/plugin/data/log/*.log"],
"one character matcher" => [false, "backward_compatible", "test/plugin/data/log/tes?.log"],
)
def test_expand_paths_with_use_glob_p
result, option, path = data
Expand All @@ -1576,7 +1576,7 @@ def test_expand_paths_with_use_glob_p
"pos_file" => "#{@tmp_dir}/tail.pos",
"read_from_head" => true,
"refresh_interval" => 30,
"enable_glob" => option,
"glob_policy" => option,
"rotate_wait" => "#{EX_ROTATE_WAIT}s",
"follow_inodes" => "#{EX_FOLLOW_INODES}",
})
Expand All @@ -1594,7 +1594,7 @@ def ex_config_with_brackets
"pos_file" => "#{@tmp_dir}/tail.pos",
"read_from_head" => true,
"refresh_interval" => 30,
"enable_glob" => "always",
"glob_policy" => "extended",
"rotate_wait" => "#{EX_ROTATE_WAIT}s",
"follow_inodes" => "#{EX_FOLLOW_INODES}",
})
Expand Down

0 comments on commit 705d5ea

Please sign in to comment.