fluent-plugin-wodby 0.1.2 → 0.1.3

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: 38201e01bc10ab5a8e3852d23fe3969058de5cf0d2050157b9206b2466f2bcf1
4
+ data.tar.gz: a76ea598966087567dd0cd60dd9532574d42fe68c377c79d336c045152c04059
5
5
  SHA512:
6
- metadata.gz: 7bf8ba304a99a79dc966bd3a27a3ad54dc48f2a9d5d5530dbb0066a44dda7738d7f4d0d368c424fffc08b8cdf9ae64018273d9eccf5d8c970d8829d0fd50e3a1
7
- data.tar.gz: ac46fdb14afaf0912004803d8cf35d69f31283e797231e701db104017b70e5d8805df011fc296ad703198a1beb3af56dde3b258f89c5dc3a136367dda9c9a8b4
6
+ metadata.gz: ab83b527ab0249bccf037e72929b56555061267e80f04146352f76ff71e2e97e2011ef99923f864772a71f06df516ab16a2396d4a07bc47fda4bc19754287965
7
+ data.tar.gz: e0380bfa99a2a4650d064217f1399c9b68d1f47359b162df0ae1b9fd0fb60013be754024b898507a224a8222802396e6c10a66dc5880dfbce6636614a6fd2fd6
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.3"
7
7
  spec.authors = ["Robert Wunderer"]
8
8
  spec.email = ["robert@ramsalt.com"]
9
9
 
@@ -24,12 +24,25 @@ 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
+ end
32
+
27
33
  def filter(tag, time, record)
34
+ record['wodby.filter'] = true
35
+
28
36
  if record.has_key?('kubernetes.namespace_name')
29
- instance = get_instance(record['kubernetes.namespace_name'])
30
- app = get_app(instance['app_id'])
37
+ unless @instance_map.has_key?(record['kubernetes.namespace_name'])
38
+ record['wodby.instance_query'] = record['kubernetes.namespace_name']
39
+ instance = get_instance(record['kubernetes.namespace_name'])
40
+ app = get_app(instance['app_id'])
41
+
42
+ @instance_map[record['kubernetes.namespace_name']] = "#{app['title']}-#{instance['name']}"
43
+ end
31
44
 
32
- record['wodby.instance'] = "#{app['title']}-#{instance['name']}"
45
+ record['wodby.instance'] = @instance_map[record['kubernetes.namespace_name']]
33
46
  end
34
47
 
35
48
  record
@@ -44,7 +57,7 @@ module Fluent
44
57
  headers={'X-API-KEY': @api_key}
45
58
  )
46
59
  instance = JSON.parse(response)
47
- rescue RestClient::ExceptionWithResponse => e
60
+ rescue RestClient::ExceptionWithResponse
48
61
  instance = {}
49
62
  end
50
63
 
@@ -58,7 +71,7 @@ module Fluent
58
71
  headers={'X-API-KEY': @api_key}
59
72
  )
60
73
  app = JSON.parse(response)
61
- rescue RestClient::ExceptionWithResponse => e
74
+ rescue RestClient::ExceptionWithResponse
62
75
  app = {}
63
76
  end
64
77
 
@@ -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.3
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