fluent-plugin-config_pit 0.0.1
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.
- data/.gitignore +18 -0
- data/Changes +4 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +13 -0
- data/README.md +50 -0
- data/Rakefile +9 -0
- data/fluent-plugin-config_pit.gemspec +23 -0
- data/lib/fluent/plugin/in_config_pit.rb +36 -0
- data/lib/fluent/plugin/out_config_pit.rb +40 -0
- data/lib/fluent/plugin/pit.rb +14 -0
- data/test/helper.rb +29 -0
- data/test/plugin/test_in_config_pit.rb +28 -0
- data/test/plugin/test_out_config_pit.rb +28 -0
- data/test/plugin/test_pit.rb +21 -0
- data/test/plugins.rb +13 -0
- metadata +145 -0
data/.gitignore
ADDED
data/Changes
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
Copyright (c) 2013- Naoya Ito
|
2
|
+
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
data/README.md
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# fluent-plugin-config_pit
|
2
|
+
|
3
|
+
## ConfigPitInput, ConfigPitOutput
|
4
|
+
|
5
|
+
Fluentd Input/Output plugin which provides pit directive in configuration.
|
6
|
+
|
7
|
+
## Configuration
|
8
|
+
|
9
|
+
Fore both of input and output (for source and match), you can use 'pit' directive like below:
|
10
|
+
|
11
|
+
<match my.tag>
|
12
|
+
type config_pit
|
13
|
+
<pit aws>
|
14
|
+
type s3
|
15
|
+
...
|
16
|
+
aws_key_id $pit[aws_access_key]
|
17
|
+
aws_seckey $pit[aws_secret_access_key]
|
18
|
+
...
|
19
|
+
</pit>
|
20
|
+
</match>
|
21
|
+
|
22
|
+
Variables '$pit[key]' will be replaced with values saved in ~/.pit directory by pit (https://github.com/cho45/pit). So you can safely treat API credentials or something like that.
|
23
|
+
|
24
|
+
## Copyright
|
25
|
+
|
26
|
+
* Copyright (c) 2013- Naoya Ito (@naoya_ito)
|
27
|
+
* License
|
28
|
+
* Apache License, Version 2.0
|
29
|
+
|
30
|
+
## Installation
|
31
|
+
|
32
|
+
Add this line to your application's Gemfile:
|
33
|
+
|
34
|
+
gem 'fluent-plugin-config-pit'
|
35
|
+
|
36
|
+
And then execute:
|
37
|
+
|
38
|
+
$ bundle
|
39
|
+
|
40
|
+
Or install it yourself as:
|
41
|
+
|
42
|
+
$ gem install fluent-plugin-config-pit
|
43
|
+
|
44
|
+
## Contributing
|
45
|
+
|
46
|
+
1. Fork it
|
47
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
48
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
49
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
50
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |gem|
|
4
|
+
gem.name = "fluent-plugin-config_pit"
|
5
|
+
gem.version = "0.0.1"
|
6
|
+
gem.authors = ["Naoya Ito"]
|
7
|
+
gem.email = ["i.naoya@gmail.com"]
|
8
|
+
gem.description = %q{This plugin provides directive for pit}
|
9
|
+
gem.summary = %q{Fluentd plugin to enable pit in configuration}
|
10
|
+
gem.homepage = "https://github.com/naoay/fluent-plugin-config_pit"
|
11
|
+
|
12
|
+
gem.files = `git ls-files`.split($\)
|
13
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
14
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
|
17
|
+
gem.add_development_dependency "rake"
|
18
|
+
gem.add_development_dependency "fluentd"
|
19
|
+
gem.add_development_dependency "pit"
|
20
|
+
|
21
|
+
gem.add_runtime_dependency "fluentd"
|
22
|
+
gem.add_runtime_dependency "pit"
|
23
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require_relative 'pit'
|
2
|
+
|
3
|
+
class Fluent::ConfigPitInput < Fluent::Input
|
4
|
+
attr_accessor :plugin
|
5
|
+
|
6
|
+
Fluent::Plugin.register_input('config_pit', self)
|
7
|
+
|
8
|
+
def mark_used(conf)
|
9
|
+
conf.used = conf.keys
|
10
|
+
conf.elements.each{|e| mark_used(e)}
|
11
|
+
end
|
12
|
+
|
13
|
+
def configure(conf)
|
14
|
+
super
|
15
|
+
|
16
|
+
configs = conf.elements.select {|e| e.name == 'pit' }
|
17
|
+
if configs.size != 1
|
18
|
+
raise Fluent::ConfigError, "config_pit needs just one <pit ...> ... </pit> section"
|
19
|
+
end
|
20
|
+
|
21
|
+
Fluent::Config::Pit.extract(configs.first).tap do |c|
|
22
|
+
@plugin = Fluent::Plugin.new_input(c['type'])
|
23
|
+
@plugin.configure(c)
|
24
|
+
end
|
25
|
+
|
26
|
+
mark_used(configs.first)
|
27
|
+
end
|
28
|
+
|
29
|
+
def start
|
30
|
+
@plugin.start
|
31
|
+
end
|
32
|
+
|
33
|
+
def shutdown
|
34
|
+
@plugin.shutdown
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require_relative 'pit'
|
2
|
+
|
3
|
+
class Fluent::ConfigPitOutput < Fluent::Output
|
4
|
+
attr_accessor :plugin
|
5
|
+
|
6
|
+
Fluent::Plugin.register_output('config_pit', self)
|
7
|
+
|
8
|
+
def mark_used(conf)
|
9
|
+
conf.used = conf.keys
|
10
|
+
conf.elements.each{|e| mark_used(e)}
|
11
|
+
end
|
12
|
+
|
13
|
+
def configure(conf)
|
14
|
+
super
|
15
|
+
|
16
|
+
configs = conf.elements.select {|e| e.name == 'pit' }
|
17
|
+
if configs.size != 1
|
18
|
+
raise Fluent::ConfigError, "config_pit needs just one <pit ...> ... </pit> section"
|
19
|
+
end
|
20
|
+
|
21
|
+
Fluent::Config::Pit.extract(configs.first).tap do |c|
|
22
|
+
@plugin = Fluent::Plugin.new_output(c['type'])
|
23
|
+
@plugin.configure(c)
|
24
|
+
end
|
25
|
+
|
26
|
+
mark_used(configs.first)
|
27
|
+
end
|
28
|
+
|
29
|
+
def start
|
30
|
+
@plugin.start
|
31
|
+
end
|
32
|
+
|
33
|
+
def shutdown
|
34
|
+
@plugin.shutdown
|
35
|
+
end
|
36
|
+
|
37
|
+
def emit(tag, es, chain)
|
38
|
+
@plugin.emit(tag, es, chain)
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'pit'
|
2
|
+
|
3
|
+
module Fluent::Config::Pit
|
4
|
+
def self.extract(conf)
|
5
|
+
pit = Pit.get(conf.arg)
|
6
|
+
ex = Fluent::Config::Element.new('', '', conf, [])
|
7
|
+
ex.each do |k, v|
|
8
|
+
if v =~ /^\$pit\[(.+)\]$/
|
9
|
+
ex[k] = pit[$1]
|
10
|
+
end
|
11
|
+
end
|
12
|
+
return ex
|
13
|
+
end
|
14
|
+
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'tmpdir'
|
2
|
+
require 'pathname'
|
3
|
+
|
4
|
+
class Pathname
|
5
|
+
@@tempname_number = 0
|
6
|
+
def self.tempname(base=$0, dir=Dir.tmpdir)
|
7
|
+
@@tempname_number += 1
|
8
|
+
path = new(dir) + "#{File.basename(base)}.#{$$}.#{@@tempname_number}"
|
9
|
+
at_exit do
|
10
|
+
path.rmtree if path.exist?
|
11
|
+
end
|
12
|
+
path
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
dir = Pathname.tempname
|
17
|
+
dir.mkpath
|
18
|
+
ENV["HOME"] = dir.to_s
|
19
|
+
|
20
|
+
require 'pit'
|
21
|
+
require 'test/unit'
|
22
|
+
|
23
|
+
require 'fluent/test'
|
24
|
+
require 'fluent/config'
|
25
|
+
|
26
|
+
require 'fluent/plugin/pit'
|
27
|
+
require 'fluent/plugin/in_config_pit'
|
28
|
+
require 'fluent/plugin/out_config_pit'
|
29
|
+
require 'plugins'
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class ConfigPitInputTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
Pit.set("test", :data => {"user" => "fiorung", "password" => "xenoblade" })
|
6
|
+
Fluent::Test.setup
|
7
|
+
end
|
8
|
+
|
9
|
+
def create_driver(conf, pit_id = 'test')
|
10
|
+
Fluent::Test::InputTestDriver.new(Fluent::ConfigPitInput).configure(conf)
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_configure
|
14
|
+
driver = create_driver %[
|
15
|
+
<pit test>
|
16
|
+
type config_pit_test
|
17
|
+
tag pit_test
|
18
|
+
user $pit[user]
|
19
|
+
password $pit[password]
|
20
|
+
</pit>
|
21
|
+
]
|
22
|
+
|
23
|
+
assert_equal 'Fluent::ConfigPitTestInput', driver.instance.plugin.class.to_s
|
24
|
+
assert_equal 'pit_test', driver.instance.plugin.tag
|
25
|
+
assert_equal 'fiorung', driver.instance.plugin.user
|
26
|
+
assert_equal 'xenoblade', driver.instance.plugin.password
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class ConfigPitOutputTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
Pit.set("test", :data => {"user" => "fiorung", "password" => "xenoblade" })
|
6
|
+
Fluent::Test.setup
|
7
|
+
end
|
8
|
+
|
9
|
+
def create_driver(conf, pit_id = 'test')
|
10
|
+
Fluent::Test::OutputTestDriver.new(Fluent::ConfigPitOutput).configure(conf)
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_configure
|
14
|
+
driver = create_driver %[
|
15
|
+
<pit test>
|
16
|
+
type config_pit_test
|
17
|
+
tag pit_test
|
18
|
+
user $pit[user]
|
19
|
+
password $pit[password]
|
20
|
+
</pit>
|
21
|
+
]
|
22
|
+
|
23
|
+
assert_equal 'Fluent::ConfigPitTestOutput', driver.instance.plugin.class.to_s
|
24
|
+
assert_equal 'pit_test', driver.instance.plugin.tag
|
25
|
+
assert_equal 'fiorung', driver.instance.plugin.user
|
26
|
+
assert_equal 'xenoblade', driver.instance.plugin.password
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class ConfigPitTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
Pit.set("test", :data => {"user" => "fiorung", "password" => "xenoblade" })
|
6
|
+
@module = Fluent::Config::Pit
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_extract
|
10
|
+
attrs = {
|
11
|
+
'tag' => 'mytag',
|
12
|
+
'user' => '$pit[user]',
|
13
|
+
'password' => '$pit[password]'
|
14
|
+
}
|
15
|
+
conf = @module.extract Fluent::Config::Element.new('pit', 'test', attrs, [])
|
16
|
+
|
17
|
+
assert_equal conf['tag'], 'mytag'
|
18
|
+
assert_equal conf['user'], 'fiorung'
|
19
|
+
assert_equal conf['password'], 'xenoblade'
|
20
|
+
end
|
21
|
+
end
|
data/test/plugins.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
class Fluent::ConfigPitTestInput < Fluent::Input
|
2
|
+
Fluent::Plugin.register_input('config_pit_test', self)
|
3
|
+
config_param :tag, :string
|
4
|
+
config_param :user, :string
|
5
|
+
config_param :password, :string
|
6
|
+
end
|
7
|
+
|
8
|
+
class Fluent::ConfigPitTestOutput < Fluent::Output
|
9
|
+
Fluent::Plugin.register_output('config_pit_test', self)
|
10
|
+
config_param :tag, :string
|
11
|
+
config_param :user, :string
|
12
|
+
config_param :password, :string
|
13
|
+
end
|
metadata
ADDED
@@ -0,0 +1,145 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluent-plugin-config_pit
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Naoya Ito
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-02-19 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: fluentd
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: pit
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: fluentd
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: pit
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :runtime
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
description: This plugin provides directive for pit
|
95
|
+
email:
|
96
|
+
- i.naoya@gmail.com
|
97
|
+
executables: []
|
98
|
+
extensions: []
|
99
|
+
extra_rdoc_files: []
|
100
|
+
files:
|
101
|
+
- .gitignore
|
102
|
+
- Changes
|
103
|
+
- Gemfile
|
104
|
+
- LICENSE.txt
|
105
|
+
- README.md
|
106
|
+
- Rakefile
|
107
|
+
- fluent-plugin-config_pit.gemspec
|
108
|
+
- lib/fluent/plugin/in_config_pit.rb
|
109
|
+
- lib/fluent/plugin/out_config_pit.rb
|
110
|
+
- lib/fluent/plugin/pit.rb
|
111
|
+
- test/helper.rb
|
112
|
+
- test/plugin/test_in_config_pit.rb
|
113
|
+
- test/plugin/test_out_config_pit.rb
|
114
|
+
- test/plugin/test_pit.rb
|
115
|
+
- test/plugins.rb
|
116
|
+
homepage: https://github.com/naoay/fluent-plugin-config_pit
|
117
|
+
licenses: []
|
118
|
+
post_install_message:
|
119
|
+
rdoc_options: []
|
120
|
+
require_paths:
|
121
|
+
- lib
|
122
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
123
|
+
none: false
|
124
|
+
requirements:
|
125
|
+
- - ! '>='
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: '0'
|
128
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ! '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
requirements: []
|
135
|
+
rubyforge_project:
|
136
|
+
rubygems_version: 1.8.23
|
137
|
+
signing_key:
|
138
|
+
specification_version: 3
|
139
|
+
summary: Fluentd plugin to enable pit in configuration
|
140
|
+
test_files:
|
141
|
+
- test/helper.rb
|
142
|
+
- test/plugin/test_in_config_pit.rb
|
143
|
+
- test/plugin/test_out_config_pit.rb
|
144
|
+
- test/plugin/test_pit.rb
|
145
|
+
- test/plugins.rb
|