Skip to content

Commit

Permalink
Feat: cast true/false values for additional_settings (#232)
Browse files Browse the repository at this point in the history
* Feat: cast true/false values for additional_settings

This allows us to properly set additional AWS settings e.g.

```ruby
output {
  s3 {
    ...
    additional_settings => {
      force_path_style => true
      ssl_verify_peer => false
    }
  }
}
```
  • Loading branch information
kares authored Oct 13, 2021
1 parent 26853ba commit 0d4a564
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 10 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
20 changes: 14 additions & 6 deletions lib/logstash/inputs/s3.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion logstash-input-s3.gemspec
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
6 changes: 3 additions & 3 deletions spec/inputs/s3_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,18 @@
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",
}
}

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)
Expand Down

0 comments on commit 0d4a564

Please sign in to comment.