diff --git a/lib/fluent/config/configure_proxy.rb b/lib/fluent/config/configure_proxy.rb index ca8c1521fa..4db4fd4ef0 100644 --- a/lib/fluent/config/configure_proxy.rb +++ b/lib/fluent/config/configure_proxy.rb @@ -117,9 +117,9 @@ def merge(other) # self is base class, other is subclass merged = if self.root? options[:root] = true - self.class.new(other.name, options) + self.class.new(other.name, **options) else - self.class.new(@name, options) + self.class.new(@name, **options) end # configured_in MUST be kept @@ -172,9 +172,9 @@ def merge_for_finalized(other) merged = if self.root? options[:root] = true - self.class.new(other.name, options) + self.class.new(other.name, **options) else - self.class.new(@name, options) + self.class.new(@name, **options) end merged.configured_in_section = self.configured_in_section || other.configured_in_section diff --git a/lib/fluent/plugin/buffer/chunk.rb b/lib/fluent/plugin/buffer/chunk.rb index 95e9a3a803..cab45cc91f 100644 --- a/lib/fluent/plugin/buffer/chunk.rb +++ b/lib/fluent/plugin/buffer/chunk.rb @@ -202,7 +202,7 @@ def open(**kwargs, &block) if kwargs[:compressed] == :gzip super else - super(kwargs) do |chunk_io| + super(**kwargs) do |chunk_io| output_io = if chunk_io.is_a?(StringIO) StringIO.new else diff --git a/lib/fluent/plugin/formatter_csv.rb b/lib/fluent/plugin/formatter_csv.rb index def855abca..100bcbff6b 100644 --- a/lib/fluent/plugin/formatter_csv.rb +++ b/lib/fluent/plugin/formatter_csv.rb @@ -56,7 +56,7 @@ def configure(conf) end def format(tag, time, record) - csv = (@cache[Thread.current] ||= CSV.new("".force_encoding(Encoding::ASCII_8BIT), @generate_opts)) + csv = (@cache[Thread.current] ||= CSV.new("".force_encoding(Encoding::ASCII_8BIT), **@generate_opts)) line = (csv << record).string.dup # Need manual cleanup because CSV writer doesn't provide such method. csv.rewind @@ -65,7 +65,7 @@ def format(tag, time, record) end def format_with_nested_fields(tag, time, record) - csv = (@cache[Thread.current] ||= CSV.new("".force_encoding(Encoding::ASCII_8BIT), @generate_opts)) + csv = (@cache[Thread.current] ||= CSV.new("".force_encoding(Encoding::ASCII_8BIT), **@generate_opts)) values = @accessors.map { |a| a.call(record) } line = (csv << values).string.dup # Need manual cleanup because CSV writer doesn't provide such method. diff --git a/lib/fluent/plugin_helper/child_process.rb b/lib/fluent/plugin_helper/child_process.rb index 9967097c31..801e840029 100644 --- a/lib/fluent/plugin_helper/child_process.rb +++ b/lib/fluent/plugin_helper/child_process.rb @@ -267,19 +267,19 @@ def child_process_execute_once( end if mode.include?(:write) - writeio.set_encoding(external_encoding, internal_encoding, encoding_options) + writeio.set_encoding(external_encoding, internal_encoding, **encoding_options) writeio_in_use = true else writeio.reopen(IO::NULL) if writeio end if mode.include?(:read) || mode.include?(:read_with_stderr) - readio.set_encoding(external_encoding, internal_encoding, encoding_options) + readio.set_encoding(external_encoding, internal_encoding, **encoding_options) readio_in_use = true else readio.reopen(IO::NULL) if readio end if mode.include?(:stderr) - stderrio.set_encoding(external_encoding, internal_encoding, encoding_options) + stderrio.set_encoding(external_encoding, internal_encoding, **encoding_options) stderrio_in_use = true else stderrio.reopen(IO::NULL) if stderrio && stderr == :discard diff --git a/lib/fluent/plugin_helper/extract.rb b/lib/fluent/plugin_helper/extract.rb index 79144c8de1..70b3dfccc9 100644 --- a/lib/fluent/plugin_helper/extract.rb +++ b/lib/fluent/plugin_helper/extract.rb @@ -55,7 +55,7 @@ module ExtractParams config_param :time_type, :enum, list: [:float, :unixtime, :string], default: :float Fluent::TimeMixin::TIME_PARAMETERS.each do |name, type, opts| - config_param name, type, opts + config_param(name, type, **opts) end end end diff --git a/lib/fluent/plugin_helper/inject.rb b/lib/fluent/plugin_helper/inject.rb index 8eec19c568..9f9f59906c 100644 --- a/lib/fluent/plugin_helper/inject.rb +++ b/lib/fluent/plugin_helper/inject.rb @@ -79,7 +79,7 @@ module InjectParams config_param :time_type, :enum, list: [:float, :unixtime, :string], default: :float Fluent::TimeMixin::TIME_PARAMETERS.each do |name, type, opts| - config_param name, type, opts + config_param(name, type, **opts) end end end diff --git a/lib/fluent/plugin_helper/server.rb b/lib/fluent/plugin_helper/server.rb index db151c142a..536e80b00d 100644 --- a/lib/fluent/plugin_helper/server.rb +++ b/lib/fluent/plugin_helper/server.rb @@ -690,9 +690,9 @@ def write(data) end if RUBY_VERSION.to_f >= 2.3 - NONBLOCK_ARG = {exception: false} + NONBLOCK_ARG = { exception: false } def try_handshake - @_handler_socket.accept_nonblock(NONBLOCK_ARG) + @_handler_socket.accept_nonblock(**NONBLOCK_ARG) end else def try_handshake diff --git a/lib/fluent/test/driver/base_owned.rb b/lib/fluent/test/driver/base_owned.rb index 45fbde3661..236750d159 100644 --- a/lib/fluent/test/driver/base_owned.rb +++ b/lib/fluent/test/driver/base_owned.rb @@ -53,13 +53,26 @@ def initialize(klass, opts: {}, &block) @section_name = '' end - def configure(conf, syntax: :v1) + def configure(conf) if conf.is_a?(Fluent::Config::Element) @config = conf elsif conf.is_a?(Hash) @config = Fluent::Config::Element.new(@section_name, "", Hash[conf.map{|k,v| [k.to_s, v]}], []) else - @config = Fluent::Config.parse(conf, @section_name, "", syntax: syntax) + @config = Fluent::Config.parse(conf, @section_name, "", syntax: :v1) + end + @instance.configure(@config) + self + end + + # this is special method for v0 and should be deleted + def configure_v0(conf) + if conf.is_a?(Fluent::Config::Element) + @config = conf + elsif conf.is_a?(Hash) + @config = Fluent::Config::Element.new(@section_name, "", Hash[conf.map{|k,v| [k.to_s, v]}], []) + else + @config = Fluent::Config.parse(conf, @section_name, "", syntax: :v0) end @instance.configure(@config) self diff --git a/lib/fluent/time.rb b/lib/fluent/time.rb index 52eed0b1f5..e846ad18a9 100644 --- a/lib/fluent/time.rb +++ b/lib/fluent/time.rb @@ -147,7 +147,7 @@ module TimeMixin module TimeParameters include Fluent::Configurable TIME_FULL_PARAMETERS.each do |name, type, opts| - config_param name, type, opts + config_param(name, type, **opts) end def configure(conf) diff --git a/test/counter/test_client.rb b/test/counter/test_client.rb index 9851b6c2de..c6b2ca951f 100644 --- a/test/counter/test_client.rb +++ b/test/counter/test_client.rb @@ -128,7 +128,8 @@ def travel(sec) test 'raise an error when @scope is nil' do @client.instance_variable_set(:@scope, nil) assert_raise 'Call `establish` method to get a `scope` before calling this method' do - @client.init(name: 'key1', reset_interval: 10).get + params = { name: 'key1', reset_interval: 10 } + @client.init(params).get end end @@ -151,7 +152,8 @@ def travel(sec) ] ) test 'return an error object' do |(param, expected_error)| - @client.init(:name => 'key1', :reset_interval => 10).get + params = { name: 'key1', reset_interval: 10 } + @client.init(params).get response = @client.init(param).get errors = response.errors.first @@ -164,7 +166,8 @@ def travel(sec) end test 'return an existing value when passed key already exists and ignore option is true' do - res1 = @client.init(name: 'key1', reset_interval: 10).get + params = { name: 'key1', reset_interval: 10 } + res1 = @client.init(params).get res2 = nil assert_nothing_raised do res2 = @client.init({ name: 'key1', reset_interval: 10 }, options: { ignore: true }).get @@ -312,7 +315,8 @@ def travel(sec) test 'raise an error when @scope is nil' do @client.instance_variable_set(:@scope, nil) assert_raise 'Call `establish` method to get a `scope` before calling this method' do - @client.inc(name: 'name', value: 1).get + params = { name: 'name', value: 1 } + @client.inc(params).get end end