maestro_plugin 0.0.7 → 0.0.11
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.
- data/.gitignore +2 -0
- data/.ruby-version +1 -0
- data/lib/maestro_plugin/maestro_worker.rb +31 -6
- data/lib/maestro_plugin/version.rb +1 -1
- data/spec/maestro_worker_spec.rb +44 -0
- metadata +132 -146
- checksums.yaml +0 -7
- data/.rvmrc +0 -1
- data/Gemfile.lock +0 -43
data/.gitignore
CHANGED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
jruby-1.6.8
|
@@ -1,7 +1,21 @@
|
|
1
1
|
require 'json'
|
2
2
|
|
3
|
-
module
|
3
|
+
module MaestroDev
|
4
|
+
module Plugin
|
5
|
+
# General plugin problem. A plugin can raise errors of this type and have the 'message' portion of the error
|
6
|
+
# automatically logged, and have the plugin-response set to the same (message) and have the execution end
|
7
|
+
class PluginError < StandardError
|
8
|
+
end
|
4
9
|
|
10
|
+
# Configuration error detected - usually as a result of the validation method determining bad/invalid data.
|
11
|
+
# This is treated same as PluginError for now... but maybe one day it'll get wings and fly, so only raise
|
12
|
+
# this error if the plugin cannot execute the task owing to poor parameters.
|
13
|
+
class ConfigError < PluginError
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
module Maestro
|
5
19
|
|
6
20
|
# Helper Class for Maestro Plugins written in Ruby. The lifecycle of the plugin
|
7
21
|
# starts with a call to the main entry point perform called by the Maestro agent, all the
|
@@ -9,7 +23,6 @@ module Maestro
|
|
9
23
|
# run_callbacks which can be customized by specifying an on_complete_handler_method, or on_complete_handler_block.
|
10
24
|
#
|
11
25
|
class MaestroWorker
|
12
|
-
|
13
26
|
# Workitem constants
|
14
27
|
CONTEXT_OUTPUTS_META = '__context_outputs__'
|
15
28
|
OUTPUT_META = '__output__'
|
@@ -87,17 +100,29 @@ module Maestro
|
|
87
100
|
def perform(action, workitem)
|
88
101
|
@action, @workitem = action, workitem
|
89
102
|
send(action)
|
103
|
+
write_output('') # Triggers any remaining buffered output to be sent
|
90
104
|
run_callbacks
|
91
|
-
rescue => e
|
105
|
+
rescue MaestroDev::Plugin::PluginError => e
|
106
|
+
# Ensure error is written to output file
|
107
|
+
write_output(e.message)
|
108
|
+
set_error(e.message)
|
109
|
+
rescue Exception => e
|
110
|
+
msg = "Unexpected error executing task: #{e.class} #{e}"
|
111
|
+
write_output(msg)
|
112
|
+
Maestro.log.warn("#{msg} " + e.backtrace.join("\n"))
|
113
|
+
|
114
|
+
# Let user-supplied exception handler do its thing
|
92
115
|
handle_exception(e)
|
116
|
+
set_error(msg)
|
117
|
+
ensure
|
118
|
+
return @workitem
|
93
119
|
end
|
94
120
|
|
121
|
+
# Fire supplied exception handlers if supplied, otherwise do nothing
|
95
122
|
def handle_exception(e)
|
96
|
-
raise e if self.class.exception_handler_method.nil? && self.class.exception_handler_block.nil?
|
97
|
-
|
98
123
|
if self.class.exception_handler_method
|
99
124
|
send(self.class.exception_handler_method, e)
|
100
|
-
|
125
|
+
elsif self.class.exception_handler_block
|
101
126
|
self.class.exception_handler_block.call(e, self)
|
102
127
|
end
|
103
128
|
end
|
data/spec/maestro_worker_spec.rb
CHANGED
@@ -165,4 +165,48 @@ describe Maestro::MaestroWorker do
|
|
165
165
|
end
|
166
166
|
|
167
167
|
end
|
168
|
+
|
169
|
+
describe 'Errors' do
|
170
|
+
class ErrorTestWorker < Maestro::MaestroWorker
|
171
|
+
def configerror_test
|
172
|
+
raise MaestroDev::Plugin::ConfigError, 'Bad Config - what are you feeding me?'
|
173
|
+
end
|
174
|
+
|
175
|
+
def pluginerror_test
|
176
|
+
raise MaestroDev::Plugin::PluginError, 'PluginError - I had a problem'
|
177
|
+
end
|
178
|
+
|
179
|
+
def error_test
|
180
|
+
raise Exception, 'noooo'
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
before :each do
|
185
|
+
@worker = ErrorTestWorker.new
|
186
|
+
end
|
187
|
+
|
188
|
+
it 'should handle a ConfigError for bad config' do
|
189
|
+
workitem = {'fields' => {}}
|
190
|
+
|
191
|
+
@worker.perform(:configerror_test, workitem)
|
192
|
+
workitem['fields']['__error__'].should include('Bad Config')
|
193
|
+
workitem['__output__'].should include('Bad Config')
|
194
|
+
end
|
195
|
+
|
196
|
+
it 'should handle a PluginError' do
|
197
|
+
workitem = {'fields' => {}}
|
198
|
+
|
199
|
+
@worker.perform(:pluginerror_test, workitem)
|
200
|
+
workitem['fields']['__error__'].should include('PluginError - I had a problem')
|
201
|
+
workitem['__output__'].should include('PluginError - I had a problem')
|
202
|
+
end
|
203
|
+
|
204
|
+
it 'should handle an unexpected Error' do
|
205
|
+
workitem = {'fields' => {}}
|
206
|
+
|
207
|
+
@worker.perform(:error_test, workitem)
|
208
|
+
workitem['fields']['__error__'].should include('Unexpected error executing task: Exception noooo')
|
209
|
+
workitem['__output__'].should include('Unexpected error executing task: Exception noooo')
|
210
|
+
end
|
211
|
+
end
|
168
212
|
end
|
metadata
CHANGED
@@ -1,158 +1,144 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: maestro_plugin
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.11
|
5
6
|
platform: ruby
|
6
|
-
authors:
|
7
|
-
- Etienne Pelletier
|
8
|
-
autorequire:
|
7
|
+
authors:
|
8
|
+
- Etienne Pelletier
|
9
|
+
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
requirements:
|
92
|
-
- - '>='
|
93
|
-
- !ruby/object:Gem::Version
|
94
|
-
version: '0'
|
95
|
-
prerelease: false
|
96
|
-
type: :development
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: rspec
|
99
|
-
version_requirements: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - ~>
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: 2.13.0
|
104
|
-
requirement: !ruby/object:Gem::Requirement
|
105
|
-
requirements:
|
106
|
-
- - ~>
|
107
|
-
- !ruby/object:Gem::Version
|
108
|
-
version: 2.13.0
|
109
|
-
prerelease: false
|
110
|
-
type: :development
|
12
|
+
|
13
|
+
date: 2013-07-26 00:00:00 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: logging
|
17
|
+
prerelease: false
|
18
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
20
|
+
requirements:
|
21
|
+
- - "="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.8.0
|
24
|
+
type: :runtime
|
25
|
+
version_requirements: *id001
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: rubyzip
|
28
|
+
prerelease: false
|
29
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
30
|
+
none: false
|
31
|
+
requirements:
|
32
|
+
- - "="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 0.9.8
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id002
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: json
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 1.4.6
|
46
|
+
type: :runtime
|
47
|
+
version_requirements: *id003
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: bundler
|
50
|
+
prerelease: false
|
51
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ~>
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: "1.3"
|
57
|
+
type: :development
|
58
|
+
version_requirements: *id004
|
59
|
+
- !ruby/object:Gem::Dependency
|
60
|
+
name: rake
|
61
|
+
prerelease: false
|
62
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: "0"
|
68
|
+
type: :development
|
69
|
+
version_requirements: *id005
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: jruby-openssl
|
72
|
+
prerelease: false
|
73
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: "0"
|
79
|
+
type: :development
|
80
|
+
version_requirements: *id006
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
name: rspec
|
83
|
+
prerelease: false
|
84
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
85
|
+
none: false
|
86
|
+
requirements:
|
87
|
+
- - ~>
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 2.13.0
|
90
|
+
type: :development
|
91
|
+
version_requirements: *id007
|
111
92
|
description: A ruby library to help with the creation of Maestro plugins
|
112
|
-
email:
|
113
|
-
- epelletier@maestrodev.com
|
93
|
+
email:
|
94
|
+
- epelletier@maestrodev.com
|
114
95
|
executables: []
|
96
|
+
|
115
97
|
extensions: []
|
98
|
+
|
116
99
|
extra_rdoc_files: []
|
117
|
-
|
118
|
-
|
119
|
-
- .
|
120
|
-
-
|
121
|
-
- Gemfile
|
122
|
-
- LICENSE.txt
|
123
|
-
- README.md
|
124
|
-
- Rakefile
|
125
|
-
- lib/maestro_plugin.rb
|
126
|
-
- lib/maestro_plugin/logging.rb
|
127
|
-
- lib/maestro_plugin/maestro_worker.rb
|
128
|
-
- lib/maestro_plugin/version.rb
|
129
|
-
- maestro_plugin.gemspec
|
130
|
-
- spec/maestro_worker_spec.rb
|
131
|
-
- spec/spec_helper.rb
|
100
|
+
|
101
|
+
files:
|
102
|
+
- .gitignore
|
103
|
+
- .ruby-version
|
104
|
+
- Gemfile
|
105
|
+
- LICENSE.txt
|
106
|
+
- README.md
|
107
|
+
- Rakefile
|
108
|
+
- lib/maestro_plugin.rb
|
109
|
+
- lib/maestro_plugin/logging.rb
|
110
|
+
- lib/maestro_plugin/maestro_worker.rb
|
111
|
+
- lib/maestro_plugin/version.rb
|
112
|
+
- maestro_plugin.gemspec
|
113
|
+
- spec/maestro_worker_spec.rb
|
114
|
+
- spec/spec_helper.rb
|
132
115
|
homepage: https://github.com/maestrodev/maestro-ruby-plugin
|
133
|
-
licenses:
|
134
|
-
- Apache 2.0
|
135
|
-
|
136
|
-
post_install_message:
|
116
|
+
licenses:
|
117
|
+
- Apache 2.0
|
118
|
+
post_install_message:
|
137
119
|
rdoc_options: []
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
120
|
+
|
121
|
+
require_paths:
|
122
|
+
- lib
|
123
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
124
|
+
none: false
|
125
|
+
requirements:
|
126
|
+
- - ">="
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: "0"
|
129
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
130
|
+
none: false
|
131
|
+
requirements:
|
132
|
+
- - ">="
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: "0"
|
150
135
|
requirements: []
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
136
|
+
|
137
|
+
rubyforge_project:
|
138
|
+
rubygems_version: 1.8.24
|
139
|
+
signing_key:
|
140
|
+
specification_version: 3
|
155
141
|
summary: Maestro ruby plugin
|
156
|
-
test_files:
|
157
|
-
- spec/maestro_worker_spec.rb
|
158
|
-
- spec/spec_helper.rb
|
142
|
+
test_files:
|
143
|
+
- spec/maestro_worker_spec.rb
|
144
|
+
- spec/spec_helper.rb
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: 0c64c1f3c1a915362afd09ce40a43df33640cd5b
|
4
|
-
data.tar.gz: 302738027d98269a9f9f63eefe215e8d535d663f
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: 1536a2ff8c81e70b12865d6deca13095d9b3af6eca2e2c9828ad72b5db7c9c537b2adc6fa8fde4111490fd7fc06275c8a64d1c371fd709ce33fb77bcb0bf9f21
|
7
|
-
data.tar.gz: 0c7685ec929c3e0fd798dc867f6bdb65a632881b49b4daf4e72dee45f4ad5e8f2e2b96105c7c703e91d5b148413106205852df90f4cab9cc72bd720e70e968c2
|
data/.rvmrc
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
rvm use jruby-1.6.8
|
data/Gemfile.lock
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
maestro_plugin (0.0.6)
|
5
|
-
json (>= 1.4.6)
|
6
|
-
logging (= 1.8.0)
|
7
|
-
rubyzip (= 0.9.8)
|
8
|
-
|
9
|
-
GEM
|
10
|
-
remote: https://rubygems.org/
|
11
|
-
specs:
|
12
|
-
bouncy-castle-java (1.5.0147)
|
13
|
-
diff-lcs (1.2.1)
|
14
|
-
jruby-openssl (0.8.7)
|
15
|
-
bouncy-castle-java (>= 1.5.0147)
|
16
|
-
json (1.8.0)
|
17
|
-
json (1.8.0-java)
|
18
|
-
little-plugger (1.1.3)
|
19
|
-
logging (1.8.0)
|
20
|
-
little-plugger (>= 1.1.3)
|
21
|
-
multi_json (>= 1.3.6)
|
22
|
-
multi_json (1.7.3)
|
23
|
-
rake (10.0.4)
|
24
|
-
rspec (2.13.0)
|
25
|
-
rspec-core (~> 2.13.0)
|
26
|
-
rspec-expectations (~> 2.13.0)
|
27
|
-
rspec-mocks (~> 2.13.0)
|
28
|
-
rspec-core (2.13.0)
|
29
|
-
rspec-expectations (2.13.0)
|
30
|
-
diff-lcs (>= 1.1.3, < 2.0)
|
31
|
-
rspec-mocks (2.13.0)
|
32
|
-
rubyzip (0.9.8)
|
33
|
-
|
34
|
-
PLATFORMS
|
35
|
-
java
|
36
|
-
ruby
|
37
|
-
|
38
|
-
DEPENDENCIES
|
39
|
-
bundler (~> 1.3)
|
40
|
-
jruby-openssl
|
41
|
-
maestro_plugin!
|
42
|
-
rake
|
43
|
-
rspec (~> 2.13.0)
|