Skip to content

Commit

Permalink
Plugin: intercept string-specified codecs and propagate execution_con…
Browse files Browse the repository at this point in the history
…text
  • Loading branch information
yaauie committed Oct 5, 2020
1 parent cd200a8 commit 0161b4d
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions logstash-core/lib/logstash/config/mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,17 @@ def config_init(params)
params[name.to_s] = deep_replace(value)
end

# Intercept codecs that have not been instantiated
params.each do |name, value|
validator = self.class.validator_find(name)
next unless validator && validator[:validate] == :codec && value.kind_of?(String)

codec_klass = LogStash::Plugin.lookup("codec", value)
codec_instance = LogStash::Plugins::Contextualizer.initialize_plugin(execution_context, codec_klass)

params[name.to_s] = LogStash::Codecs::Delegator.new(codec_instance)
end

if !self.class.validate(params)
raise LogStash::ConfigurationError,
I18n.t("logstash.runner.configuration.invalid_plugin_settings")
Expand Down

0 comments on commit 0161b4d

Please sign in to comment.