fluentd-v1-checker 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.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +36 -0
- data/Rakefile +2 -0
- data/bin/fluentd-v1-checker +28 -0
- data/fluentd-v1-checker.gemspec +26 -0
- data/lib/fluentd/v1/checker.rb +41 -0
- data/lib/fluentd/v1/checker/version.rb +7 -0
- metadata +111 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: fe3c03afe8e8397d696529e953cb77800ca649c6
|
4
|
+
data.tar.gz: c7aa597356583613cf3707580eac3264721776c2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f79b851a2e99303867fc5ad57a9382411d8aabe746d3937b8857b2cf53f725f74eca95486e877022acb83b661dbb575828afe0157757450a39dcf85722fefdf2
|
7
|
+
data.tar.gz: d222f1664f3d7ab29929969c15b3707f7162fb7ccc67e15e9f8072d055125dd6e72934f48cb4351c36897a6778e47006679a6c8e22922f84774ecea317e85e81
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 TAGOMORI Satoshi
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# fluentd-v1-checker
|
2
|
+
|
3
|
+
Checker utility for Fluentd v1 configuration syntax.
|
4
|
+
|
5
|
+
* to check Fluentd configuration files are valid as both of v0 (classic) and v1 syntax
|
6
|
+
* to check difference between v0 and v1 configuration files
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
$ gem install fluentd-v1-checker
|
11
|
+
|
12
|
+
## Usage
|
13
|
+
|
14
|
+
```
|
15
|
+
Usage: fluentd-v1-checker [options] CONF_PATH
|
16
|
+
--with-v1-conf V1_CONF_PATH configuration file path with v1 syntax to be checked whether same or not
|
17
|
+
```
|
18
|
+
|
19
|
+
To check classic configuration file is valid as v1:
|
20
|
+
|
21
|
+
$ fluentd-v1-checker my_fluentd.conf
|
22
|
+
|
23
|
+
To check v1 configuration file is actually same with classic configuration file:
|
24
|
+
|
25
|
+
$ fluentd-v1-checker --with-v1-conf my_v1_fluentd.conf my_classic_fluentd.conf
|
26
|
+
|
27
|
+
If any differences exist, this utility shows entire parse result and diff, and exits with code 1.
|
28
|
+
If no difference exists, it exits with code 0 without any output.
|
29
|
+
|
30
|
+
## Contributing
|
31
|
+
|
32
|
+
1. Fork it ( https://github.com/[my-github-username]/fluentd-v1-checker/fork )
|
33
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
34
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
35
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
36
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'fluentd/v1/checker'
|
4
|
+
require "optparse"
|
5
|
+
|
6
|
+
opt = OptionParser.new
|
7
|
+
|
8
|
+
v1conf_path = nil
|
9
|
+
opt.on('-w PATH', '--with-v1-conf PATH', "v1 syntax conf path to be checked same with CONF_PATH") {|v| v1conf_path = v }
|
10
|
+
opt.on('-h', '--help', "show this message") {|v| puts opt.help; exit 2 }
|
11
|
+
opt.version = Fluentd::V1::Checker::VERSION
|
12
|
+
opt.banner = "Usage: fluentd-v1-checker [options] CONF_PATH"
|
13
|
+
|
14
|
+
invalid = false
|
15
|
+
|
16
|
+
begin
|
17
|
+
opt.parse!(ARGV)
|
18
|
+
rescue OptionParser::InvalidOption => e
|
19
|
+
puts e.message
|
20
|
+
invalid = true
|
21
|
+
end
|
22
|
+
|
23
|
+
if invalid || ARGV.size != 1
|
24
|
+
puts opt.help
|
25
|
+
exit 2
|
26
|
+
end
|
27
|
+
|
28
|
+
Fluentd::V1::Checker.execute(ARGV.first, v1conf_path)
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'fluentd/v1/checker/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "fluentd-v1-checker"
|
8
|
+
spec.version = Fluentd::V1::Checker::VERSION
|
9
|
+
spec.authors = ["TAGOMORI Satoshi"]
|
10
|
+
spec.email = ["tagomoris@gmail.com"]
|
11
|
+
spec.summary = %q{Checker utility for Fluentd v1 configuration syntax}
|
12
|
+
spec.description = %q{Command to check Fluentd configuration files are valid as v1 configuration, or to check difference between v0 and v1 configuration files}
|
13
|
+
spec.homepage = "https://github.com/tagomoris/fluentd-v1-checker"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_runtime_dependency "fluentd"
|
22
|
+
spec.add_runtime_dependency "diffy"
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require "fluentd/v1/checker/version"
|
2
|
+
|
3
|
+
require "fluent/config/parser"
|
4
|
+
require "fluent/config/v1_parser"
|
5
|
+
|
6
|
+
require "diffy"
|
7
|
+
|
8
|
+
module Fluentd
|
9
|
+
module V1
|
10
|
+
module Checker
|
11
|
+
def self.parse_classic(path)
|
12
|
+
str = File.read(path)
|
13
|
+
fname = File.basename(path)
|
14
|
+
dirname = File.dirname(path)
|
15
|
+
Fluent::Config::Parser.parse(str, fname, dirname)
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.parse_v1(path)
|
19
|
+
str = File.read(path)
|
20
|
+
fname = File.basename(path)
|
21
|
+
dirname = File.dirname(path)
|
22
|
+
Fluent::Config::V1Parser.parse(str, fname, dirname, Kernel.binding)
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.execute(path, v1conf_path)
|
26
|
+
v0 = parse_classic(path).to_s.rstrip + "\n"
|
27
|
+
v1 = parse_v1(v1conf_path || path).to_s.rstrip + "\n"
|
28
|
+
diff = Diffy::Diff.new(v0, v1, :include_diff_info => true ).to_s(:color)
|
29
|
+
if diff.strip.empty? && v1conf_path
|
30
|
+
# ok
|
31
|
+
elsif diff.strip.empty?
|
32
|
+
# ok
|
33
|
+
else
|
34
|
+
diff = diff.sub(/--- .*$/){ "--- CLASSIC PARSE" }.sub(/\+\+\+ .*$/){ "+++ V1 PARSE" }
|
35
|
+
puts diff
|
36
|
+
exit 1
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
metadata
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluentd-v1-checker
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- TAGOMORI Satoshi
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-12-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: fluentd
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: diffy
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.7'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.7'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
description: Command to check Fluentd configuration files are valid as v1 configuration,
|
70
|
+
or to check difference between v0 and v1 configuration files
|
71
|
+
email:
|
72
|
+
- tagomoris@gmail.com
|
73
|
+
executables:
|
74
|
+
- fluentd-v1-checker
|
75
|
+
extensions: []
|
76
|
+
extra_rdoc_files: []
|
77
|
+
files:
|
78
|
+
- ".gitignore"
|
79
|
+
- Gemfile
|
80
|
+
- LICENSE.txt
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- bin/fluentd-v1-checker
|
84
|
+
- fluentd-v1-checker.gemspec
|
85
|
+
- lib/fluentd/v1/checker.rb
|
86
|
+
- lib/fluentd/v1/checker/version.rb
|
87
|
+
homepage: https://github.com/tagomoris/fluentd-v1-checker
|
88
|
+
licenses:
|
89
|
+
- MIT
|
90
|
+
metadata: {}
|
91
|
+
post_install_message:
|
92
|
+
rdoc_options: []
|
93
|
+
require_paths:
|
94
|
+
- lib
|
95
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
requirements: []
|
106
|
+
rubyforge_project:
|
107
|
+
rubygems_version: 2.2.2
|
108
|
+
signing_key:
|
109
|
+
specification_version: 4
|
110
|
+
summary: Checker utility for Fluentd v1 configuration syntax
|
111
|
+
test_files: []
|