diff --git a/CHANGELOG.md b/CHANGELOG.md index 6bb4c6f..607c8ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 3.8.1 + - Feat: cast true/false values for additional_settings [#232](https://github.com/logstash-plugins/logstash-input-s3/pull/232) + ## 3.8.0 - Add ECS v8 support. diff --git a/lib/logstash/inputs/s3.rb b/lib/logstash/inputs/s3.rb index 91b51d5..3852d82 100644 --- a/lib/logstash/inputs/s3.rb +++ b/lib/logstash/inputs/s3.rb @@ -353,14 +353,22 @@ def sincedb_file end def symbolized_settings - @symbolized_settings ||= symbolize(@additional_settings) + @symbolized_settings ||= symbolize_keys_and_cast_true_false(@additional_settings) end - def symbolize(hash) - return hash unless hash.is_a?(Hash) - symbolized = {} - hash.each { |key, value| symbolized[key.to_sym] = symbolize(value) } - symbolized + def symbolize_keys_and_cast_true_false(hash) + case hash + when Hash + symbolized = {} + hash.each { |key, value| symbolized[key.to_sym] = symbolize_keys_and_cast_true_false(value) } + symbolized + when 'true' + true + when 'false' + false + else + hash + end end def ignore_filename?(filename) diff --git a/logstash-input-s3.gemspec b/logstash-input-s3.gemspec index 043d79c..021849a 100644 --- a/logstash-input-s3.gemspec +++ b/logstash-input-s3.gemspec @@ -1,7 +1,7 @@ Gem::Specification.new do |s| s.name = 'logstash-input-s3' - s.version = '3.8.0' + s.version = '3.8.1' s.licenses = ['Apache-2.0'] s.summary = "Streams events from files in a S3 bucket" 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" diff --git a/spec/inputs/s3_spec.rb b/spec/inputs/s3_spec.rb index f4a06d7..9d9eb4c 100644 --- a/spec/inputs/s3_spec.rb +++ b/spec/inputs/s3_spec.rb @@ -84,10 +84,10 @@ end describe "additional_settings" do - context 'when force_path_style is set' do + context "supported settings" do let(:settings) { { - "additional_settings" => { "force_path_style" => true }, + "additional_settings" => { "force_path_style" => 'true', "ssl_verify_peer" => 'false', "profile" => 'logstash' }, "bucket" => "logstash-test", } } @@ -95,7 +95,7 @@ it 'should instantiate AWS::S3 clients with force_path_style set' do expect(Aws::S3::Resource).to receive(:new).with({ :region => subject.region, - :force_path_style => true + :force_path_style => true, :ssl_verify_peer => false, :profile => 'logstash' }).and_call_original subject.send(:get_s3object)