fluentd 0.12.10 → 0.12.11

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of fluentd might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1713e75f8506de5f6b0536fad50320386c836d66
4
- data.tar.gz: 4b8f4e7728086788c62f2f88b3e45e4ef93d0ccd
3
+ metadata.gz: f332fd6ebffa5a9f9c318f90e3a14aeca817bd06
4
+ data.tar.gz: ebf638f6375958a66a285003c4dee6a193fd9914
5
5
  SHA512:
6
- metadata.gz: 72b4a8dd05fc897004a0313a37fcd2d931723a449dee05b8c6682ceba49ac539cad4dec1cd9ca90fae6563fd1a2893d96de2e7df20248014a5f9da6c416afb03
7
- data.tar.gz: c6d11c5e0958a43f8edef4a8ff508687291e02749b850c84f88baae3ef1f78bcf84074718e63b681b0da26decf360d4303063381d894d47eff4ea1f185cfcc81
6
+ metadata.gz: 6e942e48b3aefbe52818f48827a87efb1f78d0037aaca0ab19612649a2db2e0ab060750ef2c14e36bec96c3ebe9bda3f1eb9d8d8d78701c9e4f3b24ca07e1e65
7
+ data.tar.gz: 3f1d85a56f16fd280da534cdca74f98cb761c59b77abe9f232b13e677fd774bb0fe97eafed3692ff0b1b78d5b259ba99f5528e5eb68031c41e6f33c97422f10f
data/ChangeLog CHANGED
@@ -1,5 +1,14 @@
1
1
  # v0.12
2
2
 
3
+ ## Release 0.12.10 - 2015/06/01
4
+
5
+ ### New features / Enhancement
6
+
7
+ * fluent-cat: Add none format
8
+ https://github.com/fluent/fluentd/pull/606
9
+ * config: Add secret option
10
+ https://github.com/fluent/fluentd/pull/604
11
+
3
12
  ## Release 0.12.10 - 2015/05/28
4
13
 
5
14
  ### New features / Enhancement
@@ -28,6 +28,7 @@ socket_path = Fluent::DEFAULT_SOCKET_PATH
28
28
 
29
29
  config_path = Fluent::DEFAULT_CONFIG_PATH
30
30
  format = 'json'
31
+ message_key = 'message'
31
32
 
32
33
  op.on('-p', '--port PORT', "fluent tcp port (default: #{port})", Integer) {|i|
33
34
  port = i
@@ -57,6 +58,14 @@ op.on('--msgpack', "same as: -f msgpack", TrueClass) {|b|
57
58
  format = 'msgpack'
58
59
  }
59
60
 
61
+ op.on('--none', "same as: -f none", TrueClass) {|b|
62
+ format = 'none'
63
+ }
64
+
65
+ op.on('--message-key KEY', "key field for none format (default: #{message_key})") {|s|
66
+ message_key = s
67
+ }
68
+
60
69
  (class<<self;self;end).module_eval do
61
70
  define_method(:usage) do |msg|
62
71
  puts op.to_s
@@ -290,6 +299,17 @@ when 'msgpack'
290
299
  exit 1
291
300
  end
292
301
 
302
+ when 'none'
303
+ begin
304
+ while line = $stdin.gets
305
+ record = { message_key => line.chomp }
306
+ w.write(record)
307
+ end
308
+ rescue
309
+ $stderr.puts $!
310
+ exit 1
311
+ end
312
+
293
313
  else
294
314
  $stderr.puts "Unknown format '#{format}'"
295
315
  exit 1
@@ -29,9 +29,10 @@ module Fluent
29
29
  }
30
30
  @unused = unused || attrs.keys
31
31
  @v1_config = false
32
+ @corresponding_proxies = [] # some plugins use flat parameters, e.g. in_http doesn't provide <format> section for parser.
32
33
  end
33
34
 
34
- attr_accessor :name, :arg, :elements, :unused, :v1_config
35
+ attr_accessor :name, :arg, :elements, :unused, :v1_config, :corresponding_proxies
35
36
 
36
37
  def add_element(name, arg='')
37
38
  e = Element.new(name, arg, {}, [])
@@ -103,7 +104,11 @@ module Fluent
103
104
  out << "#{indent}<#{@name} #{@arg}>\n"
104
105
  end
105
106
  each_pair { |k, v|
106
- out << "#{nindent}#{k} #{v}\n"
107
+ if secret_param?(k)
108
+ out << "#{nindent}#{k} xxxxxx\n"
109
+ else
110
+ out << "#{nindent}#{k} #{v}\n"
111
+ end
107
112
  }
108
113
  @elements.each { |e|
109
114
  out << e.to_s(nest + 1)
@@ -112,6 +117,28 @@ module Fluent
112
117
  out
113
118
  end
114
119
 
120
+ def to_masked_element
121
+ element = Element.new(@name, @arg, {}, @elements, @unused)
122
+ each_pair { |k, v|
123
+ element[k] = secret_param?(k) ? 'xxxxxx' : v
124
+ }
125
+ element
126
+ end
127
+
128
+ def secret_param?(key)
129
+ return false if @corresponding_proxies.empty?
130
+
131
+ param_key = key.to_sym
132
+ @corresponding_proxies.each { |proxy|
133
+ block, opts = proxy.params[param_key]
134
+ if opts && opts.has_key?(:secret)
135
+ return opts[:secret]
136
+ end
137
+ }
138
+
139
+ false
140
+ end
141
+
115
142
  def self.unescape_parameter(v)
116
143
  result = ''
117
144
  v.each_char { |c| result << LiteralParser.unescape_char(c) }
@@ -21,8 +21,6 @@ module Fluent
21
21
  require 'fluent/registry'
22
22
 
23
23
  module Configurable
24
- attr_reader :config
25
-
26
24
  def self.included(mod)
27
25
  mod.extend(ClassMethods)
28
26
  end
@@ -47,6 +45,9 @@ module Fluent
47
45
 
48
46
  def configure(conf)
49
47
  @config = conf
48
+ if class_name = self.class.name # Class.new in tests returns nil so it should be skipped.
49
+ @config.corresponding_proxies << self.class.configure_proxy(class_name)
50
+ end
50
51
 
51
52
  logger = self.respond_to?(:log) ? log : $log
52
53
  proxy = self.class.merged_configure_proxy
@@ -64,6 +65,10 @@ module Fluent
64
65
  self
65
66
  end
66
67
 
68
+ def config
69
+ @masked_config ||= @config.to_masked_element
70
+ end
71
+
67
72
  CONFIG_TYPE_REGISTRY = Registry.new(:config_type, 'fluent/plugin/type_')
68
73
 
69
74
  def self.register_type(type, callable = nil, &block)
@@ -90,12 +90,12 @@ module Fluent
90
90
  $log.info "gem '#{spec.name}' version '#{spec.version}'"
91
91
  end
92
92
 
93
+ @root_agent.configure(conf)
94
+ @event_router = @root_agent.event_router
95
+
93
96
  unless @suppress_config_dump
94
97
  $log.info "using configuration file: #{conf.to_s.rstrip}"
95
98
  end
96
-
97
- @root_agent.configure(conf)
98
- @event_router = @root_agent.event_router
99
99
  end
100
100
 
101
101
  def load_plugin_dir(dir)
@@ -16,6 +16,6 @@
16
16
 
17
17
  module Fluent
18
18
 
19
- VERSION = '0.12.10'
19
+ VERSION = '0.12.11'
20
20
 
21
21
  end
@@ -146,6 +146,13 @@ module ConfigurableSpec
146
146
  config_param :age, :integer, default: 10
147
147
  end
148
148
  end
149
+
150
+ class Example5
151
+ include Fluent::Configurable
152
+
153
+ config_param :normal_param, :string
154
+ config_param :secret_param, :string, :secret => true
155
+ end
149
156
  end
150
157
 
151
158
  module Fluent::Config
@@ -182,18 +189,22 @@ module Fluent::Config
182
189
  end
183
190
 
184
191
  sub_test_case '#configure' do
192
+ def e(attrs)
193
+ Fluent::Config::Element.new('', '', attrs, [])
194
+ end
195
+
185
196
  test 'returns configurable object itself' do
186
197
  b2 = ConfigurableSpec::Base2.new
187
- assert_instance_of(ConfigurableSpec::Base2, b2.configure({"name1" => "t1", "name5" => "t5", "opt3" => "a"}))
198
+ assert_instance_of(ConfigurableSpec::Base2, b2.configure(e({"name1" => "t1", "name5" => "t5", "opt3" => "a"})))
188
199
  end
189
200
 
190
201
  test 'raise errors without any specifications for param without defaults' do
191
202
  b2 = ConfigurableSpec::Base2.new
192
- assert_raise(Fluent::ConfigError) { b2.configure({}) }
193
- assert_raise(Fluent::ConfigError) { b2.configure({"name1" => "t1"}) }
194
- assert_raise(Fluent::ConfigError) { b2.configure({"name5" => "t5"}) }
195
- assert_raise(Fluent::ConfigError) { b2.configure({"name1" => "t1", "name5" => "t5"}) }
196
- assert_nothing_raised { b2.configure({"name1" => "t1", "name5" => "t5", "opt3" => "a"}) }
203
+ assert_raise(Fluent::ConfigError) { b2.configure(e({})) }
204
+ assert_raise(Fluent::ConfigError) { b2.configure(e({"name1" => "t1"})) }
205
+ assert_raise(Fluent::ConfigError) { b2.configure(e({"name5" => "t5"})) }
206
+ assert_raise(Fluent::ConfigError) { b2.configure(e({"name1" => "t1", "name5" => "t5"})) }
207
+ assert_nothing_raised { b2.configure(e({"name1" => "t1", "name5" => "t5", "opt3" => "a"})) }
197
208
 
198
209
  assert_equal(["node", false, true, "t1", "base2", "base1", "base2", "t5", "base2"], b2.get_all)
199
210
  assert_equal(:a, b2.opt3)
@@ -201,19 +212,19 @@ module Fluent::Config
201
212
 
202
213
  test 'can configure bool values' do
203
214
  b2a = ConfigurableSpec::Base2.new
204
- assert_nothing_raised { b2a.configure({"flag1" => "true", "flag2" => "yes", "name1" => "t1", "name5" => "t5", "opt3" => "a"}) }
215
+ assert_nothing_raised { b2a.configure(e({"flag1" => "true", "flag2" => "yes", "name1" => "t1", "name5" => "t5", "opt3" => "a"})) }
205
216
  assert_true(b2a.flag1)
206
217
  assert_true(b2a.flag2)
207
218
 
208
219
  b2b = ConfigurableSpec::Base2.new
209
- assert_nothing_raised { b2b.configure({"flag1" => false, "flag2" => "no", "name1" => "t1", "name5" => "t5", "opt3" => "a"}) }
220
+ assert_nothing_raised { b2b.configure(e({"flag1" => false, "flag2" => "no", "name1" => "t1", "name5" => "t5", "opt3" => "a"})) }
210
221
  assert_false(b2b.flag1)
211
222
  assert_false(b2b.flag2)
212
223
  end
213
224
 
214
225
  test 'overwrites values of defaults' do
215
226
  b2 = ConfigurableSpec::Base2.new
216
- b2.configure({"name1" => "t1", "name2" => "t2", "name3" => "t3", "name4" => "t4", "name5" => "t5", "opt1" => "foo", "opt3" => "b"})
227
+ b2.configure(e({"name1" => "t1", "name2" => "t2", "name3" => "t3", "name4" => "t4", "name5" => "t5", "opt1" => "foo", "opt3" => "b"}))
217
228
  assert_equal("t1", b2.name1)
218
229
  assert_equal("t2", b2.name2)
219
230
  assert_equal("t3", b2.name3)
@@ -227,7 +238,7 @@ module Fluent::Config
227
238
  end
228
239
 
229
240
  test 'enum type rejects values which does not exist in list' do
230
- default = {"name1" => "t1", "name2" => "t2", "name3" => "t3", "name4" => "t4", "name5" => "t5", "opt1" => "foo", "opt3" => "b"}
241
+ default = e({"name1" => "t1", "name2" => "t2", "name3" => "t3", "name4" => "t4", "name5" => "t5", "opt1" => "foo", "opt3" => "b"})
231
242
 
232
243
  b2 = ConfigurableSpec::Base2.new
233
244
  assert_nothing_raised { b2.configure(default) }
@@ -467,12 +478,12 @@ module Fluent::Config
467
478
  ex01 = ConfigurableSpec::Example0.new
468
479
  assert_raise(Fluent::ConfigError) { ex01.configure(conf0) }
469
480
 
470
- complete = {
481
+ complete = e('ROOT', '', {
471
482
  "stringvalue" => "s1", "boolvalue" => "yes", "integervalue" => "10",
472
483
  "sizevalue" => "10m", "timevalue" => "100s", "floatvalue" => "1.001",
473
484
  "hashvalue" => '{"foo":1, "bar":2}',
474
485
  "arrayvalue" => '[1,"ichi"]',
475
- }
486
+ })
476
487
 
477
488
  checker = lambda { |conf| ConfigurableSpec::Example0.new.configure(conf) }
478
489
 
@@ -488,12 +499,12 @@ module Fluent::Config
488
499
  end
489
500
 
490
501
  test 'accepts configuration values as string representation' do
491
- conf = {
502
+ conf = e('ROOT', '', {
492
503
  "stringvalue" => "s1", "boolvalue" => "yes", "integervalue" => "10",
493
504
  "sizevalue" => "10m", "timevalue" => "10m", "floatvalue" => "1.001",
494
505
  "hashvalue" => '{"foo":1, "bar":2}',
495
506
  "arrayvalue" => '[1,"ichi"]',
496
- }
507
+ })
497
508
  ex = ConfigurableSpec::Example0.new.configure(conf)
498
509
  assert_equal("s1", ex.stringvalue)
499
510
  assert_true(ex.boolvalue)
@@ -506,12 +517,12 @@ module Fluent::Config
506
517
  end
507
518
 
508
519
  test 'accepts configuration values as ruby value representation (especially for DSL)' do
509
- conf = {
520
+ conf = e('ROOT', '', {
510
521
  "stringvalue" => "s1", "boolvalue" => true, "integervalue" => 10,
511
522
  "sizevalue" => 10 * 1024 * 1024, "timevalue" => 10 * 60, "floatvalue" => 1.001,
512
523
  "hashvalue" => {"foo" => 1, "bar" => 2},
513
524
  "arrayvalue" => [1,"ichi"],
514
- }
525
+ })
515
526
  ex = ConfigurableSpec::Example0.new.configure(conf)
516
527
  assert_equal("s1", ex.stringvalue)
517
528
  assert_true(ex.boolvalue)
@@ -524,12 +535,12 @@ module Fluent::Config
524
535
  end
525
536
 
526
537
  test 'gets both of true(yes) and false(no) for bool value parameter' do
527
- conf = {
538
+ conf = e('ROOT', '', {
528
539
  "stringvalue" => "s1", "integervalue" => 10,
529
540
  "sizevalue" => 10 * 1024 * 1024, "timevalue" => 10 * 60, "floatvalue" => 1.001,
530
541
  "hashvalue" => {"foo" => 1, "bar" => 2},
531
542
  "arrayvalue" => [1,"ichi"],
532
- }
543
+ })
533
544
  ex0 = ConfigurableSpec::Example0.new.configure(conf.merge({"boolvalue" => "true"}))
534
545
  assert_true(ex0.boolvalue)
535
546
 
@@ -673,5 +684,35 @@ module Fluent::Config
673
684
  end
674
685
  end
675
686
  end
687
+
688
+ sub_test_case ':secret option' do
689
+ setup do
690
+ @conf = Fluent::Config::Element.new('ROOT', '', {'normal_param' => 'param1', 'secret_param' => 'param2'}, [])
691
+ @example = ConfigurableSpec::Example5.new
692
+ @example.configure(@conf)
693
+ end
694
+
695
+ test 'to_s hides secret config_param' do
696
+ @conf.to_s.each_line { |line|
697
+ key, value = line.strip.split(' ', 2)
698
+ assert_secret_param(key, value)
699
+ }
700
+ end
701
+
702
+ test 'config returns masked configuration' do
703
+ @example.config.each_pair { |key, value|
704
+ assert_secret_param(key, value)
705
+ }
706
+ end
707
+
708
+ def assert_secret_param(key, value)
709
+ case key
710
+ when 'normal_param'
711
+ assert_equal 'param1', value
712
+ when 'secret_param'
713
+ assert_equal 'xxxxxx', value
714
+ end
715
+ end
716
+ end
676
717
  end
677
718
  end
@@ -23,6 +23,18 @@ if ENV['SIMPLE_COV']
23
23
  end
24
24
  end
25
25
 
26
+ # Some tests use Hash instead of Element for configure.
27
+ # We should rewrite these tests in the future and remove this ad-hoc code
28
+ class Hash
29
+ def corresponding_proxies
30
+ @corresponding_proxies ||= []
31
+ end
32
+
33
+ def to_masked_element
34
+ self
35
+ end
36
+ end
37
+
26
38
  require 'rr'
27
39
  require 'test/unit'
28
40
  require 'test/unit/rr'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluentd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.10
4
+ version: 0.12.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sadayuki Furuhashi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-27 00:00:00.000000000 Z
11
+ date: 2015-06-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: msgpack