fluent-plugin-record-reformer 0.8.1 → 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5c12a8d7d13aa7b7cd2774128c13b1ce7ed4473a
4
- data.tar.gz: 7bf4dd5a13506bd3d9e89acf739d27322bb737e4
3
+ metadata.gz: abcb8c05a4359b363c8a1a0f0cf75a16df123c03
4
+ data.tar.gz: 55d88baf42ee056e4de0f181fae316fcefc451ac
5
5
  SHA512:
6
- metadata.gz: 54d23d63dca07dad339103db47a0b7374ef6aef190f4d8e64b984a625ac40b1e158a46f2c9b6aa8c735f1701a19fe0fc16418ba39d4e06052307756d1e0f96b3
7
- data.tar.gz: fda86acdd87b031272f229b8162a2b2b77caa07788e0db8076fb9e84f8cb74ab865aa6a15be579928aba42e38c904b7ae5eeddabb377596a50dbcf96b9a31e40
6
+ metadata.gz: de246d926ea5785af76414cc7d8d60acde19cc552d8a81e988ca91a290f0ce41c77482a29d18ef99f9953097b958a6ec695ad7db7d8276e8721063bc6716fd72
7
+ data.tar.gz: d905845078c70d674b33098b4269fd62ba76d32a3fb3ef9e1bcc9758138b359e7d08c15313f1a4b7d12abbf09bcdb9ce4eec516837f6ff977fd4b372052f339f
@@ -1,9 +1,14 @@
1
1
  rvm:
2
- - 2.0.0
2
+ - 2.0.*
3
3
  - 2.1.*
4
4
  - 2.2.*
5
5
  - 2.3.0
6
6
  gemfile:
7
7
  - Gemfile
8
+ - Gemfile.fluentd.0.12
8
9
  - Gemfile.fluentd.0.10
10
+ matrix:
11
+ exclude:
12
+ - rvm: 2.0.*
13
+ gemfile: Gemfile
9
14
  before_install: gem update bundler
@@ -1,3 +1,9 @@
1
+ ## 0.8.2 (2016/08/21)
2
+
3
+ Fixes
4
+
5
+ * Prevent overwriting reserved placeholder keys such as tag, time, etc with `enable_ruby false` (thanks to @kimamula)
6
+
1
7
  ## 0.8.1 (2016/03/09)
2
8
 
3
9
  Fixes
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem 'fluentd', '~> 0.12.0'
4
+ gemspec
@@ -3,7 +3,7 @@ $:.push File.expand_path('../lib', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
5
  gem.name = "fluent-plugin-record-reformer"
6
- gem.version = "0.8.1"
6
+ gem.version = "0.8.2"
7
7
  gem.authors = ["Naotoshi Seo"]
8
8
  gem.email = "sonots@gmail.com"
9
9
  gem.homepage = "https://github.com/sonots/fluent-plugin-record-reformer"
@@ -22,6 +22,6 @@ Gem::Specification.new do |gem|
22
22
  gem.add_development_dependency "pry"
23
23
  gem.add_development_dependency "pry-nav"
24
24
  gem.add_development_dependency "test-unit"
25
- gem.add_development_dependency "rr"
25
+ gem.add_development_dependency "test-unit-rr"
26
26
  gem.add_development_dependency "timecop"
27
27
  end
@@ -209,6 +209,7 @@ module Fluent
209
209
 
210
210
  def prepare_placeholders(placeholder_values)
211
211
  placeholders = {}
212
+ reserved_keys = Set.new(placeholder_values.keys)
212
213
 
213
214
  placeholder_values.each do |key, value|
214
215
  if value.kind_of?(Array) # tag_parts, etc
@@ -219,7 +220,9 @@ module Fluent
219
220
  end
220
221
  elsif value.kind_of?(Hash) # record, etc
221
222
  value.each do |k, v|
222
- placeholders.store("${#{k}}", v) # foo
223
+ unless reserved_keys.include?(k) # prevent overwriting the reserved keys such as tag
224
+ placeholders.store("${#{k}}", v)
225
+ end
223
226
  placeholders.store(%Q[${#{key}["#{k}"]}], v) # record["foo"]
224
227
  end
225
228
  else # string, interger, float, and others?
@@ -1,4 +1,6 @@
1
1
  require 'test/unit'
2
+ require 'test/unit/rr'
3
+ require 'timecop'
2
4
  require 'fluent/log'
3
5
  require 'fluent/test'
4
6
 
@@ -1,7 +1,5 @@
1
1
  require_relative 'helper'
2
- require 'rr'
3
2
  require 'time'
4
- require 'timecop'
5
3
  require 'fluent/plugin/out_record_reformer'
6
4
 
7
5
  Fluent::Test.setup
@@ -26,12 +24,11 @@ class RecordReformerOutputTest < Test::Unit::TestCase
26
24
  def emit(config, use_v1, msgs = [''])
27
25
  d = create_driver(config, use_v1)
28
26
  d.run do
29
- msgs.each do |msg|
30
- record = {
31
- 'eventType0' => 'bar',
32
- 'message' => msg,
33
- }
34
- record = record.merge(msg) if msg.is_a?(Hash)
27
+ records = msgs.map do |msg|
28
+ next msg if msg.is_a?(Hash)
29
+ { 'eventType0' => 'bar', 'message' => msg }
30
+ end
31
+ records.each do |record|
35
32
  d.emit(record, @time)
36
33
  end
37
34
  end
@@ -298,6 +295,29 @@ EOC
298
295
  end
299
296
  end
300
297
 
298
+ test "Prevent overriting reserved keys (such as tag, etc) #40 with enable_ruby #{enable_ruby}" do
299
+ config = %[
300
+ tag tag
301
+ enable_ruby #{enable_ruby}
302
+ <record>
303
+ new_tag ${tag}
304
+ new_time ${time}
305
+ new_record_tag ${record["tag"]}
306
+ new_record_time ${record["time"]}
307
+ </record>
308
+ ]
309
+ records = [{'tag' => 'tag', 'time' => 'time'}]
310
+ emits = emit(config, use_v1, records)
311
+ emits.each do |(tag, time, record)|
312
+ assert_not_equal('tag', record['new_tag'])
313
+ assert_equal(@tag, record['new_tag'])
314
+ assert_not_equal('time', record['new_time'])
315
+ assert_equal(@time.to_s, record['new_time'])
316
+ assert_equal('tag', record['new_record_tag'])
317
+ assert_equal('time', record['new_record_time'])
318
+ end
319
+ end
320
+
301
321
  test "hash values with placeholders with enable_ruby #{enable_ruby}" do
302
322
  config = %[
303
323
  tag tag
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-record-reformer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naotoshi Seo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-09 00:00:00.000000000 Z
11
+ date: 2016-08-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd
@@ -81,7 +81,7 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: rr
84
+ name: test-unit-rr
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - ">="
@@ -120,6 +120,7 @@ files:
120
120
  - CHANGELOG.md
121
121
  - Gemfile
122
122
  - Gemfile.fluentd.0.10
123
+ - Gemfile.fluentd.0.12
123
124
  - LICENSE
124
125
  - README.md
125
126
  - Rakefile