foreman_hooks 0.3.0 → 0.3.1
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/foreman_hooks.gemspec +2 -2
- data/lib/foreman_hooks/util.rb +14 -7
- metadata +2 -2
data/foreman_hooks.gemspec
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "foreman_hooks"
|
3
3
|
|
4
|
-
s.version = "0.3.
|
5
|
-
s.date = "2013-04-
|
4
|
+
s.version = "0.3.1"
|
5
|
+
s.date = "2013-04-07"
|
6
6
|
|
7
7
|
s.summary = "Run custom hook scripts on Foreman events"
|
8
8
|
s.description = "Plugin engine for Foreman that enables running custom hook scripts on Foreman events"
|
data/lib/foreman_hooks/util.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'open3'
|
2
|
+
|
1
3
|
module ForemanHooks::Util
|
2
4
|
extend ActiveSupport::Concern
|
3
5
|
|
@@ -35,7 +37,7 @@ module ForemanHooks::Util
|
|
35
37
|
@hooks = discover_hooks
|
36
38
|
@hooks.each do |klass,events|
|
37
39
|
events.each do |event,hooks|
|
38
|
-
logger.info "Finished registering #{hooks.size} hooks for #{
|
40
|
+
logger.info "Finished registering #{hooks.size} hooks for #{klass.to_s}##{event}"
|
39
41
|
hooks.sort!
|
40
42
|
end
|
41
43
|
end
|
@@ -75,13 +77,18 @@ module ForemanHooks::Util
|
|
75
77
|
end
|
76
78
|
|
77
79
|
def exec_hook_int(stdin_data, *args)
|
78
|
-
output =
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
80
|
+
output, status = if Open3.respond_to? :capture2e
|
81
|
+
Open3.capture2e(*args.push(:stdin_data => stdin_data))
|
82
|
+
else # 1.8
|
83
|
+
Open3.popen3(*args) do |stdin,stdout,stderr|
|
84
|
+
stdin.write(stdin_data)
|
85
|
+
stdin.close
|
86
|
+
# we could still deadlock here, it'd ideally select() on stdout+err
|
87
|
+
output = stderr.read
|
88
|
+
end
|
89
|
+
[output, $?]
|
83
90
|
end
|
84
91
|
logger.debug "Hook output: #{output}" if output && !output.empty?
|
85
|
-
|
92
|
+
status
|
86
93
|
end
|
87
94
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_hooks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-04-
|
12
|
+
date: 2013-04-07 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Plugin engine for Foreman that enables running custom hook scripts on
|
15
15
|
Foreman events
|