Skip to content

Commit

Permalink
Merge pull request #1482 from okkez/storage-create-can-accept-hash
Browse files Browse the repository at this point in the history
Fix a bug storage_create cannot accept hash as `conf` keyword argument
  • Loading branch information
repeatedly authored Mar 2, 2017
2 parents 0e60445 + 997e1cb commit c728188
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/fluent/plugin_helper/storage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ module Storage
StorageState = Struct.new(:storage, :running)

def storage_create(usage: '', type: nil, conf: nil, default_type: nil)
if conf && !conf.arg.empty?
if conf && conf.respond_to?(:arg) && !conf.arg.empty?
usage = conf.arg
end
if !usage.empty? && usage !~ /^[a-zA-Z][-_.a-zA-Z0-9]*$/
Expand Down
9 changes: 9 additions & 0 deletions test/plugin_helper/test_storage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,15 @@ class Dummy2 < Fluent::Plugin::TestBase
assert_equal 0, d._storages.size
end

test 'can be configured with hash' do
d = Dummy.new
d.configure(config_element())
conf = { '@type' => 'example' }
assert_nothing_raised do
d.storage_create(conf: conf)
end
end

test 'can override default configuration parameters, but not overwrite whole definition' do
d = Dummy.new
d.configure(config_element())
Expand Down

0 comments on commit c728188

Please sign in to comment.