fluent-plugin-redmine 0.5.3 → 0.6.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
  SHA1:
3
- metadata.gz: a91fd3eb7844c4d4b564c7b9e195ba64db4794d0
4
- data.tar.gz: 93e74847c269c3d683c840300cc31660b3609d45
3
+ metadata.gz: f193b8f6fea649e602c652324c244eb11d521eea
4
+ data.tar.gz: 4633aeb58a38806c7f3221a692184dfbcd2eb512
5
5
  SHA512:
6
- metadata.gz: 3764f98d7e9909c70524965113d5892952d9a08171f6ac46bfa92dd3aeeaf726fe5a0e5514bc9a73620855e262909e81de0d22b688702bdf4126a101e9f97663
7
- data.tar.gz: 5bc9748c211feb0acf4b474cea6e6961d638dfe0168bb4b437b4ddc8df4306ac32a3c6bb6a061c794f8e0261f007047397e9e7def3722e2dcb8df8c24f720e3a
6
+ metadata.gz: d0a01fcc9fb1e13e446432cef4edd0c601d5fa22a4feb625057bc868f95237ac5a7f09291815faaa3b56215748e817eab1872edf2cb4d955c408bc0546f47712
7
+ data.tar.gz: b8d76888ac8d943176ceb84b61147135869451983e06b54cfff84da9c9ba8b245b61bf6290d5bf3f0001d66bccfe2d437c3546b7eb6f239fb41b4c012e464da0
data/README.md CHANGED
@@ -38,12 +38,14 @@ Here is example settings:
38
38
 
39
39
  and here is optional configuration:
40
40
 
41
- project_id myproject # projectId of redmine
42
- category_id 70 # categoryId of tickets
43
- project_id_key key_of_priority_id # value in record for priorityId
44
- category_id_key key_of_category_id # value in record for categoryId
45
- tag_key my_ tag # 'tag' is used by default
46
- debug_http true # set debug_http=true of Net::HTTP module, false is used by default
41
+ project_id myproject # Redmine project id
42
+ category_id 70 # Redmine category id
43
+ project_id_key key_of_priority_id # key name if the record for priority id
44
+ category_id_key key_of_category_id # key name if the record for category id
45
+ tag_key my_ tag # 'tag' is used by default
46
+ custom_fields [{"id":1, "value" "value01"}] # Redmine custom fields, array of hash with id, value
47
+ custom_fields_key key_of_custom_fields # key name if the record for custom fields
48
+ debug_http true # set debug_http=true of Net::HTTP module, false is used by default
47
49
 
48
50
 
49
51
  ### placeholders
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "fluent-plugin-redmine"
7
- spec.version = "0.5.3"
7
+ spec.version = "0.6.0"
8
8
  spec.authors = ["Takuma kanari"]
9
9
  spec.email = ["chemtrails.t@gmail.com"]
10
10
  spec.summary = %q{Fluentd output plugin to create ticket in redmine}
@@ -9,40 +9,46 @@ module Fluent
9
9
  end
10
10
 
11
11
  desc "Redmine url"
12
- config_param :url, :string, :default => nil
12
+ config_param :url, :string, default: nil
13
13
 
14
14
  desc "Redmine api key"
15
- config_param :api_key, :string, :default => nil, :secret => true
15
+ config_param :api_key, :string, default: nil, secret: true
16
16
 
17
17
  desc "Key name in the record for tag"
18
- config_param :tag_key, :string, :default => "tag"
18
+ config_param :tag_key, :string, default: "tag"
19
19
 
20
20
  desc "Redmine project id"
21
- config_param :project_id, :string, :default => nil
21
+ config_param :project_id, :string, default: nil
22
22
 
23
23
  desc "Redmine category id"
24
- config_param :category_id, :integer, :default => nil
24
+ config_param :category_id, :integer, default: nil
25
25
 
26
26
  desc "Key name in the record for Redmine category id"
27
- config_param :category_id_key, :string, :default => nil
27
+ config_param :category_id_key, :string, default: nil
28
28
 
29
29
  desc "Redmine tracker id"
30
- config_param :tracker_id, :integer
30
+ config_param :tracker_id, :integer, default: nil
31
31
 
32
32
  desc "Redmine priority id"
33
- config_param :priority_id, :integer
33
+ config_param :priority_id, :integer, default: nil
34
34
 
35
35
  desc "Key name in the record for Redmine priority id"
36
- config_param :priority_id_key, :string, :default => nil
36
+ config_param :priority_id_key, :string, default: nil
37
37
 
38
38
  desc "Ticket title"
39
- config_param :subject, :string, :default => "Fluent::RedmineOutput plugin"
39
+ config_param :subject, :string, default: "Fluent::RedmineOutput plugin"
40
40
 
41
41
  desc "Ticket description"
42
- config_param :description, :string, :default => ""
42
+ config_param :description, :string, default: ""
43
43
 
44
44
  desc "If true, show debug message of http operations"
45
- config_param :debug_http, :bool, :default => false
45
+ config_param :debug_http, :bool, default: false
46
+
47
+ desc "Redmine custom fields, array of hash with id, value"
48
+ config_param :custom_fields, :array, default: []
49
+
50
+ desc "Key name in the record for Redmine custom fields"
51
+ config_param :custom_fields_key, :string, default: nil
46
52
 
47
53
  def initialize
48
54
  super
@@ -123,16 +129,17 @@ module Fluent
123
129
  def make_payload(subject, desc, record)
124
130
  priority_id = @priority_id_key.nil? ? @priority_id : (record[@priority_id_key] || @priority_id).to_i
125
131
  category_id = @category_id_key.nil? ? @category_id : (record[@category_id_key] || @category_id).to_i
126
- {
127
- :issue => {
128
- :project_id => @project_id,
129
- :tracker_id => @tracker_id,
130
- :priority_id => priority_id,
131
- :category_id => category_id,
132
- :subject => subject,
133
- :description => desc
134
- }
132
+ custom_fields = @custom_fields_key.nil? ? @custom_fields : (record[@custom_fields_key] || [])
133
+ issue = {
134
+ project_id: @project_id,
135
+ category_id: category_id,
136
+ subject: subject,
137
+ description: desc
135
138
  }
139
+ issue[:tracker_id] = @tracker_id unless @tracker_id.nil?
140
+ issue[:priority_id] = priority_id unless priority_id.nil?
141
+ issue[:custom_fields] = custom_fields unless custom_fields.empty?
142
+ { issue: issue }
136
143
  end
137
144
 
138
145
  private
@@ -21,6 +21,28 @@ class RedmineOutputTest < Test::Unit::TestCase
21
21
  description this is description %{d1} - %{d2} - %{d3}
22
22
  ]
23
23
 
24
+ CONFIG_WITHOUT_TRACKER_ID_AND_PRIORITY_ID = %[
25
+ type redmine
26
+ url http://localhost:4000
27
+ api_key test-api-key
28
+ tag_key test
29
+ project_id 1
30
+ category_id 4
31
+ subject awesome
32
+ description this is description %{d1} - %{d2} - %{d3}
33
+ ]
34
+
35
+ CONFIG_WITH_CUSTOM_FIELDS = %[
36
+ type redmine
37
+ url http://localhost:4000
38
+ api_key test-api-key
39
+ tag_key test
40
+ project_id 1
41
+ subject awesome
42
+ custom_fields [{"id" : 1, "value" : "awesome"}]
43
+ description this is description %{d1} - %{d2} - %{d3}
44
+ ]
45
+
24
46
  CONFIG_WITH_PROPERTY_ALIAS_KEYS = %[
25
47
  type redmine
26
48
  url http://localhost:4000
@@ -32,6 +54,7 @@ class RedmineOutputTest < Test::Unit::TestCase
32
54
  category_id 4
33
55
  priority_id_key key_of_priority_id
34
56
  category_id_key key_of_category_id
57
+ custom_fields_key key_of_custom_fields
35
58
  subject awesome
36
59
  description this is description %{d1} - %{d2} - %{d3}
37
60
  ]
@@ -149,6 +172,7 @@ class RedmineOutputTest < Test::Unit::TestCase
149
172
  assert_nothing_raised { p = create_driver(CONFIG_WITH_PROPERTY_ALIAS_KEYS).instance }
150
173
  assert_equal "key_of_priority_id", p.priority_id_key
151
174
  assert_equal "key_of_category_id", p.category_id_key
175
+ assert_equal "key_of_custom_fields", p.custom_fields_key
152
176
  end
153
177
 
154
178
  def test_configure_https
@@ -200,17 +224,49 @@ CONFIG
200
224
  assert_equal p.project_id, ret[:issue][:project_id]
201
225
  assert_equal p.tracker_id, ret[:issue][:tracker_id]
202
226
  assert_equal p.priority_id, ret[:issue][:priority_id]
227
+ assert_false ret[:issue].key?(:custom_fields)
228
+ end
229
+
230
+ def test_make_payload_with_custom_fields
231
+ p = create_driver(CONFIG_WITH_CUSTOM_FIELDS).instance
232
+ record = {
233
+ "name" => "John",
234
+ "age" => 25,
235
+ "message" => "this is message!"
236
+ }
237
+ ret = p.make_payload("subject", "description", record)
238
+ assert_equal 1, ret[:issue][:custom_fields].size
239
+ assert_equal 1, ret[:issue][:custom_fields].first["id"]
240
+ assert_equal "awesome", ret[:issue][:custom_fields].first["value"]
241
+ end
242
+
243
+ def test_make_payload_without_tracker_id_and_priority_id
244
+ p = create_driver(CONFIG_WITHOUT_TRACKER_ID_AND_PRIORITY_ID).instance
245
+ record = {
246
+ "name" => "John",
247
+ "age" => 25,
248
+ "message" => "this is message!"
249
+ }
250
+ ret = p.make_payload("subject", "description", record)
251
+ assert_equal "subject", ret[:issue][:subject]
252
+ assert_equal "description", ret[:issue][:description]
253
+ assert_false ret[:issue].key?(:priority_id)
254
+ assert_false ret[:issue].key?(:tracker_id)
255
+ assert_equal p.priority_id, ret[:issue][:priority_id]
203
256
  end
204
257
 
205
258
  def test_make_payload_with_alias_keys
206
259
  p = create_driver(CONFIG_WITH_PROPERTY_ALIAS_KEYS).instance
260
+ custom_fields = [{"id" => 1, "value" => "awesome"}]
207
261
  record = {
208
262
  "key_of_priority_id" => "123",
209
- "key_of_category_id" => "456"
263
+ "key_of_category_id" => "456",
264
+ "key_of_custom_fields" => custom_fields
210
265
  }
211
266
  ret = p.make_payload("subject", "description", record)
212
267
  assert_equal 123, ret[:issue][:priority_id]
213
268
  assert_equal 456, ret[:issue][:category_id]
269
+ assert_equal custom_fields, ret[:issue][:custom_fields]
214
270
  end
215
271
 
216
272
  def test_make_payload_with_alias_keys_use_default_ids
@@ -218,6 +274,7 @@ CONFIG
218
274
  ret = p.make_payload("subject", "description", {})
219
275
  assert_equal 3, ret[:issue][:priority_id]
220
276
  assert_equal 4, ret[:issue][:category_id]
277
+ assert_false ret[:issue].key?(:custom_fields)
221
278
  end
222
279
 
223
280
  def test_emit
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-redmine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takuma kanari
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-16 00:00:00.000000000 Z
11
+ date: 2017-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd