hammer_cli_foreman_templates 0.1.1 → 0.1.2

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
- SHA1:
3
- metadata.gz: c9940a9b1ee7f78f853be626ec6c12ef4836ecf7
4
- data.tar.gz: 324d0dc97ba2d88254bbbbdde8d1a3cfe4de8c68
2
+ SHA256:
3
+ metadata.gz: 8f6da17ea43bb64f7903d23cb2dbdcbd2bd6f3fd68aa4f1e3ec7977c991cafe2
4
+ data.tar.gz: a9f3dfbf5ba28b9132eb2596e0e344fc913b212c536c05010e35f56296259c86
5
5
  SHA512:
6
- metadata.gz: 920c4fbc3508ecce17204bb57619c065a06c8a6aa7dbd6526a12d5452e87c7a254a4a149f9e1ff76a21d86f985186adbc4e116f98ce0201d702636799b5086df
7
- data.tar.gz: c50266c5c8745f49f1051e28f22bc6f1cd80d5d47770f05a0eb61110134afe3ee3428208d2b0af26d35c4eb5ebbbd9be43ca02c2d1caa09f83708e20762aed21
6
+ metadata.gz: 6bf9fdf5b46253f61d5810b0d8c8bd8f78cb98bae4529c1189853ac26159ec3b5e1590373cdfbbccf0f5e0968f56a2ec5ef8e5d854aba5bf20f572808aa4cae7
7
+ data.tar.gz: ecfc7ef16c7dd17b918e9367371da6d8056d4b07ce408cf0337d4470d1784c0bb698f8976882fc392c62fba09370c5ff9123e70a95d35b9ef7e0320524ba9be2
data/README.md CHANGED
@@ -1,8 +1,39 @@
1
- # hammer_cli_foreman_templates
1
+ # Hammer CLI Foreman Templates
2
2
 
3
- Next-gen CLI tool for [ForemanTemplates](http://www.theforeman.org/plugins/foreman_templates/)
3
+ This Hammer CLI plugin contains set of commands for [foreman_templates](
4
+ https://github.com/theforeman/foreman_templates
5
+ ), a plugin to Foreman for syncing the contents of the Foreman Community
6
+ Templates [repository](
7
+ https://github.com/theforeman/community-templates/
8
+ ) (or a git repo of your choice).
4
9
 
5
- hammer-cli development docs for [help](https://github.com/theforeman/hammer-cli/blob/master/doc/developer_docs.md#hammer-development-docs)
10
+ ## Versions
11
+
12
+ This is the list of which version of Foreman Templates is needed to which version of this plugin.
13
+
14
+ | Hammer Templates | 0.1.0+ |
15
+ |-------------------|--------|
16
+ | Foreman Templates | 5.0.2+ |
17
+
18
+ ## Installation
19
+
20
+ $ gem install hammer_cli_foreman_templates
21
+
22
+ $ mkdir -p ~/.hammer/cli.modules.d/
23
+
24
+ $ cat <<EOQ > ~/.hammer/cli.modules.d/foreman_templates.yml
25
+ :foreman_templates:
26
+ :enable_module: true
27
+ EOQ
28
+
29
+ # to confirm things work, this should return useful output
30
+ hammer import-templates --help
31
+ hammer export-templates --help
32
+
33
+ ## More info
34
+
35
+ See our [Hammer CLI installation and configuration instuctions](
36
+ https://github.com/theforeman/hammer-cli/blob/master/doc/installation.md#installation).
6
37
 
7
38
  ## Development setup
8
39
  With this guide, you'll be able to set up hammer_cli_foreman_templates with hammer-cli-foreman for development.
@@ -69,5 +100,3 @@ You should see in the output:
69
100
  Extension module hammer_cli_foreman_templates (version) loaded
70
101
  ```
71
102
  If you see no errors, you should be good to go.
72
-
73
-
@@ -3,9 +3,14 @@ require 'hammer_cli_foreman/template'
3
3
 
4
4
  module HammerCLIForemanTemplates
5
5
  require 'hammer_cli_foreman_templates/version'
6
+ require 'hammer_cli_foreman_templates/exception_handler'
6
7
  require 'hammer_cli_foreman_templates/import'
7
8
  require 'hammer_cli_foreman_templates/export'
8
9
 
10
+ def self.exception_handler_class
11
+ HammerCLIForemanTemplates::ExceptionHandler
12
+ end
13
+
9
14
  HammerCLI::MainCommand.lazy_subcommand(
10
15
  ImportCommand.command_name,
11
16
  ImportCommand.desc,
@@ -0,0 +1,23 @@
1
+ module HammerCLIForemanTemplates
2
+ class ExceptionHandler < HammerCLIForeman::ExceptionHandler
3
+ def mappings
4
+ [
5
+ [RestClient::InternalServerError, :handle_internal_error]
6
+ ] + super
7
+ end
8
+
9
+ protected
10
+
11
+ def handle_internal_error(e)
12
+ handle_templates_error(e)
13
+ HammerCLI::EX_SOFTWARE
14
+ end
15
+
16
+ def handle_templates_error(e)
17
+ response = JSON.parse(e.response)
18
+ response = HammerCLIForeman.record_to_common_format(response)
19
+ print_error(response['error'] || response['warning'])
20
+ log_full_error e
21
+ end
22
+ end
23
+ end
@@ -5,9 +5,26 @@ module HammerCLIForemanTemplates
5
5
 
6
6
  resource :template, :export
7
7
 
8
- success_message _('Export finished')
8
+ success_message _('Export finished.')
9
9
  failure_message _('Could not export')
10
10
 
11
- build_options without: [:verbose]
11
+ option '--verbose', 'BE_VERBOSE', _('Be verbose'),
12
+ format: HammerCLI::Options::Normalizers::Bool.new
13
+
14
+ output do
15
+ field :id, _('Id'), Fields::Id
16
+ field :name, _('Name')
17
+ field :type, _('Type')
18
+ field :exported, _('Exported')
19
+ end
20
+
21
+ def execute
22
+ templates = send_request['templates']
23
+ templates = [] unless option_verbose
24
+ print_data(templates)
25
+ HammerCLI::EX_OK
26
+ end
27
+
28
+ build_options
12
29
  end
13
30
  end
@@ -5,9 +5,48 @@ module HammerCLIForemanTemplates
5
5
 
6
6
  resource :template, :import
7
7
 
8
- success_message _('Import finished')
8
+ success_message _('Import finished.')
9
9
  failure_message _('Could not import')
10
10
 
11
- build_options without: [:verbose]
11
+ output do
12
+ field :id, _('Id'), Fields::Id
13
+ field :name, _('Name')
14
+ field :type, _('Type')
15
+ field :imported, _('Imported')
16
+ field :changed, _('Changed')
17
+ field nil, _('Changes'), Fields::Label, hide_blank: true do
18
+ field :diff, nil, Fields::LongText, hide_blank: true
19
+ end
20
+ field nil, _('Errors'), Fields::Label, hide_blank: true do
21
+ field :validation_errors, _('Validation'), Fields::Collection, hide_blank: true do
22
+ field nil, nil
23
+ end
24
+ field :additional_errors, _('Additional'), Fields::LongText, hide_blank: true
25
+ field :exception, _('Exception'), Fields::LongText, hide_blank: true
26
+ end
27
+ end
28
+
29
+ def execute
30
+ templates = send_request['templates']
31
+ if option_verbose
32
+ templates.each do |template|
33
+ if template['validation_errors'].empty?
34
+ template['validation_errors'] = nil
35
+ else
36
+ validation_errors = []
37
+ template['validation_errors'].each do |key, value|
38
+ validation_errors << "#{key.capitalize}: #{value}"
39
+ end
40
+ template['validation_errors'] = validation_errors
41
+ end
42
+ end
43
+ else
44
+ templates = []
45
+ end
46
+ print_data(templates)
47
+ HammerCLI::EX_OK
48
+ end
49
+
50
+ build_options
12
51
  end
13
52
  end
@@ -1,6 +1,6 @@
1
1
 
2
2
  module HammerCLIForemanTemplates
3
3
  def self.version
4
- @version ||= Gem::Version.new '0.1.1'
4
+ @version ||= Gem::Version.new '0.1.2'
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hammer_cli_foreman_templates
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - The Foreman team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-13 00:00:00.000000000 Z
11
+ date: 2018-09-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hammer_cli_foreman
@@ -38,14 +38,15 @@ files:
38
38
  - README.md
39
39
  - config/foreman_templates.yml
40
40
  - lib/hammer_cli_foreman_templates.rb
41
+ - lib/hammer_cli_foreman_templates/exception_handler.rb
41
42
  - lib/hammer_cli_foreman_templates/export.rb
42
43
  - lib/hammer_cli_foreman_templates/i18n.rb
43
44
  - lib/hammer_cli_foreman_templates/import.rb
44
45
  - lib/hammer_cli_foreman_templates/version.rb
45
46
  - test/test_helper.rb
46
- homepage: http://github.com/theforeman/hammer-cli-foreman-templates
47
+ homepage: https://github.com/theforeman/hammer-cli-foreman-templates
47
48
  licenses:
48
- - GPL-3
49
+ - GPL-3.0
49
50
  metadata: {}
50
51
  post_install_message:
51
52
  rdoc_options: []
@@ -63,7 +64,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
63
64
  version: '0'
64
65
  requirements: []
65
66
  rubyforge_project:
66
- rubygems_version: 2.6.14
67
+ rubygems_version: 2.7.7
67
68
  signing_key:
68
69
  specification_version: 4
69
70
  summary: Foreman Hammer commands for exporting and importing templates