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 +4 -4
- data/.travis.yml +6 -1
- data/CHANGELOG.md +6 -0
- data/Gemfile.fluentd.0.12 +4 -0
- data/fluent-plugin-record-reformer.gemspec +2 -2
- data/lib/fluent/plugin/out_record_reformer.rb +4 -1
- data/test/helper.rb +2 -0
- data/test/test_out_record_reformer.rb +28 -8
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: abcb8c05a4359b363c8a1a0f0cf75a16df123c03
|
4
|
+
data.tar.gz: 55d88baf42ee056e4de0f181fae316fcefc451ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: de246d926ea5785af76414cc7d8d60acde19cc552d8a81e988ca91a290f0ce41c77482a29d18ef99f9953097b958a6ec695ad7db7d8276e8721063bc6716fd72
|
7
|
+
data.tar.gz: d905845078c70d674b33098b4269fd62ba76d32a3fb3ef9e1bcc9758138b359e7d08c15313f1a4b7d12abbf09bcdb9ce4eec516837f6ff977fd4b372052f339f
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -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.
|
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
|
-
|
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?
|
data/test/helper.rb
CHANGED
@@ -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.
|
30
|
-
|
31
|
-
|
32
|
-
|
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.
|
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-
|
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
|