foreman_hooks 0.3.4 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/foreman_hooks/util.rb +22 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4aa78594bdb6c2cc863097039b920bafe1b21b0e
|
4
|
+
data.tar.gz: 25fad3c59ce04be593118ac643f326c1daafe9c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1fa4d89f00745e4cc5863988f5c9da6df9ed5a424abc549acfd0d5d6513b4f5a12646bd00cd2b735b20599289503a671130c0f2583c99224f050683e5cb7ed7a
|
7
|
+
data.tar.gz: f0ca3b8c45b66224bfa21e5e893d8a381a9cca95cbac135d1403fe420f3894b63c6313706522b70134511169126f1c3e2d83a125657c57d081b7ff0715c03be7
|
data/lib/foreman_hooks/util.rb
CHANGED
@@ -3,12 +3,32 @@ require 'open3'
|
|
3
3
|
module ForemanHooks::Util
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
|
6
|
+
def render_hook_type
|
7
|
+
case self
|
8
|
+
when Host::Managed
|
9
|
+
'host'
|
10
|
+
else
|
11
|
+
self.class.name.to_lower
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def render_hook_json
|
16
|
+
# APIv2 has some pretty good templates. We could extend them later in special cases.
|
17
|
+
# Wrap them in a root node for pre-1.4 compatibility
|
18
|
+
json = Rabl.render(self, "api/v2/#{render_hook_type.tableize}/show", :view_path => 'app/views', :format => :json)
|
19
|
+
%Q|{"#{render_hook_type}":#{json}}|
|
20
|
+
rescue => e
|
21
|
+
logger.warn "Unable to render #{self} (#{self.class}) using RABL: #{e.message}"
|
22
|
+
logger.debug e.backtrace.join("\n")
|
23
|
+
self.to_json
|
24
|
+
end
|
25
|
+
|
6
26
|
def exec_hook(*args)
|
7
27
|
logger.debug "Running hook: #{args.join(' ')}"
|
8
28
|
success = if defined? Bundler && Bundler.responds_to(:with_clean_env)
|
9
|
-
Bundler.with_clean_env { exec_hook_int(
|
29
|
+
Bundler.with_clean_env { exec_hook_int(render_hook_json, *args) }
|
10
30
|
else
|
11
|
-
exec_hook_int(
|
31
|
+
exec_hook_int(render_hook_json, *args)
|
12
32
|
end.success?
|
13
33
|
|
14
34
|
# Raising here causes Foreman Orchestration to correctly show error bubble in GUI
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dominic Cleal
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-01-
|
11
|
+
date: 2014-01-27 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Plugin engine for Foreman that enables running custom hook scripts on
|
14
14
|
Foreman events
|