fluent-plugin-wodby 0.3.0 → 0.4.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
2
  SHA256:
3
- metadata.gz: 469eb72bb742f469ad5971d49d596713edbb271956a732c4621098cea1865a96
4
- data.tar.gz: 1bbea99af50452655e065d8e6ef752ba4a682e5198b675aa1abeaeba01455b91
3
+ metadata.gz: e2c0a42ae8e68d022cea68274dec675e8e22b181e1b1ab0a257ece331166eca0
4
+ data.tar.gz: 4b740c774e644e04201abab355f79312a9f5a25652c6026c7fe55547c65e50d1
5
5
  SHA512:
6
- metadata.gz: 6659e889809b6f8d613c782425adf2974917a0ffb3915e701975693bf6cb89cfe719ab2b386ce06f778dc203cc82e5c0b5169feb30ce154081d976ef3d41e69a
7
- data.tar.gz: f5ac87623a93140f2486527f93510f83414f1260775b599292e5928fa43a455e54cacde609bf9fceb67e77305b96078efd1ea2e984c8739e00e08116949d3151
6
+ metadata.gz: e36b6cde7a8ca346a9e2343ceeeb32a0b6b1ceb028e9b2481c797d17352fe3eeb6336bd96e94649a27fb1410210c8f07e3d3be10f2217af50a9450bc32142970
7
+ data.tar.gz: c17560e1f313d485a5dd79048dc4deeea97aa6f1045d0ad8b0715c5972ed84ab41ecf4b8985841983f75a22410680a47fe469099aa85226e085e4f4928805805
@@ -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.3.0"
6
+ spec.version = "0.4.0"
7
7
  spec.authors = ["Robert Wunderer"]
8
8
  spec.email = ["robert@ramsalt.com"]
9
9
 
@@ -36,28 +36,38 @@ module Fluent
36
36
  'filter' => true
37
37
  }
38
38
 
39
+ if record.has_key?('wodby.node_name')
40
+ record['wodby']['node_name'] = record['wodby.node_name']
41
+ record.delete('wodby.node_name')
42
+ end
43
+
39
44
  if record.has_key?('kubernetes') && record['kubernetes'].has_key?('namespace_name')
40
45
  namespace = record['kubernetes']['namespace_name']
41
46
  unless @instance_map.has_key?(namespace)
42
47
  record['wodby']['instance_query'] = namespace
43
48
  instance = get_instance(namespace)
44
- app = get_app(instance['app_id'])
45
- org = get_org(app['org_id'])
46
-
47
- @instance_map[namespace] = {
48
- 'name' => "#{app['name']}.#{instance['name']}",
49
- 'title' => "#{app['title']} - #{instance['title']}",
50
- 'type' => instance['type'],
51
- 'organization' => org['name'],
52
- 'organization_title' => org['title'],
53
- }
49
+
50
+ if instance.empty?
51
+ @instance_map[namespace] = {
52
+ 'found' => false
53
+ }
54
+
55
+ else
56
+ app = get_app(instance['app_id'])
57
+ org = get_org(app['org_id'])
58
+
59
+ @instance_map[namespace] = {
60
+ 'found' => true,
61
+ 'instance' => "#{app['name']}.#{instance['name']}",
62
+ 'instance_title' => "#{app['title']} - #{instance['title']}",
63
+ 'instance_type' => instance['type'],
64
+ 'organization' => org['name'],
65
+ 'organization_title' => org['title'],
66
+ }
67
+ end
54
68
  end
55
69
 
56
- record['wodby']['instance'] = @instance_map[namespace]['name']
57
- record['wodby']['instance_title'] = @instance_map[namespace]['title']
58
- record['wodby']['instance_type'] = @instance_map[namespace]['type']
59
- record['wodby']['organization'] = @instance_map[namespace]['organization']
60
- record['wodby']['organization_title'] = @instance_map[namespace]['organization_title']
70
+ record['wodby'].merge!(@instance_map[namespace])
61
71
  else
62
72
  log.info "No namespace found"
63
73
  log.info record
@@ -16,18 +16,31 @@ class WodbyFilterTest < Test::Unit::TestCase
16
16
  d = create_driver("api_key #{ENV['WODBY_API_KEY']}")
17
17
  time = event_time
18
18
  d.run do
19
- d.feed('filter.test', time, { 'kubernetes' => {'namespace_name' => '650241f4-7303-4668-91c7-b8cd1821d81a'}, 'message' => 'hullo' })
20
- d.feed('filter.test', time, { 'kubernetes' => {'namespace_name' => '7ee5d15f-7c3c-4ce8-873e-34b75154f0f4'}, 'message' => 'hullo' })
21
- d.feed('filter.test', time, { 'kubernetes' => {'namespace_name' => '650241f4-7303-4668-91c7-b8cd1821d81a'}, 'message' => 'hullo' })
19
+ d.feed('filter.test', time, { 'kubernetes' => {'namespace_name' => '650241f4-7303-4668-91c7-b8cd1821d81a'}, 'message' => 'hullo', 'wodby.node_name' => 'node' })
20
+ d.feed('filter.test', time, { 'kubernetes' => {'namespace_name' => '7ee5d15f-7c3c-4ce8-873e-34b75154f0f4'}, 'message' => 'hullo', 'wodby.node_name' => 'node' })
21
+ d.feed('filter.test', time, { 'kubernetes' => {'namespace_name' => '650241f4-7303-4668-91c7-b8cd1821d81a'}, 'message' => 'hullo', 'wodby.node_name' => 'node' })
22
+ d.feed('filter.test', time, { 'kubernetes' => {'namespace_name' => 'renovate'}, 'message' => 'hullo', 'wodby.node_name' => 'node' })
22
23
  end
23
24
 
24
- assert_equal(3, d.filtered_records.size)
25
+ assert_equal(4, d.filtered_records.size)
26
+ assert_true(d.filtered_records[0]['wodby']['found'])
27
+ assert_true(d.filtered_records[1]['wodby']['found'])
28
+ assert_true(d.filtered_records[2]['wodby']['found'])
29
+ assert_false(d.filtered_records[3]['wodby']['found'])
30
+
25
31
  assert_equal('dfono.staging', d.filtered_records[0]['wodby']['instance'])
26
32
  assert_equal('dfono.prod', d.filtered_records[1]['wodby']['instance'])
27
33
  assert_equal('dfono.staging', d.filtered_records[2]['wodby']['instance'])
28
34
  assert_equal('dfo.no - Staging', d.filtered_records[0]['wodby']['instance_title'])
29
35
  assert_equal('dfo.no - Prod', d.filtered_records[1]['wodby']['instance_title'])
36
+ assert_equal('node', d.filtered_records[0]['wodby']['node_name'])
37
+ assert_equal('node', d.filtered_records[1]['wodby']['node_name'])
38
+ assert_equal('dfo', d.filtered_records[0]['wodby']['organization'])
39
+ assert_equal('DFØ', d.filtered_records[1]['wodby']['organization_title'])
40
+
30
41
  assert_nil(d.filtered_records[2]['wodby']['instance_query'])
42
+ assert_nil(d.filtered_records[2]['wodby.node_name'])
43
+
31
44
  assert_true(d.filtered_records[0]['wodby']['filter'])
32
45
  assert_true(d.filtered_records[1]['wodby']['filter'])
33
46
  assert_true(d.filtered_records[2]['wodby']['filter'])
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-wodby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Wunderer