Skip to content

Commit c12bb2c

Browse files
authored
Fix connection placeholder replacements errors (#92)
Fixed connection placeholder replacements errors when running Logstash 8.15.1 and 8.15.2 versions
1 parent 64e90a5 commit c12bb2c

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 1.4.8
2+
- Fixed connection placeholder replacements errors with Logstash `8.15.1` and `8.15.2` [#92](https://github.com/logstash-plugins/logstash-input-azure_event_hubs/pull/92)
3+
14
## 1.4.7
25
- [DOCS] Clarify examples for single and multiple event hubs [#90](https://github.com/logstash-plugins/logstash-input-azure_event_hubs/pull/90)
36

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.4.7
1+
1.4.8

lib/logstash/inputs/azure_event_hubs.rb

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,7 @@ def initialize(params)
332332
connections = *params['event_hub_connections'] # ensure array
333333
connections.each.with_index do |_connection, i|
334334
begin
335-
connection = self.class.replace_placeholders(_connection) if self.class.respond_to? 'replace_placeholders' # 6.x
336-
connection = self.class.replace_env_placeholders(_connection) if self.class.respond_to? 'replace_env_placeholders' # 5.x
335+
connection = replace_connection_placeholders(_connection)
337336
event_hub_name = ConnectionStringBuilder.new(connection).getEventHubName
338337
redacted_connection = connection.gsub(/(SharedAccessKey=)([0-9a-zA-Z=+]*)([;]*)(.*)/, '\\1<redacted>\\3\\4')
339338
params['event_hub_connections'][i] = redacted_connection # protect from leaking logs
@@ -361,6 +360,25 @@ def initialize(params)
361360

362361
attr_reader :event_hubs_exploded
363362

363+
def replace_connection_placeholders(value)
364+
connection = value
365+
if self.class.respond_to? :replace_placeholders
366+
# Logstash 6.x
367+
if self.class.method(:replace_placeholders).arity == 1
368+
connection = self.class.replace_placeholders(connection)
369+
else
370+
# Logstash 8.15.1 and 8.15.2 changed the method arity including a new boolean parameter `refine`.
371+
# This was fixed in 8.15.3. see https://github.com/elastic/logstash/pull/16485
372+
connection = self.class.replace_placeholders(connection, false)
373+
end
374+
end
375+
376+
# Logstash 5.x
377+
connection = self.class.replace_env_placeholders(connection) if self.class.respond_to? :replace_env_placeholders
378+
379+
connection
380+
end
381+
364382
def register
365383
# augment the exploded config with the defaults
366384
@event_hubs_exploded.each do |event_hub|

0 commit comments

Comments
 (0)