deploy_rubygem 0.60.19 → 0.60.21

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
  SHA256:
3
- metadata.gz: ee7c9d9e75a9bb9a640edffb6d267bb28385677078e28dfaca96cf17edba4a24
4
- data.tar.gz: 103b0f1bd56705075451e8ce3f72759b25b5f5d60067ddc1bf93dbd31c0ca3a6
3
+ metadata.gz: d5a382592bfb10083db919cd98d351fedf46531b0f0316340dcd61440d78934a
4
+ data.tar.gz: ae39a1b035154186fd05ffb3a2a0ea3ce5d8d14a0bf13a3cab9d7270f54201d0
5
5
  SHA512:
6
- metadata.gz: c5cbaf614cc2b00d6d22f514a818592d8f2201d2808d6adb6c6e142c1e98ff3dd2327275fc73bea627b2c565b83529f80e9d29eb6c50149d17b942e202eeda5a
7
- data.tar.gz: d2f6ad82f811b76618d10d0af44f8109e3457f103ed41a6e8c48b1a419a130621c9db5f2356645f26ec03d5cef6ef8c306c7409e545745c7b2d8a30afba0bcbd
6
+ metadata.gz: 3316dfff7b0612fd01b95a28cec007e3a7a16a8c509117be35d2945c5e9fce846abbda0e6855cb68c9d44c92596e63eb258f528e087081e80d1cc2c24d7d5e55
7
+ data.tar.gz: 7b6b42ca9946bc38d148c0c74126f71b843951764b9aecca80223eb7128d126e0e0faef4f0152062283abffd5ae7d0e7d8cf172100f2436f1253e0c65e2e7755
checksums.yaml.gz.sig CHANGED
@@ -1,4 +1,2 @@
1
- .��|��·��Է#�q��}:A�#��߶�@~�v�� G�ß-s��U��T�P�.ul�<w^�,d.�'���K�O�}< k���~����Ѭ{�QYF���'�Al����e/{:�7 E��|[�������-j[���8��,��*:���_ QI��*о�BТ(%��J26)�{)��s�0�eUQU9dt0��d1����NXl��{s�%�
2
- ��څ��:�f�g * ��P������Ѻ�~�!?[�����W"ˋ,T���az 0(g������d������bk
3
- .����ta��\(��!���jvp��m��ed {�
4
- Pk�9�#
1
+ A�� ��]9_�Ȱ;$�iU��Dp���cA��Li���60��z��.5��d�K�@�5g�,�H5���H���-�����~�t/�E}�W ��d��\Z��<I�7ݞ��nN>�<ft˟�*zjS,� �t��Cq�z��*�ē�Ե��T��"'�@QN��FU�͇�MG!��Um��-,j�#]��{¹0�J��"@�� X��d"c\=qK����F_qF<h����;�` ��1^,���_�� ��0�\B:�Tg�/�>7k"���%FJ~Uqt�B�����K
2
+ ��r��HR�/ 8�k �\��Z��SM�Q�v��q��-���ޘ�L.O�D+᠕j���< x���틀%�MU�ܶ�fa!>�}�̴k9�L�
@@ -0,0 +1,67 @@
1
+ # frozen_string_literal: true
2
+
3
+ # DeployRubygem - deploy a gem using rake
4
+ # Containing a class
5
+ module DeployRubygem
6
+ # Using Inspec to deploy and manage Inspec
7
+ class InspecTestorResult
8
+ attr_reader :success_control, :success_result, :failed_control, :failed_result, :pending_control, :pending_result
9
+
10
+ def initialize(as_json)
11
+ @as_json = as_json
12
+ @success_control = 0
13
+ @success_result = 0
14
+ @failed_control = 0
15
+ @failed_result = 0
16
+ @pending_control = 0
17
+ @pending_result = 0
18
+ results
19
+ end
20
+
21
+ def profile
22
+ @as_json['profiles'].first
23
+ end
24
+
25
+ def status
26
+ profile['status']
27
+ end
28
+
29
+ def controls
30
+ profile['controls']
31
+ end
32
+
33
+ def result_summary
34
+ {
35
+ success_control: success_control,
36
+ success_result: success_result,
37
+ failed_control: failed_control,
38
+ failed_result: failed_result,
39
+ pending_control: pending_control,
40
+ pending_result: pending_result
41
+ }
42
+ end
43
+
44
+ private
45
+
46
+ def results
47
+ controls.each do |control_result|
48
+ control_as_fail = false
49
+ control_result['results'].each do |item_result|
50
+ case item_result['status']
51
+ when 'passed'
52
+ @success_result += 1
53
+ when 'failed'
54
+ @failed_result += 1
55
+ @failed_control += 1
56
+ control_as_fail = true
57
+ else
58
+ @pending_result += 1
59
+ @pending_control += 1
60
+ control_as_fail = true
61
+ end
62
+ end
63
+ @success_control += 1 unless control_as_fail
64
+ end
65
+ end
66
+ end
67
+ end
@@ -2,6 +2,8 @@
2
2
 
3
3
  require 'json'
4
4
 
5
+ require_relative 'inspec_result'
6
+
5
7
  # DeployRubygem - deploy a gem using rake
6
8
  # Containing a class
7
9
  module DeployRubygem
@@ -15,30 +17,10 @@ module DeployRubygem
15
17
  @waiver_file = waiver_file
16
18
  end
17
19
 
18
- def inspect_name
20
+ def inspec_name
19
21
  File.basename(inspec_path)
20
22
  end
21
23
 
22
- def inspec_options
23
- cmd_opt = []
24
-
25
- unless input_file.nil?
26
- cmd_opt << '--input-file'
27
- cmd_opt << input_file
28
- end
29
-
30
- unless waiver_file.nil?
31
- cmd_opt << '--waiver-file'
32
- cmd_opt << waiver_file
33
- end
34
- cmd_opt
35
- end
36
-
37
- def check
38
- update
39
- system("inspec check #{inspec_path}")
40
- end
41
-
42
24
  def apply
43
25
  puts "ActuaL Dir #{Dir.pwd}"
44
26
  puts "inspec_name = #{inspec_name}"
@@ -60,6 +42,32 @@ module DeployRubygem
60
42
  system("inspec exec #{inspec_path} #{inspec_options.join(' ')} --reporter html:#{html_file}")
61
43
  end
62
44
 
45
+ def test_json
46
+ @test_json ||= InspecTestorResult.new(as_json)
47
+ end
48
+
49
+ private
50
+
51
+ def inspec_options
52
+ cmd_opt = []
53
+
54
+ unless input_file.nil?
55
+ cmd_opt << '--input-file'
56
+ cmd_opt << input_file
57
+ end
58
+
59
+ unless waiver_file.nil?
60
+ cmd_opt << '--waiver-file'
61
+ cmd_opt << waiver_file
62
+ end
63
+ cmd_opt
64
+ end
65
+
66
+ def check
67
+ update
68
+ system("inspec check #{inspec_path}")
69
+ end
70
+
63
71
  def as_json
64
72
  check
65
73
  request_str = `inspec exec #{inspec_path} #{inspec_options.join(' ')} --reporter json`
@@ -96,18 +96,24 @@ module DeployRubygem
96
96
  end
97
97
  end
98
98
 
99
- def testing_inspec(inspec_path, input_file = nil, waiver_file = nil)
100
- inspect_test = InspecTestor.new(inspec_path, input_file, waiver_file)
99
+ def testing_inspec(inspector)
100
+ inspect_test = InspecTestor.new(inspector[:inspec_path], inspector[:input_file], inspector[:waiver_file])
101
101
  RSpec.describe "Testing #{inspect_test} at #{Dir.pwd}" do
102
102
  it 'Should be a kind of Html' do
103
- test_json = inspect_test.save_as_html('/tmp/html/deploy_rubygem_kind_of_html.html')
104
- expect(test_json).not_to be nil
105
- expect(test_json).to be true
103
+ test_html = inspect_test.save_as_html('/tmp/html/deploy_rubygem_kind_of_html.html')
104
+ expect(test_html).to be true
106
105
  end
107
106
  it 'Should be a kind of Json' do
108
- test_json = inspect_test.as_json
109
- expect(test_json).not_to be nil
110
- expect(test_json).to be_kind_of(Hash)
107
+ expect(inspect_test.test_json).to be_kind_of(InspecTestorResult)
108
+ expect(inspect_test.test_json.status).to eq 'loaded'
109
+ end
110
+ it 'Should be successfull' do
111
+ expect(inspect_test.test_json.success_result).to eq inspector[:success_result]
112
+ expect(inspect_test.test_json.success_control).to eq inspector[:success_control]
113
+ expect(inspect_test.test_json.failed_result).to eq inspector[:failed_result]
114
+ expect(inspect_test.test_json.failed_control).to eq inspector[:failed_control]
115
+ expect(inspect_test.test_json.pending_result).to eq inspector[:pending_result]
116
+ expect(inspect_test.test_json.pending_control).to eq inspector[:pending_control]
111
117
  end
112
118
  end
113
119
  end
@@ -17,5 +17,5 @@ module DeployRubygem
17
17
  end
18
18
 
19
19
  # VERSION = new_deploy_rubygem.gvb_version.short_version
20
- VERSION = '0.60.19'
20
+ VERSION = '0.60.21'
21
21
  end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'rspec'
4
+
5
+ # DeployRubygem - deploy a gem using rake
6
+ # Containing a class
7
+ module DeployRubygem
8
+ # Using Project to deploy and manage Project
9
+ class Workstation
10
+ def clientrb
11
+ {
12
+ log_location: '/var/log/chef-client.log',
13
+ chef_server_url: ENV['CHEF_SERVER_URL'],
14
+ chef_license: 'accept',
15
+ file_cache_path: '/var/chef/cache',
16
+ file_backup_path: '/var/chef/backup',
17
+ node_name: ENV['NODENAME'],
18
+ policy_name: ENV['POLICYNAME'],
19
+ policy_group: ENV['POLICYGROUP']
20
+ }.map do |key, value|
21
+ [key, "'#{value}'"].join(' ')
22
+ end.join("\n")
23
+ end
24
+
25
+ def credential
26
+ (['[default]'] + {
27
+ client_name: ENV['KNIFE_NAME'],
28
+ client_key: File.join(ENV['HOME'], '.chef', 'cicd.pem'),
29
+ chef_server_url: ENV['CHEF_SERVER_URL']
30
+ # secret_file: File.join(ENV['HOME'], '.chef', 'cicd.secret')
31
+ }.map do |key, value|
32
+ [key, "'#{value}'"].join(' ')
33
+ end).join("\n")
34
+ end
35
+
36
+ def boostrap_workstation
37
+ clientrb_file = '/etc/chef/client.rb'
38
+ clientpem_file = '/etc/chef/client.pem'
39
+ cicdpem_file = File.join(ENV['HOME'], '.chef', 'cicd.pem')
40
+ cicdcredential_file = File.join(ENV['HOME'], '.chef', 'credentials')
41
+ File.write(clientrb_file, clientrb)
42
+ File.write(clientpem_file, ENV['CHEF_CLIENT_KEY'])
43
+ File.write(cicdpem_file, ENV['CHEF_KNIFE_KEY'])
44
+ File.write(cicdcredential_file, credential)
45
+
46
+ FileUtils.chmod(0o600, clientrb_file)
47
+ FileUtils.chmod(0o600, clientpem_file)
48
+ FileUtils.chmod(0o600, cicdpem_file)
49
+ FileUtils.chmod(0o600, cicdcredential_file)
50
+
51
+ system('chef-client')
52
+ end
53
+ end
54
+ end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deploy_rubygem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.60.19
4
+ version: 0.60.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jimmy Provencher
@@ -138,6 +138,7 @@ files:
138
138
  - lib/deploy_rubygem.rb
139
139
  - lib/deploy_rubygem/cookbook.rb
140
140
  - lib/deploy_rubygem/deploy_rubygem_options.rb
141
+ - lib/deploy_rubygem/inspec_result.rb
141
142
  - lib/deploy_rubygem/inspectestor.rb
142
143
  - lib/deploy_rubygem/kitchen.rb
143
144
  - lib/deploy_rubygem/project.rb
@@ -145,6 +146,7 @@ files:
145
146
  - lib/deploy_rubygem/rubygem.rb
146
147
  - lib/deploy_rubygem/testing.rb
147
148
  - lib/deploy_rubygem/version.rb
149
+ - lib/deploy_rubygem/workstation.rb
148
150
  - sig/deploy_rubygem.rbs
149
151
  homepage: https://github.com/JimboDragonGit/deploy_rubygem
150
152
  licenses:
metadata.gz.sig CHANGED
Binary file