fluent-plugin-barito 0.1.14 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: b84669e65564859fa5fe631b76e71d9f830a23d66a524c5942d4300be7396c24
4
- data.tar.gz: 60f1835917729abd12d00608f81c18aa063aee92925ca0246bfe720603d0c260
2
+ SHA1:
3
+ metadata.gz: a9443cfecff7d382c4941e5bfae21d520a3818d7
4
+ data.tar.gz: b49bf6375814aeb01bddda08bf2b2a6573392dd6
5
5
  SHA512:
6
- metadata.gz: fc7bde45ea4f7601f0a35ed06ab6f3342da74574b6e7adcc344081afe0479ee7d3f9532106cd0aaa070bb811f1623b81590ea5c71288c3231a3085af822834bd
7
- data.tar.gz: 889dc1965589f3f9418163af70c14a2329a61692e7f5f25f7cc843cfc984e99365d1bcb94c3c56ad1064dff3dfd6153be2782e3c35741fba930d4b601cf34ff1
6
+ metadata.gz: b72763e3cbe8b57c0a297d44de0ed348fbf1f39537f6891aee75dadc66ee68983c595fea042ce1fc07f5083ad65f1ef37f289263b4991da1cb09b3007c344a70
7
+ data.tar.gz: fdef293d09591b1adbf5d34a1eb68c1970fc6d70c5ad70b27c2d1951af00d39afb64c30c68d93424adfff09d519c26b89dd30bb6e7b93d3f508cb32dc9c66012
@@ -0,0 +1,5 @@
1
+ # Changelog
2
+
3
+ **0.2.0**
4
+
5
+ - Allow Application Group Secret to be used
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
 
4
4
  Gem::Specification.new do |spec|
5
5
  spec.name = "fluent-plugin-barito"
6
- spec.version = "0.1.14"
6
+ spec.version = "0.2.0"
7
7
  spec.authors = ["BaritoLog"]
8
8
  spec.email = ["pushm0v.development@gmail.com", "iman.tung@gmail.com"]
9
9
 
@@ -8,6 +8,8 @@ module Fluent
8
8
 
9
9
  PLUGIN_NAME = 'barito_k8s'
10
10
  LABEL_APP_SECRET = 'barito.applicationSecret'
11
+ LABEL_APP_GROUP_SECRET = 'barito.applicationGroupSecret'
12
+ LABEL_APP_NAME = 'barito.applicationName'
11
13
  LABEL_PRODUCE_URL = 'barito.produceUrl'
12
14
 
13
15
  Fluent::Plugin.register_output(PLUGIN_NAME, self)
@@ -33,9 +35,22 @@ module Fluent
33
35
  # Skip record if no annotations found
34
36
  next if params.nil?
35
37
  url = produce_url(params)
36
- secret = application_secret(params)
37
-
38
- next if url.nil? or secret.nil?
38
+ app_secret = application_secret(params)
39
+ app_group_secret = application_group_secret(params)
40
+ app_name = application_name(params)
41
+
42
+ next if url.nil?
43
+
44
+ if app_secret.nil?
45
+ next if app_group_secret.nil? or app_name.nil?
46
+ header = {
47
+ content_type: :json,
48
+ 'X-App-Group-Secret' => app_group_secret,
49
+ 'X-App-Name' => app_name
50
+ }
51
+ else
52
+ header = {content_type: :json, 'X-App-Secret' => app_secret}
53
+ end
39
54
 
40
55
  record = clean_attribute(record)
41
56
  trail = Fluent::Plugin::ClientTrail.new(true)
@@ -50,8 +65,6 @@ module Fluent
50
65
  'host' => k8s_metadata['host']
51
66
  }
52
67
 
53
- header = {content_type: :json, 'X-App-Secret' => secret}
54
-
55
68
  RestClient.post url, new_timber.to_json, header
56
69
  end
57
70
  end
@@ -64,6 +77,14 @@ module Fluent
64
77
  params[LABEL_APP_SECRET]
65
78
  end
66
79
 
80
+ def application_group_secret(params)
81
+ params[LABEL_APP_GROUP_SECRET]
82
+ end
83
+
84
+ def application_name(params)
85
+ params[LABEL_APP_NAME]
86
+ end
87
+
67
88
  def clean_attribute(record)
68
89
  # Delete kubernetes & docker field
69
90
  record.delete('kubernetes')
@@ -7,10 +7,12 @@ module Fluent
7
7
  class BaritoVMOutput < BufferedOutput
8
8
 
9
9
  PLUGIN_NAME = "barito_vm"
10
-
10
+
11
11
  Fluent::Plugin.register_output(PLUGIN_NAME, self)
12
12
 
13
13
  config_param :application_secret, :string, :default => nil
14
+ config_param :application_group_secret, :string, :default => nil
15
+ config_param :application_name, :string, :default => nil
14
16
  config_param :produce_url, :string, :default => ''
15
17
 
16
18
  # Overide from BufferedOutput
@@ -28,13 +30,20 @@ module Fluent
28
30
  chunk.msgpack_each do |tag, time, record|
29
31
  trail = Fluent::Plugin::ClientTrail.new(false)
30
32
  timber = Fluent::Plugin::TimberFactory::create_timber(tag, time, record, trail)
31
- header = {content_type: :json, 'X-App-Secret' => @application_secret}
32
-
33
+
34
+ if @application_secret.nil? or @application_secret.blank?
35
+ next if @application_group_secret.nil? or @application_name.nil?
36
+ header = {
37
+ content_type: :json,
38
+ 'X-App-Group-Secret' => @application_group_secret,
39
+ 'X-App-Name' => @application_name
40
+ }
41
+ else
42
+ header = {content_type: :json, 'X-App-Secret' => @application_secret}
43
+ end
44
+
33
45
  RestClient.post @produce_url, timber.to_json, header
34
46
  end
35
47
  end
36
-
37
48
  end
38
-
39
-
40
49
  end
@@ -1,24 +1,24 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe 'Fluent::BaritoK8sOutput' do
4
-
4
+
5
5
  describe '.produce_url' do
6
6
  it do
7
7
  k8s_labels = {
8
8
  Fluent::BaritoK8sOutput::LABEL_PRODUCE_URL => 'https://localhost:5000/produce/sometopic'
9
9
  }
10
-
10
+
11
11
  out = Fluent::BaritoK8sOutput.new
12
12
  url = out.produce_url(k8s_labels)
13
13
  expect(url).to eq 'https://localhost:5000/produce/sometopic'
14
14
  end
15
-
15
+
16
16
  end
17
-
17
+
18
18
  describe '.application_secret' do
19
19
  it do
20
20
  out = Fluent::BaritoK8sOutput.new
21
-
21
+
22
22
  k8s_labels = {
23
23
  Fluent::BaritoK8sOutput::LABEL_APP_SECRET => 'some_secret'
24
24
  }
@@ -27,6 +27,30 @@ describe 'Fluent::BaritoK8sOutput' do
27
27
  end
28
28
  end
29
29
 
30
+ describe '.application_group_secret' do
31
+ it do
32
+ out = Fluent::BaritoK8sOutput.new
33
+
34
+ k8s_labels = {
35
+ Fluent::BaritoK8sOutput::LABEL_APP_GROUP_SECRET => 'some_secret'
36
+ }
37
+ secret = out.application_group_secret(k8s_labels)
38
+ expect(secret).to eq 'some_secret'
39
+ end
40
+ end
41
+
42
+ describe '.application_name' do
43
+ it do
44
+ out = Fluent::BaritoK8sOutput.new
45
+
46
+ k8s_labels = {
47
+ Fluent::BaritoK8sOutput::LABEL_APP_NAME => 'some_name'
48
+ }
49
+ app_name = out.application_name(k8s_labels)
50
+ expect(app_name).to eq 'some_name'
51
+ end
52
+ end
53
+
30
54
  describe '.merge_log_attribute' do
31
55
  it do
32
56
  out = Fluent::BaritoK8sOutput.new
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-barito
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.14
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - BaritoLog
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-08 00:00:00.000000000 Z
11
+ date: 2018-10-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -154,6 +154,7 @@ files:
154
154
  - ".gitignore"
155
155
  - ".rspec"
156
156
  - ".travis.yml"
157
+ - CHANGELOG.md
157
158
  - Gemfile
158
159
  - LICENSE
159
160
  - README.md
@@ -186,7 +187,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
186
187
  version: '0'
187
188
  requirements: []
188
189
  rubyforge_project:
189
- rubygems_version: 2.7.6
190
+ rubygems_version: 2.6.14
190
191
  signing_key:
191
192
  specification_version: 4
192
193
  summary: Fluentd output plugin for BaritoLog