fluent-plugin-wodby 0.1.2 → 0.1.5

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
2
  SHA256:
3
- metadata.gz: 13aa893cfb355e20164d075f6b18684fc482e6e89dc5c4bfdd7c7e143a8fc9cc
4
- data.tar.gz: '083c6cf98fdfee4fdc6cdc199d8c7e5924da14b045537db2d4344e582c1c9f56'
3
+ metadata.gz: ec5aac4ba42f1eb469da3610fe5451181c59db36115ab2b2234fce6df99e8091
4
+ data.tar.gz: 298cde6628e7c10fb5ccaed095fb93847f9f713b6877b4a7a1b886c92e3821c3
5
5
  SHA512:
6
- metadata.gz: 7bf8ba304a99a79dc966bd3a27a3ad54dc48f2a9d5d5530dbb0066a44dda7738d7f4d0d368c424fffc08b8cdf9ae64018273d9eccf5d8c970d8829d0fd50e3a1
7
- data.tar.gz: ac46fdb14afaf0912004803d8cf35d69f31283e797231e701db104017b70e5d8805df011fc296ad703198a1beb3af56dde3b258f89c5dc3a136367dda9c9a8b4
6
+ metadata.gz: 8872f83349b861730ccbb648a27a2c296f05bdf21685699248286474b352d70749e211354980efbd4cbf781696c8aa0f8406bf2ba92d9235aef86d7a22516867
7
+ data.tar.gz: 60577048aad3abcb8a3b51a80a481d865d279d41b35e8a2ce3e5475b8fb7e33d20c67c77f0709d89340ac26b2cb3f7016599a56fecea7d7f97168662b9fefa89
data/Makefile ADDED
@@ -0,0 +1,9 @@
1
+ PWD=$(shell pwd)
2
+
3
+ .PHONY: docker-test
4
+ docker-test:
5
+ docker run --rm -it -v $(PWD):/build -e WODBY_API_KEY=${WODBY_API_KEY} ruby /bin/bash -c "cd build && bundle install && bundle exec rake test"
6
+
7
+ .PHONY: docker-tester
8
+ docker-tester:
9
+ docker run --rm -it -v $(PWD):/build -e WODBY_API_KEY=${WODBY_API_KEY} ruby /bin/bash
@@ -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-wodby"
6
- spec.version = "0.1.2"
6
+ spec.version = "0.1.5"
7
7
  spec.authors = ["Robert Wunderer"]
8
8
  spec.email = ["robert@ramsalt.com"]
9
9
 
@@ -24,12 +24,26 @@ module Fluent
24
24
 
25
25
  config_param :api_key, :string, secret: true
26
26
 
27
+ def start
28
+ super
29
+
30
+ @instance_map = {}
31
+ log.info "Initialized wodby plugin"
32
+ end
33
+
27
34
  def filter(tag, time, record)
35
+ record['wodby.filter'] = true
36
+
28
37
  if record.has_key?('kubernetes.namespace_name')
29
- instance = get_instance(record['kubernetes.namespace_name'])
30
- app = get_app(instance['app_id'])
38
+ unless @instance_map.has_key?(record['kubernetes.namespace_name'])
39
+ record['wodby.instance_query'] = record['kubernetes.namespace_name']
40
+ instance = get_instance(record['kubernetes.namespace_name'])
41
+ app = get_app(instance['app_id'])
42
+
43
+ @instance_map[record['kubernetes.namespace_name']] = "#{app['title']}-#{instance['name']}"
44
+ end
31
45
 
32
- record['wodby.instance'] = "#{app['title']}-#{instance['name']}"
46
+ record['wodby.instance'] = @instance_map[record['kubernetes.namespace_name']]
33
47
  end
34
48
 
35
49
  record
@@ -44,7 +58,7 @@ module Fluent
44
58
  headers={'X-API-KEY': @api_key}
45
59
  )
46
60
  instance = JSON.parse(response)
47
- rescue RestClient::ExceptionWithResponse => e
61
+ rescue RestClient::ExceptionWithResponse
48
62
  instance = {}
49
63
  end
50
64
 
@@ -58,7 +72,7 @@ module Fluent
58
72
  headers={'X-API-KEY': @api_key}
59
73
  )
60
74
  app = JSON.parse(response)
61
- rescue RestClient::ExceptionWithResponse => e
75
+ rescue RestClient::ExceptionWithResponse
62
76
  app = {}
63
77
  end
64
78
 
@@ -18,10 +18,16 @@ class WodbyFilterTest < Test::Unit::TestCase
18
18
  d.run do
19
19
  d.feed('filter.test', time, { 'kubernetes.namespace_name' => '650241f4-7303-4668-91c7-b8cd1821d81a', 'message' => 'hullo' })
20
20
  d.feed('filter.test', time, { 'kubernetes.namespace_name' => 'a3d67f12-8341-4245-87db-ed7a6c856e70', 'message' => 'hullo' })
21
+ d.feed('filter.test', time, { 'kubernetes.namespace_name' => '650241f4-7303-4668-91c7-b8cd1821d81a', 'message' => 'hullo' })
21
22
  end
22
23
 
23
- assert_equal(2, d.filtered_records.size)
24
+ assert_equal(3, d.filtered_records.size)
24
25
  assert_equal('dfo.no-staging', d.filtered_records[0]['wodby.instance'])
25
26
  assert_equal('dfo.no-prod', d.filtered_records[1]['wodby.instance'])
27
+ assert_equal('dfo.no-staging', d.filtered_records[2]['wodby.instance'])
28
+ assert_nil(d.filtered_records[2]['wodby.instance_query'])
29
+ assert_true(d.filtered_records[0]['wodby.filter'])
30
+ assert_true(d.filtered_records[1]['wodby.filter'])
31
+ assert_true(d.filtered_records[2]['wodby.filter'])
26
32
  end
27
33
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-wodby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Wunderer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-05 00:00:00.000000000 Z
11
+ date: 2022-09-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -111,6 +111,7 @@ files:
111
111
  - ".gitignore"
112
112
  - Gemfile
113
113
  - LICENSE
114
+ - Makefile
114
115
  - README.md
115
116
  - Rakefile
116
117
  - fluent-plugin-wodby.gemspec