Skip to content

Commit ff42372

Browse files
authored
Feat: cast true/false values for additional_settings (#241)
1 parent b511809 commit ff42372

File tree

4 files changed

+23
-11
lines changed

4 files changed

+23
-11
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 4.3.5
2+
- Feat: cast true/false values for additional_settings [#241](https://github.com/logstash-plugins/logstash-output-s3/pull/241)
3+
14
## 4.3.4
25
- [DOC] Added note about performance implications of interpolated strings in prefixes [#233](https://github.com/logstash-plugins/logstash-output-s3/pull/233)
36

lib/logstash/outputs/s3.rb

+14-7
Original file line numberDiff line numberDiff line change
@@ -283,17 +283,24 @@ def full_options
283283
end
284284

285285
def symbolized_settings
286-
@symbolized_settings ||= symbolize_keys(@additional_settings)
286+
@symbolized_settings ||= symbolize_keys_and_cast_true_false(@additional_settings)
287287
end
288288

289-
def symbolize_keys(hash)
290-
return hash unless hash.is_a?(Hash)
291-
symbolized = {}
292-
hash.each { |key, value| symbolized[key.to_sym] = symbolize_keys(value) }
293-
symbolized
289+
def symbolize_keys_and_cast_true_false(hash)
290+
case hash
291+
when Hash
292+
symbolized = {}
293+
hash.each { |key, value| symbolized[key.to_sym] = symbolize_keys_and_cast_true_false(value) }
294+
symbolized
295+
when 'true'
296+
true
297+
when 'false'
298+
false
299+
else
300+
hash
301+
end
294302
end
295303

296-
297304
def normalize_key(prefix_key)
298305
prefix_key.gsub(PathValidator.matches_re, PREFIX_KEY_NORMALIZE_CHARACTER)
299306
end

logstash-output-s3.gemspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Gem::Specification.new do |s|
22
s.name = 'logstash-output-s3'
3-
s.version = '4.3.4'
3+
s.version = '4.3.5'
44
s.licenses = ['Apache-2.0']
55
s.summary = "Sends Logstash events to the Amazon Simple Storage Service"
66
s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"

spec/outputs/s3_spec.rb

+5-3
Original file line numberDiff line numberDiff line change
@@ -160,13 +160,15 @@
160160
end
161161

162162
describe "additional_settings" do
163-
context "when enabling force_path_style" do
163+
context "supported settings" do
164164
let(:additional_settings) do
165-
{ "additional_settings" => { "force_path_style" => true } }
165+
{ "additional_settings" => { "force_path_style" => 'true', "ssl_verify_peer" => 'false', "profile" => 'logstash' } }
166166
end
167167

168168
it "validates the prefix" do
169-
expect(Aws::S3::Bucket).to receive(:new).twice.with(anything, hash_including(:force_path_style => true)).and_call_original
169+
expect(Aws::S3::Bucket).to receive(:new).twice.
170+
with(anything, hash_including(:force_path_style => true, :ssl_verify_peer => false, :profile => 'logstash')).
171+
and_call_original
170172
described_class.new(options.merge(additional_settings)).register
171173
end
172174
end

0 commit comments

Comments
 (0)