chef-handler-opsmatic 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +4 -0
- data/chef-handler-opsmatic.gemspec +3 -0
- data/lib/chef/handler/opsmatic.rb +2 -1
- data/lib/chef/handler/version.rb +1 -1
- data/spec/opsmatic_spec.rb +40 -0
- data/spec/spec_helper.rb +2 -0
- metadata +49 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a346c71f3073a21cf46a68cc83c834881b91e0a
|
4
|
+
data.tar.gz: 7f4f1c993f5cad976559bd7e2a0c8300a2f182dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d82e7b6a29eb1e2dc5fa8a1d3a1cc26e9682851f9c97bcee5be33b5133c8b977640e914d43edbe0f67373a862ad3b09f1427f83af71b40f39f4b3129c9b9cf7
|
7
|
+
data.tar.gz: 12c8831fbaee87a7e196c1c8f35478f8723092e8fd4e1189b206837ca6ec346a552190c86294f8dff4e5de0585b9b1f4db75bdcc413828854c0ad9f278d3e371
|
data/Rakefile
CHANGED
@@ -20,4 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.6"
|
22
22
|
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "rspec"
|
24
|
+
spec.add_development_dependency "chef"
|
25
|
+
spec.add_development_dependency "webmock"
|
23
26
|
end
|
@@ -56,7 +56,8 @@ class Chef
|
|
56
56
|
|
57
57
|
# if there's an exception include details in event
|
58
58
|
if !run_status.exception.nil?
|
59
|
-
|
59
|
+
clean_exception = run_status.formatted_exception.encode('UTF-8', {:invalid => :replace, :undef => :replace, :replace => '?'})
|
60
|
+
opsmatic_event[:data][:exception] = clean_exception
|
60
61
|
end
|
61
62
|
|
62
63
|
submit opsmatic_event
|
data/lib/chef/handler/version.rb
CHANGED
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'pp'
|
4
|
+
|
5
|
+
describe "Chef::Handler::Opsmatic" do
|
6
|
+
before(:all) do
|
7
|
+
COLLECTOR_URL = "http://api.opsmatic.com/webhooks/events"
|
8
|
+
INTEGRATION_TOKEN = "xxxxx-yyyyy"
|
9
|
+
HOSTNAME = "foo.example.com"
|
10
|
+
|
11
|
+
@handler = Chef::Handler::Opsmatic.new(
|
12
|
+
:integration_token => INTEGRATION_TOKEN,
|
13
|
+
:collector_url => COLLECTOR_URL
|
14
|
+
)
|
15
|
+
|
16
|
+
@node = Chef::Node.build(HOSTNAME)
|
17
|
+
@node.attributes.default[:fqdn] = HOSTNAME
|
18
|
+
end
|
19
|
+
|
20
|
+
before (:each) do
|
21
|
+
@events = Chef::EventDispatch::Dispatcher.new
|
22
|
+
@run_context = Chef::RunContext.new(@node, {}, @events)
|
23
|
+
@run_status = Chef::RunStatus.new(@node, @events)
|
24
|
+
@run_status.start_clock
|
25
|
+
@run_status.stop_clock
|
26
|
+
@run_status.run_context = @run_context
|
27
|
+
stub_request(:post, /#{COLLECTOR_URL}/).to_return(status: 202)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should successfully post an event" do
|
31
|
+
@handler.run_report_unsafe(@run_status)
|
32
|
+
expect a_request(:post, COLLECTOR_URL)
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should not fail if exception is encoded ASCII-8BIT" do
|
36
|
+
@run_status.exception = Exception.new("Exception with a binary char \xA9".force_encoding("ASCII-8BIT"))
|
37
|
+
@handler.run_report_unsafe(@run_status)
|
38
|
+
expect a_request(:post, COLLECTOR_URL)
|
39
|
+
end
|
40
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chef-handler-opsmatic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marcus Barczak
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -38,6 +38,48 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: chef
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: webmock
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
41
83
|
description: Chef report handler for sending run detail information to Opsmatic
|
42
84
|
email:
|
43
85
|
- support@opsmatic.com
|
@@ -53,6 +95,8 @@ files:
|
|
53
95
|
- chef-handler-opsmatic.gemspec
|
54
96
|
- lib/chef/handler/opsmatic.rb
|
55
97
|
- lib/chef/handler/version.rb
|
98
|
+
- spec/opsmatic_spec.rb
|
99
|
+
- spec/spec_helper.rb
|
56
100
|
homepage: https://github.com/opsmatic/chef-handler-opsmatic
|
57
101
|
licenses:
|
58
102
|
- MIT
|
@@ -77,4 +121,6 @@ rubygems_version: 2.2.0
|
|
77
121
|
signing_key:
|
78
122
|
specification_version: 4
|
79
123
|
summary: Chef report handler for sending run detail information to Opsmatic
|
80
|
-
test_files:
|
124
|
+
test_files:
|
125
|
+
- spec/opsmatic_spec.rb
|
126
|
+
- spec/spec_helper.rb
|