Skip to content

Commit

Permalink
Don't use keyword argument for Configurable::configure
Browse files Browse the repository at this point in the history
Since the first argument inherits Hash class, it's confusing.

Signed-off-by: Takuro Ashie <ashie@clear-code.com>
  • Loading branch information
ashie committed Dec 5, 2019
1 parent f13d48b commit 6e187f7
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/fluent/configurable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def configured_section_create(name, conf = nil)
Fluent::Config::SectionGenerator.generate(proxy, conf, nil, nil)
end

def configure(conf, strict_config_value: false)
def configure(conf, strict_config_value=false)
@config = conf

logger = if self.respond_to?(:log)
Expand Down
2 changes: 1 addition & 1 deletion lib/fluent/plugin/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def configure(conf)
end
system_config_override(workers: workers)
end
super(conf, strict_config_value: system_config.strict_config_value)
super(conf, system_config.strict_config_value)
@_state ||= State.new(false, false, false, false, false, false, false, false, false)
@_state.configure = true
self
Expand Down
8 changes: 4 additions & 4 deletions lib/fluent/system_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class SystemConfig
config_param :timeout, :time, default: nil
end

def self.create(conf, strict_config_value: false)
def self.create(conf, strict_config_value=false)
systems = conf.elements(name: 'system')
return SystemConfig.new if systems.empty?
raise Fluent::ConfigError, "<system> is duplicated. <system> should be only one" if systems.size > 1
Expand All @@ -100,17 +100,17 @@ def self.overwrite_system_config(hash)
def initialize(conf=nil, strict_config_value=false)
super()
conf ||= SystemConfig.blank_system_config
configure(conf, strict_config_value: strict_config_value)
configure(conf, strict_config_value)
end

def configure(conf, strict_config_value: false)
def configure(conf, strict_config_value=false)
strict = strict_config_value
if !strict && conf && conf.has_key?("strict_config_value")
strict = Fluent::Config.bool_value(conf["strict_config_value"])
end

begin
super(conf, strict_config_value: strict)
super(conf, strict)
rescue ConfigError => e
$log.error "config error in:\n#{conf}"
$log.error 'config error', error: e
Expand Down
4 changes: 2 additions & 2 deletions test/config/test_configurable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ class TestConfigurable < ::Test::Unit::TestCase

c = ConfigurableSpec::ExampleWithIntFloat.new
assert_nothing_raised { c.configure(default) }
assert_raise(Fluent::ConfigError) { c.configure(default, strict_config_value: true) }
assert_raise(Fluent::ConfigError) { c.configure(default, true) }
end
end

Expand Down Expand Up @@ -1714,7 +1714,7 @@ class TestClass01
c = TestClass01.new
subsection = config_element('subsection', "hoge", { })
assert_raise(Fluent::ConfigError.new('param1: invalid value for Integer(): "hoge"')) do
c.configure(config_element('root', '', {}, [subsection]), strict_config_value: true)
c.configure(config_element('root', '', {}, [subsection]), true)
end
end

Expand Down

0 comments on commit 6e187f7

Please sign in to comment.