88import org .jruby .runtime .builtin .IRubyObject ;
99import org .logstash .RubyUtil ;
1010import org .logstash .Rubyfier ;
11- import org .logstash .common .EnvironmentVariableProvider ;
1211import org .logstash .common .SourceWithMetadata ;
1312import org .logstash .config .ir .compiler .AbstractFilterDelegatorExt ;
1413import org .logstash .config .ir .compiler .AbstractOutputDelegatorExt ;
2322import org .logstash .config .ir .graph .Vertex ;
2423import org .logstash .config .ir .imperative .PluginStatement ;
2524import org .logstash .ext .JrubyEventExtLibrary ;
26- import org .logstash .plugins .ConfigVariableExpander ;
27- import org .logstash .secret .store .SecretStore ;
2825
29- import java .util .ArrayList ;
3026import java .util .Collection ;
3127import java .util .Collections ;
3228import java .util .HashMap ;
3329import java .util .HashSet ;
34- import java .util .List ;
3530import java .util .Map ;
3631import java .util .Objects ;
3732import java .util .stream .Collectors ;
@@ -78,27 +73,13 @@ public final class CompiledPipeline {
7873 */
7974 private final RubyIntegration .PluginFactory pluginFactory ;
8075
81- public CompiledPipeline (
82- final PipelineIR pipelineIR ,
83- final RubyIntegration .PluginFactory pluginFactory ) {
84- this (pipelineIR , pluginFactory , null );
85- }
86-
87- public CompiledPipeline (
88- final PipelineIR pipelineIR ,
89- final RubyIntegration .PluginFactory pluginFactory ,
90- final SecretStore secretStore ) {
76+ public CompiledPipeline (final PipelineIR pipelineIR ,
77+ final RubyIntegration .PluginFactory pluginFactory ) {
9178 this .pipelineIR = pipelineIR ;
9279 this .pluginFactory = pluginFactory ;
93- try (ConfigVariableExpander cve = new ConfigVariableExpander (
94- secretStore ,
95- EnvironmentVariableProvider .defaultProvider ())) {
96- inputs = setupInputs (cve );
97- filters = setupFilters (cve );
98- outputs = setupOutputs (cve );
99- } catch (Exception e ) {
100- throw new IllegalStateException ("Unable to configure plugins: " + e .getMessage ());
101- }
80+ inputs = setupInputs ();
81+ filters = setupFilters ();
82+ outputs = setupOutputs ();
10283 }
10384
10485 public Collection <AbstractOutputDelegatorExt > outputs () {
@@ -125,15 +106,15 @@ public Dataset buildExecution() {
125106 /**
126107 * Sets up all outputs learned from {@link PipelineIR}.
127108 */
128- private Map <String , AbstractOutputDelegatorExt > setupOutputs (ConfigVariableExpander cve ) {
109+ private Map <String , AbstractOutputDelegatorExt > setupOutputs () {
129110 final Collection <PluginVertex > outs = pipelineIR .getOutputPluginVertices ();
130111 final Map <String , AbstractOutputDelegatorExt > res = new HashMap <>(outs .size ());
131112 outs .forEach (v -> {
132113 final PluginDefinition def = v .getPluginDefinition ();
133114 final SourceWithMetadata source = v .getSourceWithMetadata ();
134115 res .put (v .getId (), pluginFactory .buildOutput (
135116 RubyUtil .RUBY .newString (def .getName ()), RubyUtil .RUBY .newFixnum (source .getLine ()),
136- RubyUtil .RUBY .newFixnum (source .getColumn ()), convertArgs (def ), convertJavaArgs (def , cve )
117+ RubyUtil .RUBY .newFixnum (source .getColumn ()), convertArgs (def ), convertJavaArgs (def )
137118 ));
138119 });
139120 return res ;
@@ -142,7 +123,7 @@ private Map<String, AbstractOutputDelegatorExt> setupOutputs(ConfigVariableExpan
142123 /**
143124 * Sets up all Ruby filters learnt from {@link PipelineIR}.
144125 */
145- private Map <String , AbstractFilterDelegatorExt > setupFilters (ConfigVariableExpander cve ) {
126+ private Map <String , AbstractFilterDelegatorExt > setupFilters () {
146127 final Collection <PluginVertex > filterPlugins = pipelineIR .getFilterPluginVertices ();
147128 final Map <String , AbstractFilterDelegatorExt > res = new HashMap <>(filterPlugins .size (), 1.0F );
148129
@@ -151,7 +132,7 @@ private Map<String, AbstractFilterDelegatorExt> setupFilters(ConfigVariableExpan
151132 final SourceWithMetadata source = vertex .getSourceWithMetadata ();
152133 res .put (vertex .getId (), pluginFactory .buildFilter (
153134 RubyUtil .RUBY .newString (def .getName ()), RubyUtil .RUBY .newFixnum (source .getLine ()),
154- RubyUtil .RUBY .newFixnum (source .getColumn ()), convertArgs (def ), convertJavaArgs (def , cve )
135+ RubyUtil .RUBY .newFixnum (source .getColumn ()), convertArgs (def ), convertJavaArgs (def )
155136 ));
156137 }
157138 return res ;
@@ -160,15 +141,15 @@ private Map<String, AbstractFilterDelegatorExt> setupFilters(ConfigVariableExpan
160141 /**
161142 * Sets up all Ruby inputs learnt from {@link PipelineIR}.
162143 */
163- private Collection <IRubyObject > setupInputs (ConfigVariableExpander cve ) {
144+ private Collection <IRubyObject > setupInputs () {
164145 final Collection <PluginVertex > vertices = pipelineIR .getInputPluginVertices ();
165146 final Collection <IRubyObject > nodes = new HashSet <>(vertices .size ());
166147 vertices .forEach (v -> {
167148 final PluginDefinition def = v .getPluginDefinition ();
168149 final SourceWithMetadata source = v .getSourceWithMetadata ();
169150 IRubyObject o = pluginFactory .buildInput (
170151 RubyUtil .RUBY .newString (def .getName ()), RubyUtil .RUBY .newFixnum (source .getLine ()),
171- RubyUtil .RUBY .newFixnum (source .getColumn ()), convertArgs (def ), convertJavaArgs (def , cve ));
152+ RubyUtil .RUBY .newFixnum (source .getColumn ()), convertArgs (def ), convertJavaArgs (def ));
172153 nodes .add (o );
173154 });
174155 return nodes ;
@@ -209,47 +190,23 @@ private RubyHash convertArgs(final PluginDefinition def) {
209190 * @return Map of plugin arguments as understood by the {@link RubyIntegration.PluginFactory}
210191 * methods that create Java plugins
211192 */
212- private Map <String , Object > convertJavaArgs (final PluginDefinition def , ConfigVariableExpander cve ) {
213- Map <String , Object > args = expandConfigVariables (cve , def .getArguments ());
214- for (final Map .Entry <String , Object > entry : args .entrySet ()) {
193+ private Map <String , Object > convertJavaArgs (final PluginDefinition def ) {
194+ for (final Map .Entry <String , Object > entry : def .getArguments ().entrySet ()) {
215195 final Object value = entry .getValue ();
216196 final String key = entry .getKey ();
217197 final IRubyObject toput ;
218198 if (value instanceof PluginStatement ) {
219199 final PluginDefinition codec = ((PluginStatement ) value ).getPluginDefinition ();
220- Map <String , Object > codecArgs = expandConfigVariables (cve , codec .getArguments ());
221200 toput = pluginFactory .buildCodec (
222201 RubyUtil .RUBY .newString (codec .getName ()),
223202 Rubyfier .deep (RubyUtil .RUBY , codec .getArguments ()),
224- codecArgs
203+ codec . getArguments ()
225204 );
226205 Codec javaCodec = (Codec )JavaUtil .unwrapJavaValue (toput );
227- args .put (key , javaCodec );
228- }
229- }
230- return args ;
231- }
232-
233- @ SuppressWarnings ({"rawtypes" , "unchecked" })
234- private Map <String , Object > expandConfigVariables (ConfigVariableExpander cve , Map <String , Object > configArgs ) {
235- Map <String , Object > expandedConfig = new HashMap <>();
236- for (Map .Entry <String , Object > e : configArgs .entrySet ()) {
237- if (e .getValue () instanceof List ) {
238- List list = (List ) e .getValue ();
239- List <Object > expandedObjects = new ArrayList <>();
240- for (Object o : list ) {
241- expandedObjects .add (cve .expand (o ));
242- }
243- expandedConfig .put (e .getKey (), expandedObjects );
244- } else if (e .getValue () instanceof Map ) {
245- expandedConfig .put (e .getKey (), expandConfigVariables (cve , (Map <String , Object >) e .getValue ()));
246- } else if (e .getValue () instanceof String ) {
247- expandedConfig .put (e .getKey (), cve .expand (e .getValue ()));
248- } else {
249- expandedConfig .put (e .getKey (), e .getValue ());
206+ def .getArguments ().put (key , javaCodec );
250207 }
251208 }
252- return expandedConfig ;
209+ return def . getArguments () ;
253210 }
254211
255212 /**
0 commit comments