fluent-format 0.2.0 → 0.2.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +0 -4
- data/lib/fluent/format/check.rb +7 -4
- data/lib/fluent/format/cli.rb +9 -2
- data/lib/fluent/format/format.rb +1 -0
- data/lib/fluent/format/version.rb +1 -1
- data/spec/fluent/format/check_spec.rb +21 -0
- data/spec/fluent/format/cli_spec.rb +34 -0
- data/spec/fluent/format/format_spec.rb +22 -0
- data/spec/spec_helper.rb +12 -0
- metadata +10 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 60872a23fdf2060c3e94c301c8b6f5e1e3eb3a66
|
4
|
+
data.tar.gz: 155f128a5bd00841a294aa2beeb4b3f6718d96ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d852f71daed2299560ba8b8bbbdce60eb2ec6d09d27d15fcc455390b79cbf6bc89fb422dc418169e0778ec21a1d6219c4a05f083340fdf610bb813d751230258
|
7
|
+
data.tar.gz: f0c342aebc5a321dd7e59196200a91b5b0a19cee46d4cadb551c91ce01f8f99fdde936b0480e46e17e3c1fc40b49ea2abf0c950090f5601ed22f8fd95a925261
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
data/lib/fluent/format/check.rb
CHANGED
@@ -26,7 +26,9 @@ module Fluent
|
|
26
26
|
|
27
27
|
# Check config file
|
28
28
|
#
|
29
|
-
# @
|
29
|
+
# @raise Fluent::ConfigParseError if conf has syntax errors
|
30
|
+
# @raise Fluent::ConfigError if plugin raises config error
|
31
|
+
# @return true if success
|
30
32
|
def run
|
31
33
|
Fluent::Supervisor.new(@opts).ext_dry_run
|
32
34
|
end
|
@@ -37,6 +39,10 @@ end
|
|
37
39
|
module Fluent
|
38
40
|
class Supervisor
|
39
41
|
# Extended to accept IO object
|
42
|
+
#
|
43
|
+
# @raise Fluent::ConfigParseError if conf has syntax errors
|
44
|
+
# @raise Fluent::ConfigError if plugin raises config error
|
45
|
+
# @return true if success
|
40
46
|
def ext_dry_run
|
41
47
|
ext_read_config
|
42
48
|
change_privilege
|
@@ -44,8 +50,6 @@ module Fluent
|
|
44
50
|
install_main_process_signal_handlers
|
45
51
|
run_configure
|
46
52
|
true
|
47
|
-
rescue => e
|
48
|
-
false
|
49
53
|
end
|
50
54
|
|
51
55
|
# Extended to accept IO object
|
@@ -53,7 +57,6 @@ module Fluent
|
|
53
57
|
if @config_path.respond_to?(:read) # IO object
|
54
58
|
@config_data = @config_path.read
|
55
59
|
else
|
56
|
-
$log.info "reading config file", :path=>@config_path
|
57
60
|
@config_fname = File.basename(@config_path)
|
58
61
|
@config_basedir = File.dirname(@config_path)
|
59
62
|
@config_data = File.read(@config_path)
|
data/lib/fluent/format/cli.rb
CHANGED
@@ -9,7 +9,7 @@ module Fluent
|
|
9
9
|
option :config, :aliases => ["-c"], :type => :string, :default => 'fluent.conf', :desc => 'Fluentd configuration file'
|
10
10
|
def format
|
11
11
|
config = @options[:config]
|
12
|
-
|
12
|
+
taputs Fluent::Format.format(config)
|
13
13
|
rescue => e
|
14
14
|
$log.error "#{e.class}: #{e}"
|
15
15
|
exit 1
|
@@ -21,11 +21,18 @@ module Fluent
|
|
21
21
|
def check
|
22
22
|
config = @options[:config]
|
23
23
|
plugin = @options[:plugin]
|
24
|
-
Fluent::Format.check(config, plugin)
|
24
|
+
Fluent::Format.check(config, plugin)
|
25
25
|
rescue => e
|
26
26
|
$log.error "#{e.class}: #{e}"
|
27
27
|
exit 1
|
28
28
|
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def taputs(str)
|
33
|
+
puts str
|
34
|
+
str
|
35
|
+
end
|
29
36
|
end
|
30
37
|
end
|
31
38
|
end
|
data/lib/fluent/format/format.rb
CHANGED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Fluent::Format::Check do
|
4
|
+
let(:subject) { Fluent::Format.check(config) }
|
5
|
+
|
6
|
+
context "valid" do
|
7
|
+
let(:config) { StringIO.new(%[<match>\ntype stdout\n</match>]) }
|
8
|
+
it { should be_true }
|
9
|
+
end
|
10
|
+
|
11
|
+
context "syntax error" do
|
12
|
+
let(:config) { StringIO.new(%[<source>\ntype stdout\n</match>]) }
|
13
|
+
it { expect { subject }.to raise_error(Fluent::ConfigParseError) }
|
14
|
+
end
|
15
|
+
|
16
|
+
context "plugin error" do
|
17
|
+
let(:config) { StringIO.new(%[<match>\ntype foobar\n</match>]) }
|
18
|
+
it { expect { subject }.to raise_error(Fluent::ConfigError) }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'fluent/format/cli'
|
3
|
+
|
4
|
+
describe Fluent::Format::CLI do
|
5
|
+
let(:cli) { Fluent::Format::CLI.new }
|
6
|
+
|
7
|
+
context "#format" do
|
8
|
+
let(:subject) { cli.invoke(:format, [], opts) }
|
9
|
+
|
10
|
+
context "success" do
|
11
|
+
let(:opts) { {config: "fluent.conf"} }
|
12
|
+
it { expect { subject }.not_to raise_error }
|
13
|
+
end
|
14
|
+
|
15
|
+
context "failure" do
|
16
|
+
let(:opts) { {config: "unknown.conf"} }
|
17
|
+
it { expect { subject }.to raise_error(SystemExit) }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context "#check" do
|
22
|
+
let(:subject) { cli.invoke(:check, [], opts) }
|
23
|
+
|
24
|
+
context "success" do
|
25
|
+
let(:opts) { {config: "fluent.conf"} }
|
26
|
+
it { expect { subject }.not_to raise_error }
|
27
|
+
end
|
28
|
+
|
29
|
+
context "failure" do
|
30
|
+
let(:opts) { {config: "unknown.conf"} }
|
31
|
+
it { expect { subject }.to raise_error(SystemExit) }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Fluent::Format::Format do
|
4
|
+
let(:subject) { Fluent::Format.format(config) }
|
5
|
+
|
6
|
+
context "valid" do
|
7
|
+
let(:config) { StringIO.new(%[<match>\ntype stdout\n</match>]) }
|
8
|
+
it { should == %[<match>\n type stdout\n</match>] }
|
9
|
+
end
|
10
|
+
|
11
|
+
context "syntax error" do
|
12
|
+
let(:config) { StringIO.new(%[<source>\ntype stdout\n</match>]) }
|
13
|
+
it { expect { subject }.to raise_error(Fluent::ConfigParseError) }
|
14
|
+
end
|
15
|
+
|
16
|
+
context "plugin error is not checked" do
|
17
|
+
let(:config) { StringIO.new(%[<match>\ntype foobar\n</match>]) }
|
18
|
+
it { should == %[<match>\n type foobar\n</match>] }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "bundler/setup"
|
3
|
+
require "pry"
|
4
|
+
require 'fluent-format'
|
5
|
+
|
6
|
+
ROOT = File.dirname(__FILE__)
|
7
|
+
Dir[File.expand_path("support/**/*.rb", ROOT)].each {|f| require f }
|
8
|
+
|
9
|
+
RSpec.configure do |config|
|
10
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
11
|
+
config.run_all_when_everything_filtered = true
|
12
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Naotoshi Seo
|
@@ -121,6 +121,10 @@ files:
|
|
121
121
|
- lib/fluent/format/cli.rb
|
122
122
|
- lib/fluent/format/format.rb
|
123
123
|
- lib/fluent/format/version.rb
|
124
|
+
- spec/fluent/format/check_spec.rb
|
125
|
+
- spec/fluent/format/cli_spec.rb
|
126
|
+
- spec/fluent/format/format_spec.rb
|
127
|
+
- spec/spec_helper.rb
|
124
128
|
homepage: https://github.com/sonots/fluent-format
|
125
129
|
licenses:
|
126
130
|
- MIT
|
@@ -145,4 +149,8 @@ rubygems_version: 2.0.3
|
|
145
149
|
signing_key:
|
146
150
|
specification_version: 4
|
147
151
|
summary: A command line utility to format fluentd configuration beautifully
|
148
|
-
test_files:
|
152
|
+
test_files:
|
153
|
+
- spec/fluent/format/check_spec.rb
|
154
|
+
- spec/fluent/format/cli_spec.rb
|
155
|
+
- spec/fluent/format/format_spec.rb
|
156
|
+
- spec/spec_helper.rb
|