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

Fix a bug storage_create cannot accept hash as conf keyword argument #1482

Merged
merged 1 commit into from
Mar 2, 2017
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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