Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parser_csv, parser_syslog: Fix a naming conflict on parser_type #3302

Merged
merged 1 commit into from
Mar 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/fluent/plugin/parser_csv.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ class CSVParser < Parser
desc 'The delimiter character (or string) of CSV values'
config_param :delimiter, :string, default: ','
desc 'The parser type used to parse CSV line'
config_param :parser_type, :enum, list: [:normal, :fast], default: :normal
config_param :parser_engine, :enum, list: [:normal, :fast], default: :normal, alias: :parser_type

def configure(conf)
super


if @parser_type == :fast
if @parser_engine == :fast
@quote_char = '"'
@escape_pattern = Regexp.compile(@quote_char * 2)

Expand Down
4 changes: 2 additions & 2 deletions lib/fluent/plugin/parser_syslog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class SyslogParser < Parser
desc 'Specify time format for event time for rfc5424 protocol'
config_param :rfc5424_time_format, :string, default: "%Y-%m-%dT%H:%M:%S.%L%z"
desc 'The parser type used to parse syslog message'
config_param :parser_type, :enum, list: [:regexp, :string], default: :regexp
config_param :parser_engine, :enum, list: [:regexp, :string], default: :regexp, alias: :parser_type
desc 'support colonless ident in string parser'
config_param :support_colonless_ident, :bool, default: true

Expand All @@ -79,7 +79,7 @@ def initialize
def configure(conf)
super

@regexp_parser = @parser_type == :regexp
@regexp_parser = @parser_engine == :regexp
@regexp = case @message_format
when :rfc3164
if @regexp_parser
Expand Down
14 changes: 14 additions & 0 deletions test/plugin/test_parser_csv.rb
Original file line number Diff line number Diff line change
Expand Up @@ -183,4 +183,18 @@ def test_incompatibility_between_normal_and_fast_parser
# And more...
end
end

# "parser_type" config shouldn't hide Fluent::Plugin::Parser#plugin_type
# https://github.com/fluent/fluentd/issues/3296
data('normal' => :normal, 'fast' => :fast)
def test_parser_type_method(engine)
d = create_driver('keys' => '["time"]','time_key' => 'time', 'parser_type' => engine.to_s)
assert_equal(:text_per_line, d.instance.parser_type)
end

data('normal' => :normal, 'fast' => :fast)
def test_parser_engine(engine)
d = create_driver('keys' => '["time"]', 'time_key' => 'time', 'parser_engine' => engine.to_s)
assert_equal(engine, d.instance.parser_engine)
end
end
14 changes: 14 additions & 0 deletions test/plugin/test_parser_syslog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -633,4 +633,18 @@ def test_parse_with_both_message_type_and_priority(param)
end
end
end

# "parser_type" config shouldn't hide Fluent::Plugin::Parser#plugin_type
# https://github.com/fluent/fluentd/issues/3296
data('regexp' => :regexp, 'fast' => :string)
def test_parser_type_method(engine)
@parser.configure({'parser_type' => engine.to_s})
assert_equal(:text_per_line, @parser.instance.parser_type)
end

data('regexp' => :regexp, 'string' => :string)
def test_parser_engine(engine)
d = @parser.configure({'parser_engine' => engine.to_s})
assert_equal(engine, @parser.instance.parser_engine)
end
end