Skip to content

Commit

Permalink
Avoid duplicates in path config
Browse files Browse the repository at this point in the history
 - removed duplicate in path config
 - added testcase

Signed-off-by: Vimal Kumar <vimal78@gmail.com>
  • Loading branch information
vimalk78 committed Apr 20, 2020
1 parent a5badcd commit d157ded
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/fluent/plugin/in_tail.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def configure(conf)
raise Fluent::ConfigError, "#{rc} are reserved words: #{@path_delimiter}"
end

@paths = @path.split(@path_delimiter).map(&:strip)
@paths = @path.split(@path_delimiter).map(&:strip).sort().uniq()
if @paths.empty?
raise Fluent::ConfigError, "tail: 'path' parameter is required on tail input"
end
Expand Down
6 changes: 6 additions & 0 deletions test/plugin/test_in_tail.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ def create_driver(conf = SINGLE_LINE_CONFIG, use_common_conf = true)
assert_equal ["tail.txt", "test2", "tmp,dev"], d.instance.paths
end

test "multi paths with same path configured twice" do
c = config_element("ROOT", "", { "path" => "test1.txt,test1.txt", "tag" => "t1", "path_delimiter" => "," })
d = create_driver(c + PARSE_SINGLE_LINE_CONFIG, false)
assert_equal ["test1.txt"], d.instance.paths
end

test "multi paths with invaid path_delimiter" do
c = config_element("ROOT", "", { "path" => "tail.txt|test2|tmp,dev", "tag" => "t1", "path_delimiter" => "*" })
assert_raise(Fluent::ConfigError) do
Expand Down

0 comments on commit d157ded

Please sign in to comment.