From 997e1cb4bf91f467715de93aa9ee0bebd5236540 Mon Sep 17 00:00:00 2001 From: Kenji Okimoto Date: Tue, 28 Feb 2017 14:06:42 +0900 Subject: [PATCH] Fix a bug storage_create cannot accept hash as `conf` keyword argument --- lib/fluent/plugin_helper/storage.rb | 2 +- test/plugin_helper/test_storage.rb | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/fluent/plugin_helper/storage.rb b/lib/fluent/plugin_helper/storage.rb index 78dd5ef6d0..7763042639 100644 --- a/lib/fluent/plugin_helper/storage.rb +++ b/lib/fluent/plugin_helper/storage.rb @@ -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]*$/ diff --git a/test/plugin_helper/test_storage.rb b/test/plugin_helper/test_storage.rb index f77a95ccab..b6f2b2d865 100644 --- a/test/plugin_helper/test_storage.rb +++ b/test/plugin_helper/test_storage.rb @@ -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())