fluent-plugin-filter_codec 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 21d07fea055581657501e1d4518e7c5e6ddd198d
4
- data.tar.gz: 7a7a7f9ca7b26f018f138567c00b8200444300ed
3
+ metadata.gz: e5b1c497147725424f7e6b4e0bcd16ddc80f62b5
4
+ data.tar.gz: 307f5f89ea10af999399c94bf6e8bd11d8c801eb
5
5
  SHA512:
6
- metadata.gz: 80aff95f6a2800a906fd2cb3ab8ce5a3130374ce8bd9cdf68f8d41aebe9f024ad0e37d11ad911c303839057db63413672b539eba803edd566c131a5ca5d8b15e
7
- data.tar.gz: 44da4eb7e6356e0fafcd67b6ff41349ef8de0f713f6b170a4c27fbe17230aed630dd23401fdf9ca1e6e0c1c93c9f5fbb51c3a53e9110f6abb1dd2289240864be
6
+ metadata.gz: 0b14cc70a6429c7a24a22fff69e9186e6de35661e7cdbf5d199eecc667ef364fe6ec66f19201857d7a716473933329afa812024886fce330e440aff5f3cf8716
7
+ data.tar.gz: 893e96a40ccba3bd166039a533bf45df4e6e8fc430dace0fbdca9ba71a8f23591c1c2ad13f5cc4aeeb74eda0e5c1f3f16bd2408bb008b93ec7fe3e1670d8fea7
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "fluent-plugin-filter_codec"
3
- spec.version = "0.0.1"
3
+ spec.version = "0.0.2"
4
4
  spec.authors = ["Neozaru"]
5
5
  spec.email = ["neozaru@mailoo.org"]
6
6
  spec.description = %q{Fluentd custom plugin to encode/decode fields}
@@ -10,6 +10,7 @@ module Fluent
10
10
  config_param :field, :string, :default => nil
11
11
  config_param :output_field, :string, :default => nil
12
12
  config_param :codec, :string, :default => nil
13
+ config_param :error_value, :string, :default => ""
13
14
 
14
15
 
15
16
  def configure(conf)
@@ -32,6 +33,7 @@ module Fluent
32
33
  @field = field
33
34
  @codec = codec
34
35
  @output_field = output_field || field
36
+ @error_value = error_value
35
37
 
36
38
  end
37
39
 
@@ -60,6 +62,8 @@ module Fluent
60
62
  return @codec_functions[codec].call(value)
61
63
 
62
64
  return value
65
+ rescue
66
+ return @error_value
63
67
  end
64
68
 
65
69
  def base64_decode(value)
@@ -22,14 +22,16 @@ class FilterCodecOutputTest < Test::Unit::TestCase
22
22
  field key1
23
23
  output_field key2
24
24
  codec base64-decode
25
+ error_value foo
25
26
  ])
26
27
 
27
28
  assert_equal 'decoded.', d.instance.add_tag_prefix
28
29
  assert_equal 'key1', d.instance.field
29
30
  assert_equal 'key2', d.instance.output_field
30
31
  assert_equal 'base64-decode', d.instance.codec
32
+ assert_equal 'foo', d.instance.error_value
31
33
 
32
- # output_field missing
34
+ # output_field and error_value missing
33
35
  d = create_driver(%[
34
36
  add_tag_prefix decoded.
35
37
  field key1
@@ -40,6 +42,7 @@ class FilterCodecOutputTest < Test::Unit::TestCase
40
42
  assert_equal 'key1', d.instance.field
41
43
  assert_equal 'key1', d.instance.output_field
42
44
  assert_equal 'base64-decode', d.instance.codec
45
+ assert_equal '', d.instance.error_value
43
46
 
44
47
  end
45
48
 
@@ -134,4 +137,47 @@ class FilterCodecOutputTest < Test::Unit::TestCase
134
137
  assert_equal 'Tmljb2xhcyBDYWdl',emits[0][2]['key2']
135
138
  end
136
139
 
140
+ def test_emit_with_base64_decode_error_not_set
141
+ d = create_driver(%[
142
+ add_tag_prefix encoded.
143
+ field key1
144
+ output_field key2
145
+ codec base64-decode
146
+ ])
147
+
148
+ record = {
149
+ 'key1' => "YmFkdmFsdWU",
150
+ 'foo' => "bar"
151
+ }
152
+
153
+ d.run { d.emit(record) }
154
+ emits = d.emits
155
+
156
+ assert_equal 1, emits.count
157
+ assert_equal 'encoded.test', emits[0][0]
158
+ assert_equal '',emits[0][2]['key2']
159
+ end
160
+
161
+ def test_emit_with_base64_decode_error_set
162
+ d = create_driver(%[
163
+ add_tag_prefix encoded.
164
+ field key1
165
+ output_field key2
166
+ codec base64-decode
167
+ error_value foo
168
+ ])
169
+
170
+ record = {
171
+ 'key1' => "YmFkdmFsdWU",
172
+ 'foo' => "bar"
173
+ }
174
+
175
+ d.run { d.emit(record) }
176
+ emits = d.emits
177
+
178
+ assert_equal 1, emits.count
179
+ assert_equal 'encoded.test', emits[0][0]
180
+ assert_equal 'foo',emits[0][2]['key2']
181
+ end
182
+
137
183
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-filter_codec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Neozaru
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-20 00:00:00.000000000 Z
11
+ date: 2015-04-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler