fluent-plugin-formatter-protobuf 0.0.3 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/build-and-test.yml +54 -0
- data/.github/workflows/codeql-analysis.yml +49 -0
- data/.github/workflows/publish.yml +96 -0
- data/.gitignore +2 -2
- data/.rubocop.yml +7 -4
- data/.ruby-version +1 -1
- data/README.md +109 -10
- data/RELEASE.md +9 -0
- data/Rakefile +5 -0
- data/fluent-plugin-formatter-protobuf.gemspec +9 -5
- data/lib/fluent/plugin/formatter_protobuf.rb +15 -21
- data/lib/fluent/plugin/version.rb +1 -3
- data/test/integration/Gemfile +6 -0
- data/{Gemfile.lock → test/integration/Gemfile.lock} +11 -19
- data/test/integration/README.md +12 -0
- data/test/integration/fluent.conf +25 -0
- data/test/integration/log.proto +6 -0
- data/test/integration/log_pb.rb +15 -0
- data/test/integration/run.sh +12 -0
- data/test/plugin/test_formatter_protobuf.rb +45 -9
- metadata +72 -18
- data/.github/workflows/gem-push.yml +0 -19
- data/package.json +0 -58
- data/test/proto/addressbook +0 -1
- data/test/proto/addressbook.bin +0 -4
- data/yarn.lock +0 -3725
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
set -euo pipefail
|
4
|
+
|
5
|
+
cd "$(dirname "$0")"
|
6
|
+
|
7
|
+
docker run -it --rm \
|
8
|
+
-v "${PWD}:/opt/fluent-plugin-formatter-protobuf/" \
|
9
|
+
-w '/opt/fluent-plugin-formatter-protobuf/' \
|
10
|
+
-e OUT_FILE="./out" \
|
11
|
+
-p 5170:5170 \
|
12
|
+
ruby:2.7.1 sh -c 'bundle install && fluentd -c /opt/fluent-plugin-formatter-protobuf/fluent.conf'
|
@@ -8,36 +8,72 @@ class ProtobufFormatterTest < Test::Unit::TestCase
|
|
8
8
|
Fluent::Test.setup
|
9
9
|
end
|
10
10
|
|
11
|
-
|
11
|
+
VALID_INCLUDE_PATHS_ABSOLUTE = [File.expand_path(File.join(__dir__, '..', 'proto', 'addressbook_pb.rb'))].freeze
|
12
|
+
|
13
|
+
# Relative to the plugin file
|
14
|
+
VALID_INCLUDE_PATHS_RELATIVE = '../../../test/proto/addressbook_pb.rb'
|
12
15
|
|
13
16
|
sub_test_case 'configure' do
|
14
17
|
test 'fail if include_paths is empty' do
|
15
18
|
assert_raise(Fluent::ConfigError) do
|
16
|
-
create_driver({
|
19
|
+
create_driver({ class_name: '', include_paths: [] })
|
17
20
|
end
|
18
21
|
end
|
19
22
|
|
20
|
-
test 'fail if
|
23
|
+
test 'fail if ruby files not found in the provided include paths' do
|
21
24
|
assert_raise(Fluent::ConfigError) do
|
22
|
-
create_driver({
|
25
|
+
create_driver({ class_name: 'tutorial.AddressBook', include_paths: ['some/random/path'] })
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
test 'fail if no protobuf class can be found with class_name' do
|
30
|
+
assert_raise(Fluent::ConfigError) do
|
31
|
+
create_driver({ class_name: 'Some.Name', include_paths: VALID_INCLUDE_PATHS_ABSOLUTE })
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
test 'success if given valid relative paths in include paths' do
|
36
|
+
assert_nothing_raised do
|
37
|
+
create_driver({ class_name: 'tutorial.AddressBook', include_paths: [VALID_INCLUDE_PATHS_RELATIVE] })
|
23
38
|
end
|
24
39
|
end
|
25
40
|
|
26
41
|
test 'passes on valid configuration' do
|
27
42
|
assert_nothing_raised do
|
28
|
-
create_driver({
|
43
|
+
create_driver({ class_name: 'tutorial.AddressBook', include_paths: VALID_INCLUDE_PATHS_ABSOLUTE })
|
29
44
|
end
|
30
45
|
end
|
31
46
|
end
|
32
47
|
|
48
|
+
stub_ruby_hash = { people: [{ name: 'Masahiro', id: 1337,
|
49
|
+
email: 'repeatedly _at_ gmail.com',
|
50
|
+
last_updated: {
|
51
|
+
seconds: 1_638_489_505,
|
52
|
+
nanos: 318_000_000
|
53
|
+
} }] }
|
33
54
|
sub_test_case 'format' do
|
34
55
|
test 'encodes into Protobuf binary' do
|
35
|
-
formatter = create_formatter({
|
56
|
+
formatter = create_formatter({ class_name: 'tutorial.AddressBook',
|
57
|
+
include_paths: VALID_INCLUDE_PATHS_ABSOLUTE })
|
36
58
|
|
37
59
|
formatted = formatter.format('some-tag', 1234,
|
38
|
-
{ people: [{ name: 'Masahiro', id: 1337, email: 'repeatedly _at_ gmail.com'
|
39
|
-
|
40
|
-
|
60
|
+
{ people: [{ name: 'Masahiro', id: 1337, email: 'repeatedly _at_ gmail.com',
|
61
|
+
last_updated: { seconds: 1_638_489_505, nanos: 318_000_000 } }] })
|
62
|
+
address_book = Tutorial::AddressBook.new(stub_ruby_hash)
|
63
|
+
assert_equal(Tutorial::AddressBook.encode(address_book), formatted)
|
64
|
+
end
|
65
|
+
|
66
|
+
test 'encodes Protobuf JSON format into Protobuf binary if config_param decode_json is true' do
|
67
|
+
formatter = create_formatter({ class_name: 'tutorial.AddressBook',
|
68
|
+
decode_json: true,
|
69
|
+
include_paths: VALID_INCLUDE_PATHS_ABSOLUTE })
|
70
|
+
|
71
|
+
formatted = formatter.format('some-tag', 1234,
|
72
|
+
{ people: [{ name: 'Masahiro', id: 1337, email: 'repeatedly _at_ gmail.com',
|
73
|
+
last_updated: '2021-12-02T23:58:25.318Z' }] })
|
74
|
+
|
75
|
+
address_book = Tutorial::AddressBook.new(stub_ruby_hash)
|
76
|
+
assert_equal(Tutorial::AddressBook.encode(address_book), formatted)
|
41
77
|
end
|
42
78
|
end
|
43
79
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-formatter-protobuf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ray Tung
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-12-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,42 +16,70 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.2
|
19
|
+
version: '2.2'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.2
|
26
|
+
version: '2.2'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 13.0
|
33
|
+
version: '13.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 13.0
|
40
|
+
version: '13.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rubocop
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.22'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.22'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubocop-rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.6'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.6'
|
41
69
|
- !ruby/object:Gem::Dependency
|
42
70
|
name: test-unit
|
43
71
|
requirement: !ruby/object:Gem::Requirement
|
44
72
|
requirements:
|
45
73
|
- - "~>"
|
46
74
|
- !ruby/object:Gem::Version
|
47
|
-
version: 3.3
|
75
|
+
version: '3.3'
|
48
76
|
type: :development
|
49
77
|
prerelease: false
|
50
78
|
version_requirements: !ruby/object:Gem::Requirement
|
51
79
|
requirements:
|
52
80
|
- - "~>"
|
53
81
|
- !ruby/object:Gem::Version
|
54
|
-
version: 3.3
|
82
|
+
version: '3.3'
|
55
83
|
- !ruby/object:Gem::Dependency
|
56
84
|
name: fluentd
|
57
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,6 +114,20 @@ dependencies:
|
|
86
114
|
- - "~>"
|
87
115
|
- !ruby/object:Gem::Version
|
88
116
|
version: '3.18'
|
117
|
+
- !ruby/object:Gem::Dependency
|
118
|
+
name: oj
|
119
|
+
requirement: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - "~>"
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '3.13'
|
124
|
+
type: :runtime
|
125
|
+
prerelease: false
|
126
|
+
version_requirements: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - "~>"
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '3.13'
|
89
131
|
description: This is a Fluentd formatter plugin designed to convert Protobuf JSON
|
90
132
|
into Protobuf binary
|
91
133
|
email:
|
@@ -94,33 +136,39 @@ executables: []
|
|
94
136
|
extensions: []
|
95
137
|
extra_rdoc_files: []
|
96
138
|
files:
|
97
|
-
- ".github/workflows/
|
139
|
+
- ".github/workflows/build-and-test.yml"
|
140
|
+
- ".github/workflows/codeql-analysis.yml"
|
141
|
+
- ".github/workflows/publish.yml"
|
98
142
|
- ".gitignore"
|
99
143
|
- ".rubocop.yml"
|
100
144
|
- ".ruby-version"
|
101
145
|
- Gemfile
|
102
|
-
- Gemfile.lock
|
103
146
|
- LICENSE
|
104
147
|
- README.md
|
148
|
+
- RELEASE.md
|
105
149
|
- Rakefile
|
106
150
|
- docker-compose.yaml
|
107
151
|
- docker-run.sh
|
108
152
|
- fluent-plugin-formatter-protobuf.gemspec
|
109
153
|
- lib/fluent/plugin/formatter_protobuf.rb
|
110
154
|
- lib/fluent/plugin/version.rb
|
111
|
-
- package.json
|
112
155
|
- test/helper.rb
|
156
|
+
- test/integration/Gemfile
|
157
|
+
- test/integration/Gemfile.lock
|
158
|
+
- test/integration/README.md
|
159
|
+
- test/integration/fluent.conf
|
160
|
+
- test/integration/log.proto
|
161
|
+
- test/integration/log_pb.rb
|
162
|
+
- test/integration/run.sh
|
113
163
|
- test/plugin/test_formatter_protobuf.rb
|
114
164
|
- test/proto/README.md
|
115
|
-
- test/proto/addressbook
|
116
|
-
- test/proto/addressbook.bin
|
117
165
|
- test/proto/addressbook.proto
|
118
166
|
- test/proto/addressbook_pb.rb
|
119
|
-
- yarn.lock
|
120
167
|
homepage: https://github.com/raytung/fluent-plugin-formatter-protobuf
|
121
168
|
licenses:
|
122
169
|
- Apache-2.0
|
123
170
|
metadata:
|
171
|
+
rubygems_mfa_required: 'true'
|
124
172
|
homepage_uri: https://github.com/raytung/fluent-plugin-formatter-protobuf
|
125
173
|
source_code_uri: https://github.com/raytung/fluent-plugin-formatter-protobuf
|
126
174
|
changelog_uri: https://github.com/raytung/fluent-plugin-formatter-protobuf/blob/main/CHANGELOG.md
|
@@ -132,22 +180,28 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
132
180
|
requirements:
|
133
181
|
- - ">="
|
134
182
|
- !ruby/object:Gem::Version
|
135
|
-
version: 2.
|
183
|
+
version: 2.5.0
|
136
184
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
137
185
|
requirements:
|
138
186
|
- - ">="
|
139
187
|
- !ruby/object:Gem::Version
|
140
188
|
version: '0'
|
141
189
|
requirements: []
|
142
|
-
|
190
|
+
rubyforge_project:
|
191
|
+
rubygems_version: 2.7.3
|
143
192
|
signing_key:
|
144
193
|
specification_version: 4
|
145
194
|
summary: Protobuf formatter for Fluentd
|
146
195
|
test_files:
|
147
196
|
- test/helper.rb
|
197
|
+
- test/integration/Gemfile
|
198
|
+
- test/integration/Gemfile.lock
|
199
|
+
- test/integration/README.md
|
200
|
+
- test/integration/fluent.conf
|
201
|
+
- test/integration/log.proto
|
202
|
+
- test/integration/log_pb.rb
|
203
|
+
- test/integration/run.sh
|
148
204
|
- test/plugin/test_formatter_protobuf.rb
|
149
205
|
- test/proto/README.md
|
150
|
-
- test/proto/addressbook
|
151
|
-
- test/proto/addressbook.bin
|
152
206
|
- test/proto/addressbook.proto
|
153
207
|
- test/proto/addressbook_pb.rb
|
@@ -1,19 +0,0 @@
|
|
1
|
-
name: Publish Package
|
2
|
-
on:
|
3
|
-
push:
|
4
|
-
branches:
|
5
|
-
- "main"
|
6
|
-
pull_request:
|
7
|
-
branches:
|
8
|
-
- "main"
|
9
|
-
jobs:
|
10
|
-
release:
|
11
|
-
runs-on: ubuntu-latest
|
12
|
-
steps:
|
13
|
-
- uses: actions/checkout@v2.3.5
|
14
|
-
- uses: actions/setup-node@v2.4.1
|
15
|
-
with:
|
16
|
-
node-version: "16"
|
17
|
-
- uses: ruby/setup-ruby@v1.83.0
|
18
|
-
with:
|
19
|
-
ruby-version: "2.7.1"
|
data/package.json
DELETED
@@ -1,58 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"name": "fluent-plugin-formatter-protobuf",
|
3
|
-
"version": "0.0.3",
|
4
|
-
"description": "Protobuf formatter for Fluentd",
|
5
|
-
"main": "dist/index.js",
|
6
|
-
"repository": "git@github.com:raytung/fluent-plugin-formatter-protobuf.git",
|
7
|
-
"author": "Ray Tung <code@raytung.net>",
|
8
|
-
"license": "Apache-2.0",
|
9
|
-
"private": false,
|
10
|
-
"scripts": {
|
11
|
-
"release": "semantic-release"
|
12
|
-
},
|
13
|
-
"devDependencies": {
|
14
|
-
"@semantic-release/changelog": "^6.0.0",
|
15
|
-
"@semantic-release/commit-analyzer": "^9.0.1",
|
16
|
-
"@semantic-release/git": "^10.0.0",
|
17
|
-
"@semantic-release/github": "^8.0.1",
|
18
|
-
"@semantic-release/npm": "^8.0.0",
|
19
|
-
"@semantic-release/release-notes-generator": "^10.0.2",
|
20
|
-
"semantic-release": "^18.0.0",
|
21
|
-
"semantic-release-rubygem": "^1.2.0"
|
22
|
-
},
|
23
|
-
"release": {
|
24
|
-
"branches": [
|
25
|
-
"main"
|
26
|
-
],
|
27
|
-
"plugins": [
|
28
|
-
"@semantic-release/commit-analyzer",
|
29
|
-
"@semantic-release/release-notes-generator",
|
30
|
-
[
|
31
|
-
"@semantic-release/npm",
|
32
|
-
{
|
33
|
-
"npmPublish": false
|
34
|
-
}
|
35
|
-
],
|
36
|
-
[
|
37
|
-
"semantic-release-rubygem",
|
38
|
-
{
|
39
|
-
"updateGemfileLock": true
|
40
|
-
}
|
41
|
-
],
|
42
|
-
"@semantic-release/changelog",
|
43
|
-
[
|
44
|
-
"@semantic-release/git",
|
45
|
-
{
|
46
|
-
"assets": [
|
47
|
-
"package.json",
|
48
|
-
"yarn.lock",
|
49
|
-
"lib/fluent/plugin/version.rb",
|
50
|
-
"CHANGELOG.md"
|
51
|
-
],
|
52
|
-
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
|
53
|
-
}
|
54
|
-
],
|
55
|
-
"@semantic-release/github"
|
56
|
-
]
|
57
|
-
}
|
58
|
-
}
|
data/test/proto/addressbook
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
people: [{name:"Masahiro", id: 1337, email: "repeatedly _at_ gmail.com"}]
|
data/test/proto/addressbook.bin
DELETED