foreman_templates 2.0.3 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 73824f0d37e2a5ad0e90ffda239ad6f7aa712b4d
4
- data.tar.gz: 4bcbc1c9c328850fc4a755c4f14a5d040d328b69
3
+ metadata.gz: b3bd9ea7c7b68c51790a87d66ab47d73f8c8a732
4
+ data.tar.gz: 9a9a5b69cbe4c1a1c46c9657eec4c25bdf7d03c8
5
5
  SHA512:
6
- metadata.gz: eb908855a10ea071b475866103062a03bb2308bf921ef89f8d43d8aaa4f54c55c8a32b11ba7e44d3a85283685200949d1c8ea694d1cf2d0dd5dd0de2535413b2
7
- data.tar.gz: 40d1e5175c74ada21a4ac49e33cd2a62ed8fe7a1d55c09fe007a790a1689a96ab79a5b8929ba922629a1ca2943bd61f004db038cbf7609cfbce7bd66f4b687dd
6
+ metadata.gz: c00161195df295c0366d2eeb1d82526f50402e7d9bb01e7f1a149976dc297b12395df399e5b8233a5f428a81e61c41f5c4807dccc7f8f1dbee4c8066203c01d9
7
+ data.tar.gz: 3a9876e223051b8ed1f3e1f5389558da85e0ab8ea389f10827d77ad3cee24d2bb6c413312fc191e42e1b37882bb0794966652c8b749618c31defb6d8ba4a2ab2
@@ -1,3 +1,3 @@
1
1
  module ForemanTemplates
2
- VERSION = "2.0.3"
2
+ VERSION = "2.1.0"
3
3
  end
@@ -26,6 +26,21 @@ def map_oses
26
26
  return oses
27
27
  end
28
28
 
29
+ def update_job_template
30
+ return {:status => false, :result => 'Skipping job template import, remote execution plugin is not installed.'} unless defined?(JobTemplate)
31
+ template = JobTemplate.import(@text.sub(/^name: .*$/, "name: #{@name}"), :update => true)
32
+
33
+ string = template.new_record? ? 'Created' : 'Updated'
34
+
35
+ if template.template != template.template_was
36
+ diff = Diffy::Diff.new(template.template_was, template.template, :include_diff_info => true).to_s(:color)
37
+ end
38
+
39
+ result = " #{string} Template #{ 'id' + template.id rescue ''}:#{@name}"
40
+
41
+ {:diff => diff, :status => template.save, :result => result}
42
+ end
43
+
29
44
  def update_template
30
45
  # Get template type
31
46
  unless kind = TemplateKind.find_by_name(@metadata['kind'])
@@ -174,6 +189,8 @@ namespace :templates do
174
189
  data = update_ptable
175
190
  when 'snippet'
176
191
  data = update_snippet
192
+ when 'job_template'
193
+ data = update_job_template
177
194
  else
178
195
  data = update_template
179
196
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_templates
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.3
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Greg Sutcliffe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-06 00:00:00.000000000 Z
11
+ date: 2016-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: diffy
@@ -73,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
73
73
  version: '0'
74
74
  requirements: []
75
75
  rubyforge_project:
76
- rubygems_version: 2.4.5.1
76
+ rubygems_version: 2.5.1
77
77
  signing_key:
78
78
  specification_version: 4
79
79
  summary: Template-syncing engine for Foreman