Skip to content

Commit

Permalink
fix to use automatic reserved parameter fetch in plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
tagomoris committed May 20, 2016
1 parent 9415d52 commit acf02c4
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 12 deletions.
4 changes: 2 additions & 2 deletions lib/fluent/plugin/in_monitor_agent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ def plugin_info_by_id(plugin_id, opts={})
# multiple plugins could have the same type
def plugins_info_by_type(type, opts={})
array = all_plugins.select {|pe|
(pe.config['@type'] == type || pe.config['type'] == type) rescue nil
(pe.config['@type'] == type) rescue nil
}
array.map {|pe|
get_monitor_info(pe, opts)
Expand All @@ -391,7 +391,7 @@ def get_monitor_info(pe, opts={})
# Common plugin information
obj['plugin_id'] = pe.plugin_id
obj['plugin_category'] = plugin_category(pe)
obj['type'] = pe.config['@type'] || pe.config['type']
obj['type'] = pe.config['@type']
obj['config'] = pe.config if !opts.has_key?(:with_config) || opts[:with_config]

# run MONITOR_INFO in plugins' instance context and store the info to obj
Expand Down
6 changes: 1 addition & 5 deletions lib/fluent/plugin/multi_output.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,7 @@ def configure(conf)

@stores.each do |store|
store_conf = store.corresponding_config_element
type = store[:@type]
if !type && store_conf['type']
type = store_conf['type']
log.warn "'type' is deprecated, and will be ignored in v1: use '@type' instead."
end
type = store_conf['@type']
unless type
raise Fluent::ConfigError, "Missing '@type' parameter in <store> section"
end
Expand Down
2 changes: 1 addition & 1 deletion lib/fluent/plugin/out_copy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def configure(conf)
conf.elements.select {|e|
e.name == 'store'
}.each {|e|
type = e['@type'] || e['type']
type = e['@type']
unless type
raise ConfigError, "Missing 'type' parameter on <store> directive"
end
Expand Down
2 changes: 1 addition & 1 deletion lib/fluent/plugin/out_roundrobin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def configure(conf)
conf.elements.select {|e|
e.name == 'store'
}.each {|e|
type = e['@type'] || e['type']
type = e['@type']
unless type
raise ConfigError, "Missing 'type' parameter on <store> directive"
end
Expand Down
4 changes: 2 additions & 2 deletions lib/fluent/plugin/output.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class Output < Base
# `<buffer>` and `<secondary>` sections are available only when '#format' and '#write' are implemented
config_section :buffer, param_name: :buffer_config, init: true, required: false, multi: false, final: true do
config_argument :chunk_keys, :array, value_type: :string, default: []
config_param :@type, :string, default: 'memory'
config_param :@type, :string, default: 'memory', alias: :type

config_param :timekey_range, :time, default: nil # range size to be used: `time.to_i / @timekey_range`
config_param :timekey_wait, :time, default: 600
Expand Down Expand Up @@ -90,7 +90,7 @@ class Output < Base
end

config_section :secondary, param_name: :secondary_config, required: false, multi: false, final: true do
config_param :@type, :string, default: nil
config_param :@type, :string, default: nil, alias: :type
config_section :buffer, required: false, multi: false do
# dummy to detect invalid specification for here
end
Expand Down
2 changes: 1 addition & 1 deletion test/plugin/test_multi_output.rb
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def create_output(type=:multi)
assert_equal 4, @i.outputs.size

logs = @i.log.out.logs
assert{ logs.select{|log| log.include?('[warn]') && log.include?("'type' is deprecated, and will be ignored in v1: use '@type' instead.") }.size == 4 }
assert{ logs.select{|log| log.include?('[warn]') && log.include?("'type' is deprecated parameter name. use '@type' instead.") }.size == 4 }
end

test '#emit_events calls #process always' do
Expand Down

0 comments on commit acf02c4

Please sign in to comment.