fluent-plugin-redmine 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a74312227f9285179b5f863968c01f87b2a838f3
4
- data.tar.gz: 8ebda1d917fe773ad253643a1cbe10a5dc8cf269
3
+ metadata.gz: ab2b9808cafcff72fde0c9e8da5c63b106899d0f
4
+ data.tar.gz: 94cd0c051678b318bd3b59d6c0ad780225ccb764
5
5
  SHA512:
6
- metadata.gz: 9399d0e446fbb7a11e3ec429230a7e02a946fae7334658e66567c45855b2d87a8edc37a2a3c7a9852b0238be87ca15358c1c7585617645c89509bd8e55174484
7
- data.tar.gz: 9e51506a72aa1ff0b2cbc6505abf30d414a32c6e15e2cbb693c57701245e4a0f482689ad75bf5b5a6a7c53673658ea39eb5cd6fe51943a0a789cc2c219f67cf7
6
+ metadata.gz: d1bbf40145d29bf47301cf175eb3ef12640d2d0a61ad4f518b902c9171feaf0c6b77d8bd7e57223ab20293861a75ebd2e627463a56c1249d7a18d33349f34680
7
+ data.tar.gz: d0a28f06a4a8651269173f3a50980631047bd1bdaeadcd341f8c1e0796c93f4676c8eead31e186fafa47aec2465130058e705838ccc209486f95d8aca345c58a
data/README.md CHANGED
@@ -28,7 +28,6 @@ Here is example settings:
28
28
  type redmine
29
29
  url http://localhost:3000/
30
30
  api_key 40a96d43a98b1626c542b04c5780f881c1e1a969
31
- project_id apitest
32
31
  tracker_id 1
33
32
  priority_id 3
34
33
  subject The new issue %{issue}
@@ -37,7 +36,9 @@ Here is example settings:
37
36
 
38
37
  and here is optional configuration:
39
38
 
40
- tag_key my_tag # 'tag' is used by default
39
+ project_id myproject # projectId of redmine
40
+ tag_key my_tag # 'tag' is used by default
41
+ debug_http true # set debug_http=true of Net::HTTP module, false is used by default
41
42
 
42
43
  ### placeholders
43
44
 
@@ -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.1.0"
7
+ spec.version = "0.2.0"
8
8
  spec.authors = ["Takuma kanari"]
9
9
  spec.email = ["chemtrails.t@gmail.com"]
10
10
  spec.summary = %q{Output filter plugin to create ticket in redmine}
@@ -16,13 +16,13 @@ module Fluent
16
16
  config_param :priority_id, :integer
17
17
  config_param :subject, :string, :default => "Fluent::RedmineOutput plugin"
18
18
  config_param :description, :string, :default => ""
19
+ config_param :debug_http, :bool, :default => false
19
20
 
20
21
  def initialize
21
22
  super
22
23
  require "json"
23
- require "net/http"
24
24
  end
25
-
25
+
26
26
  def configure(conf)
27
27
  super
28
28
 
@@ -34,6 +34,14 @@ module Fluent
34
34
  raise Fluent::ConfigError, "'api_key' must be specified."
35
35
  end
36
36
 
37
+ @use_ssl = (@url =~ /^https:/) ? true : false
38
+
39
+ if @use_ssl
40
+ require "net/https"
41
+ else
42
+ require "net/http"
43
+ end
44
+
37
45
  @subject_expander = TemplateExpander.new(@subject)
38
46
  @description_expander = TemplateExpander.new(@description)
39
47
  @redmine_uri = URI.parse("#{@url}/issues.json")
@@ -68,7 +76,17 @@ module Fluent
68
76
  initheader = @redmine_request_header
69
77
  )
70
78
  request.body = JSON.generate(make_payload(subject, desc))
71
- Net::HTTP.new(@redmine_uri.host, @redmine_uri.port).start do |http|
79
+
80
+ client = Net::HTTP.new(@redmine_uri.host, @redmine_uri.port)
81
+ if @use_ssl
82
+ client.use_ssl = true
83
+ client.verify_mode = OpenSSL::SSL::VERIFY_NONE # TODO support other verify mode
84
+ end
85
+ if @debug_http
86
+ client.set_debug_output($stderr)
87
+ end
88
+
89
+ client.start do |http|
72
90
  res = http.request(request)
73
91
  unless res.code.to_i == 201
74
92
  raise Exception.new("Error: #{res.code}, #{res.body}")
@@ -20,6 +20,18 @@ class RedmineOutputTest < Test::Unit::TestCase
20
20
  description this is description %{d1} - %{d2} - %{d3}
21
21
  ]
22
22
 
23
+ CONFIG_HTTPS = %[
24
+ type redmine
25
+ url https://localhost:4000
26
+ api_key test-api-key
27
+ tag_key test
28
+ project_id 1
29
+ tracker_id 2
30
+ priority_id 3
31
+ subject awesome
32
+ description this is description %{d1} - %{d2} - %{d3}
33
+ ]
34
+
23
35
  CONFIG_TO_FORMAT = %[
24
36
  type redmine
25
37
  url http://localhost:4000
@@ -101,7 +113,7 @@ class RedmineOutputTest < Test::Unit::TestCase
101
113
  Fluent::Test::OutputTestDriver.new(Fluent::RedmineOutput, tag).configure(conf)
102
114
  end
103
115
 
104
- def test_configure
116
+ def test_configure_http
105
117
  p = nil
106
118
  assert_nothing_raised { p = create_driver(CONFIG_DEFAULT).instance }
107
119
  assert_equal "http://localhost:4000", p.url
@@ -113,6 +125,18 @@ class RedmineOutputTest < Test::Unit::TestCase
113
125
  assert_equal "this is description %{d1} - %{d2} - %{d3}", p.description
114
126
  end
115
127
 
128
+ def test_configure_https
129
+ p = nil
130
+ assert_nothing_raised { p = create_driver(CONFIG_HTTPS).instance }
131
+ assert_equal "https://localhost:4000", p.url
132
+ assert_equal "test", p.tag_key
133
+ assert_equal "1", p.project_id
134
+ assert_equal 2, p.tracker_id
135
+ assert_equal 3, p.priority_id
136
+ assert_equal "awesome", p.subject
137
+ assert_equal "this is description %{d1} - %{d2} - %{d3}", p.description
138
+ end
139
+
116
140
  def test_configure_fail_by_url
117
141
  assert_raise(Fluent::ConfigError){ create_driver(<<CONFIG) }
118
142
  type redmine
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.1.0
4
+ version: 0.2.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: 2014-12-08 00:00:00.000000000 Z
11
+ date: 2015-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake