fluent-format 0.2.3 → 0.2.4
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 +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/fluent/format.rb +3 -4
- data/lib/fluent/format/check.rb +52 -5
- data/lib/fluent/format/cli.rb +6 -7
- data/lib/fluent/format/version.rb +1 -1
- data/spec/fluent/format/check_spec.rb +5 -3
- data/spec/fluent/format/cli_spec.rb +6 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 45e9edeceed0b41a528b44e55f62acc590c10511
|
4
|
+
data.tar.gz: f1f8d83c06393f8e1711f09d518df075cda1d9b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0214b3c0202711b8524ba1aa1224adc9423660fb480582967f5c274f99a50eacd7f8765cfb20fa659e85470681b309424fa24150de7733a26aacf637ddf9eca5
|
7
|
+
data.tar.gz: 4c4d3e307d2f1c45708da99e444c36d3a09f5c29aced24c84a06bb35315845eefa610f3bc7f28cc119b2d7c31eb329257f98781a61c0d21cab55cef52b299c20
|
data/CHANGELOG.md
CHANGED
data/lib/fluent/format.rb
CHANGED
@@ -13,11 +13,10 @@ module Fluent
|
|
13
13
|
# Check config file
|
14
14
|
#
|
15
15
|
# @param [IO|String] config_dev
|
16
|
-
# @param [
|
17
|
-
# @param [Array] libs load libraries (to require)
|
16
|
+
# @param [Hash] opts
|
18
17
|
# @return [Boolean]
|
19
|
-
def self.check(config_dev,
|
20
|
-
Fluent::Format::Check.new(config_dev,
|
18
|
+
def self.check(config_dev, opts = {})
|
19
|
+
Fluent::Format::Check.new(config_dev, opts).run
|
21
20
|
end
|
22
21
|
end
|
23
22
|
end
|
data/lib/fluent/format/check.rb
CHANGED
@@ -6,9 +6,7 @@ module Fluent
|
|
6
6
|
# Initialize
|
7
7
|
#
|
8
8
|
# @param [IO|String] config_dev
|
9
|
-
|
10
|
-
# @param [Array] libs load libraries (to require)
|
11
|
-
def initialize(config_dev, plugin_dir = nil, libs = nil)
|
9
|
+
def initialize(config_dev, opts = {})
|
12
10
|
@opts = {
|
13
11
|
:config_path => config_dev, # Fluent::DEFAULT_CONFIG_PATH,
|
14
12
|
:plugin_dirs => [Fluent::DEFAULT_PLUGIN_DIR],
|
@@ -22,8 +20,11 @@ module Fluent
|
|
22
20
|
:suppress_interval => 0,
|
23
21
|
:suppress_repeated_stacktrace => false,
|
24
22
|
}
|
25
|
-
@opts[:plugin_dirs]
|
26
|
-
@opts[:libs] += libs if libs and !libs.empty?
|
23
|
+
@opts[:plugin_dirs] += opts[:plugin_dirs] if opts[:plugin_dirs] and !opts[:plugin_dirs].empty?
|
24
|
+
@opts[:libs] += opts[:libs] if opts[:libs] and !opts[:libs].empty?
|
25
|
+
@opts[:inline_config] = opts[:inline_config]
|
26
|
+
@opts[:gemfile] = opts[:gemfile]
|
27
|
+
@opts[:gem_install_path] = opts[:gem_install_path]
|
27
28
|
end
|
28
29
|
|
29
30
|
# Check config file
|
@@ -32,12 +33,58 @@ module Fluent
|
|
32
33
|
# @raise Fluent::ConfigError if plugin raises config error
|
33
34
|
# @return true if success
|
34
35
|
def run
|
36
|
+
Fluent::Format::BundlerInjection.new(@opts).run
|
35
37
|
Fluent::Supervisor.new(@opts).extended_dry_run
|
36
38
|
end
|
37
39
|
end
|
38
40
|
end
|
39
41
|
end
|
40
42
|
|
43
|
+
module Fluent
|
44
|
+
class Format
|
45
|
+
class BundlerInjection
|
46
|
+
def initialize(opts = {})
|
47
|
+
@opts = {
|
48
|
+
:gemfile => opts[:gemfile],
|
49
|
+
:gem_install_path => opts[:gem_install_path],
|
50
|
+
}
|
51
|
+
end
|
52
|
+
|
53
|
+
def run
|
54
|
+
# copy from lib/fluent/command/fluentd.rb
|
55
|
+
if ENV['FLUENTD_DISABLE_BUNDLER_INJECTION'] != '1' && gemfile = @opts[:gemfile]
|
56
|
+
ENV['BUNDLE_GEMFILE'] = gemfile
|
57
|
+
if path = @opts[:gem_install_path]
|
58
|
+
ENV['BUNDLE_PATH'] = path
|
59
|
+
else
|
60
|
+
ENV['BUNDLE_PATH'] = File.expand_path(File.join(File.dirname(gemfile), 'vendor/bundle'))
|
61
|
+
end
|
62
|
+
ENV['FLUENTD_DISABLE_BUNDLER_INJECTION'] = '1'
|
63
|
+
bundler_injection
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def bundler_injection
|
68
|
+
# basically copy from lib/fluent/command/bundler_injection.rb
|
69
|
+
system("bundle install")
|
70
|
+
unless $?.success?
|
71
|
+
exit $?.exitstatus
|
72
|
+
end
|
73
|
+
|
74
|
+
cmdline = [
|
75
|
+
'bundle',
|
76
|
+
'exec',
|
77
|
+
RbConfig.ruby,
|
78
|
+
File.expand_path(File.join(File.dirname(__FILE__), '../../../bin/fluent-format')),
|
79
|
+
] + ARGV
|
80
|
+
|
81
|
+
exec *cmdline
|
82
|
+
exit! 127
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
41
88
|
# lib/fluent/supervisor.rb
|
42
89
|
# Open the existing class and define new methods
|
43
90
|
module Fluent
|
data/lib/fluent/format/cli.rb
CHANGED
@@ -17,15 +17,14 @@ module Fluent
|
|
17
17
|
|
18
18
|
desc "check", "Check fluent.conf"
|
19
19
|
option :config, :aliases => ["-c"], :type => :string, :default => 'fluent.conf', :desc => 'Fluentd configuration file'
|
20
|
-
option :
|
21
|
-
option :
|
20
|
+
option :plugin_dirs, :aliases => ["-p"], :type => :array, :desc => 'add plugin directory'
|
21
|
+
option :libs, :aliases => ["-r"], :type => :array, :desc => 'load library'
|
22
|
+
option :inline_config, :aliases => ["-i"], :type => :string, :desc => 'inline config which is appended to the config file on-fly'
|
23
|
+
option :gemfile, :aliases => ["-g"], :type => :string, :desc => 'Gemfile path'
|
24
|
+
option :gem_install_path, :aliases => ["-G"], :type => :string, :desc => 'Gem install path (default: $(dirname $gemfile)/vendor/bundle)'
|
22
25
|
def check
|
23
26
|
config = @options[:config]
|
24
|
-
|
25
|
-
require 'pry'
|
26
|
-
binding.pry
|
27
|
-
libs = @options[:require]
|
28
|
-
Fluent::Format.check(config, plugin, libs)
|
27
|
+
Fluent::Format.check(config, @options)
|
29
28
|
rescue => e
|
30
29
|
$stderr.puts "#{e.class} #{e.message} #{e.backtrace.first}"
|
31
30
|
exit 1
|
@@ -1,9 +1,11 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Fluent::Format::Check do
|
4
|
-
let(:
|
5
|
-
|
6
|
-
|
4
|
+
let(:opts) {{
|
5
|
+
:plugin_dirs => [File.expand_path('../../../example', File.dirname(__FILE__))],
|
6
|
+
:libs => [File.expand_path('../../../example/out_example', File.dirname(__FILE__))]
|
7
|
+
}}
|
8
|
+
let(:subject) { Fluent::Format.check(config, opts) }
|
7
9
|
|
8
10
|
context "valid" do
|
9
11
|
let(:config) { StringIO.new(%[<match>\ntype stdout\n</match>]) }
|
@@ -40,14 +40,15 @@ describe Fluent::Format::CLI do
|
|
40
40
|
it { expect { subject }.not_to raise_error }
|
41
41
|
end
|
42
42
|
|
43
|
-
context "
|
44
|
-
let(:opts) { {config: "fluent.conf",
|
43
|
+
context "-p option" do
|
44
|
+
let(:opts) { {config: "fluent.conf", plugin_dirs: ["example"]} }
|
45
45
|
it { capture_stderr { subject }.should == "" }
|
46
46
|
it { expect { subject }.not_to raise_error }
|
47
47
|
end
|
48
48
|
|
49
|
-
context "
|
50
|
-
let(:
|
49
|
+
context "-r option" do
|
50
|
+
let(:libs) { [File.expand_path('../../../example/out_example', File.dirname(__FILE__))] }
|
51
|
+
let(:opts) { {config: "fluent.conf", libs: libs } }
|
51
52
|
it { capture_stderr { subject }.should == "" }
|
52
53
|
it { expect { subject }.not_to raise_error }
|
53
54
|
end
|
@@ -65,7 +66,7 @@ describe Fluent::Format::CLI do
|
|
65
66
|
end
|
66
67
|
|
67
68
|
context "param error" do
|
68
|
-
let(:opts) { {config: "example/param_error.conf",
|
69
|
+
let(:opts) { {config: "example/param_error.conf", plugin_dirs: ["example"]} }
|
69
70
|
it { capture_stderr { subject }.should include("out_example.rb") }
|
70
71
|
it { expect { subject }.to raise_error(SystemExit) }
|
71
72
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-format
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Naotoshi Seo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|