foreman_templates 4.0.2 → 5.0.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 405fd0e87a4cc0a5444b3bb95b0313df4618e607
4
- data.tar.gz: 41e1005f524034615387b4640dc92d871d2b9ecf
3
+ metadata.gz: 7e20876391aee6555fefc6346da21ac4dd54e9e9
4
+ data.tar.gz: 1cee72d5d2ec7e8e509791f50f7bd7ae2d168b6c
5
5
  SHA512:
6
- metadata.gz: 4d9f281b4d709925c932f78a62e20de8729da61dec8f73501d0fbdb69b7ba25c6d08063481b016888f7d4cdb6f04e49e7c39fbfe4d7334abb5980a4d3817f80d
7
- data.tar.gz: 6ba2b0f1bc1a70a9e40d32ef683ba27ddd780510e54a5a47458c13827d9c670c26c168093150e4d16d94e835ab065fcd7e686bd3e10887094b9ac93a82e63d9c
6
+ metadata.gz: 28f7610e8b1b4b3aa1cff6a228db20d3ac4d8835265dd6d646a50d0c3ebe536e2548bf3e9184e72af7096f92a40b226a46303f1c13aad1f322018c3260f4e7ef
7
+ data.tar.gz: 7e492ef86762d568446c9c1859957be35d38af649b998352c64f10fb401172773e0e4af6ad2b1d7d8b24d0851f80781fffed89c90f77539d1c77bc390642a35c
@@ -0,0 +1,28 @@
1
+ module Api
2
+ module V2
3
+ class TemplateController < ::Api::V2::BaseController
4
+
5
+ api :POST, "/template/import/", N_("Initiate Import")
6
+ param :repo, String, :required => false, :desc => N_("Import templates from a different repo.")
7
+ param :branch, String, :required => false, :desc => N_("Branch in Git repo.")
8
+ param :prefix, String, :required => false, :desc => N_("The string all imported templates should begin with.")
9
+ param :dirname, String, :required => false, :desc => N_("The directory within the git tree containing the templates.")
10
+ param :filter, String, :required => false, :desc => N_("Import names matching this regex (case-insensitive; snippets are not filtered).")
11
+ param :negate, :bool, :required => false, :desc => N_("Negate the prefix (for purging).")
12
+ param :associate, String, :required => false, :desc => N_("Associate to OS's, Locations & Organizations. Options are: always, new or never.")
13
+ def import
14
+ results = ForemanTemplates::TemplateImporter.new({
15
+ verbose: params['verbose'],
16
+ repo: params['repo'],
17
+ branch: params['branch'],
18
+ prefix: params['prefix'],
19
+ dirname: params['dirname'],
20
+ filter: params['filter'],
21
+ associate: params['associate'],
22
+ negate: params['negate'],
23
+ }).import!
24
+ render :json => {:message => results}
25
+ end
26
+ end
27
+ end
28
+ end
data/config/routes.rb ADDED
@@ -0,0 +1,13 @@
1
+ Rails.application.routes.draw do
2
+
3
+ namespace :api, :defaults => {:format => 'json'} do
4
+ scope "(:apiv)", :module => :v2, :defaults => {:apiv => 'v2'}, :apiv => /v1|v2/, :constraints => ApiConstraints.new(:version => 2) do
5
+ resources :templates, :controller => :template, :only => :import do
6
+ collection do
7
+ post 'import'
8
+ end
9
+ end
10
+ end
11
+ end
12
+
13
+ end
@@ -15,7 +15,16 @@ module ForemanTemplates
15
15
 
16
16
  initializer 'foreman_templates.register_plugin', :before => :finisher_hook do
17
17
  Foreman::Plugin.register :foreman_templates do
18
- requires_foreman '>= 1.14'
18
+ requires_foreman '>= 1.15'
19
+
20
+ apipie_documented_controllers ["#{ForemanTemplates::Engine.root}/app/controllers/api/v2/*.rb"]
21
+
22
+ security_block :templates do
23
+ permission :import_templates, {
24
+ :"api/v2/template" => [:import]
25
+ }, :resource_type => 'Template'
26
+ end
27
+ add_all_permissions_to_default_roles
19
28
  end
20
29
  end
21
30
 
@@ -1,3 +1,3 @@
1
1
  module ForemanTemplates
2
- VERSION = '4.0.2'.freeze
2
+ VERSION = '5.0.0'.freeze
3
3
  end
@@ -14,6 +14,8 @@ namespace :templates do
14
14
  #* filter => Import names matching this regex (case-insensitive; snippets are not filtered)
15
15
  #* associate => Associate to OS's, Locations & Organizations. Options are: always, new or never [new]
16
16
 
17
+ User.current = User.anonymous_admin
18
+
17
19
  results = ForemanTemplates::TemplateImporter.new({
18
20
  verbose: ENV['verbose'],
19
21
  repo: ENV['repo'],
@@ -31,6 +33,8 @@ namespace :templates do
31
33
 
32
34
  desc 'Export templates according to settings'
33
35
  task :export => :environment do
36
+ User.current = User.anonymous_admin
37
+
34
38
  ForemanTemplates::TemplateExporter.new({
35
39
  verbose: ENV['verbose'],
36
40
  repo: ENV['repo'],
@@ -47,6 +51,8 @@ namespace :templates do
47
51
 
48
52
  desc 'Purge unwanted templates from foreman'
49
53
  task :purge => :environment do
54
+ User.current = User.anonymous_admin
55
+
50
56
  ForemanTemplates::TemplateImporter.new({
51
57
  #* negate => negate query [false]
52
58
  #* prefix => The string all templates to purge should ( or not ) begin with [Community ]
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: 4.0.2
4
+ version: 5.0.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: 2017-04-21 00:00:00.000000000 Z
11
+ date: 2017-04-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: diffy
@@ -49,6 +49,7 @@ files:
49
49
  - LICENSE
50
50
  - README.md
51
51
  - Rakefile
52
+ - app/controllers/api/v2/template_controller.rb
52
53
  - app/models/concerns/foreman_templates/provisioning_template_import.rb
53
54
  - app/models/concerns/foreman_templates/ptable_import.rb
54
55
  - app/models/concerns/foreman_templates/template_import.rb
@@ -57,6 +58,7 @@ files:
57
58
  - app/services/foreman_templates/cleaner.rb
58
59
  - app/services/foreman_templates/template_exporter.rb
59
60
  - app/services/foreman_templates/template_importer.rb
61
+ - config/routes.rb
60
62
  - lib/foreman_templates.rb
61
63
  - lib/foreman_templates/engine.rb
62
64
  - lib/foreman_templates/version.rb