onceover 3.21.0 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (191) hide show
  1. checksums.yaml +4 -4
  2. data/.devcontainer/devcontainer.json +4 -6
  3. data/.github/dependabot.yml +17 -0
  4. data/.github/workflows/release.yaml +32 -0
  5. data/.github/workflows/tests.yaml +30 -4
  6. data/.gitignore +2 -1
  7. data/.rubocop.yml +4 -704
  8. data/.rubocop_todo.yml +828 -0
  9. data/CHANGELOG.md +1036 -0
  10. data/Gemfile +9 -0
  11. data/LICENSE +202 -0
  12. data/README.md +122 -32
  13. data/Rakefile +24 -14
  14. data/cucumber.yml +1 -0
  15. data/features/auto_vendored.feature +27 -0
  16. data/features/step_definitions/common.rb +5 -5
  17. data/features/step_definitions/run.rb +4 -0
  18. data/features/support/cache_helper.rb +0 -1
  19. data/features/support/command_helper.rb +0 -2
  20. data/features/support/controlrepo_helper.rb +0 -2
  21. data/features/zzz_run.feature +1 -8
  22. data/lib/onceover/beaker/spec_helper.rb +9 -9
  23. data/lib/onceover/beaker.rb +9 -12
  24. data/lib/onceover/cli/run.rb +1 -0
  25. data/lib/onceover/controlrepo.rb +22 -27
  26. data/lib/onceover/deploy.rb +30 -3
  27. data/lib/onceover/group.rb +1 -3
  28. data/lib/onceover/logger.rb +3 -3
  29. data/lib/onceover/node.rb +0 -2
  30. data/lib/onceover/rake_tasks.rb +9 -4
  31. data/lib/onceover/rspec/formatters.rb +5 -8
  32. data/lib/onceover/runner.rb +1 -1
  33. data/lib/onceover/test.rb +2 -3
  34. data/lib/onceover/testconfig.rb +2 -2
  35. data/lib/onceover/vendored_modules.rb +186 -0
  36. data/onceover.gemspec +26 -30
  37. data/spec/fixtures/controlrepos/caching/spec/factsets/README.md +1 -1
  38. data/spec/fixtures/controlrepos/caching/spec/pre_conditions/README.md +1 -1
  39. data/spec/fixtures/controlrepos/factsets/spec/factsets/README.md +1 -1
  40. data/spec/fixtures/controlrepos/puppet_controlrepo/.atom-build.json +9 -0
  41. data/spec/fixtures/controlrepos/puppet_controlrepo/.gitignore +5 -0
  42. data/spec/fixtures/controlrepos/puppet_controlrepo/.ruby-version +1 -0
  43. data/spec/fixtures/controlrepos/puppet_controlrepo/.travis.yml +13 -0
  44. data/spec/fixtures/controlrepos/puppet_controlrepo/Gemfile +22 -0
  45. data/spec/fixtures/controlrepos/puppet_controlrepo/Jenkinsfile +50 -0
  46. data/spec/fixtures/controlrepos/puppet_controlrepo/Puppetfile +102 -0
  47. data/spec/fixtures/controlrepos/puppet_controlrepo/README.md +4 -0
  48. data/spec/fixtures/controlrepos/puppet_controlrepo/Rakefile +6 -0
  49. data/spec/fixtures/controlrepos/puppet_controlrepo/data/common.yaml +558 -0
  50. data/spec/fixtures/controlrepos/puppet_controlrepo/data/datacenter/melbourne.yaml +12 -0
  51. data/spec/fixtures/controlrepos/puppet_controlrepo/data/datacenter/singapore.yaml +12 -0
  52. data/spec/fixtures/controlrepos/puppet_controlrepo/data/environments/development.yaml +3 -0
  53. data/spec/fixtures/controlrepos/puppet_controlrepo/data/environments/production.yaml +3 -0
  54. data/spec/fixtures/controlrepos/puppet_controlrepo/data/size/vol.large.yaml +27 -0
  55. data/spec/fixtures/controlrepos/puppet_controlrepo/environment.conf +3 -0
  56. data/spec/fixtures/controlrepos/puppet_controlrepo/hiera.yaml +25 -0
  57. data/spec/fixtures/controlrepos/puppet_controlrepo/manifests/site.pp +11 -0
  58. data/spec/fixtures/controlrepos/puppet_controlrepo/scripts/code_manager_config_version.rb +19 -0
  59. data/spec/fixtures/controlrepos/puppet_controlrepo/scripts/config_version.rb +25 -0
  60. data/spec/fixtures/controlrepos/puppet_controlrepo/scripts/config_version.sh +12 -0
  61. data/spec/fixtures/controlrepos/puppet_controlrepo/scripts/count_changed_classes.rb +26 -0
  62. data/spec/fixtures/controlrepos/puppet_controlrepo/scripts/get_changed_classes.rb +26 -0
  63. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/console/functions/user/token.pp +10 -0
  64. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/console/manifests/init.pp +14 -0
  65. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/console/manifests/user.pp +35 -0
  66. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/deployments/lib/puppet/functions/deployments/generate.rb +15 -0
  67. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/deployments/plans/signed_deployment.pp +126 -0
  68. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/facts.d/test.sh +2 -0
  69. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/files/artifactory/config_descriptor.xml +265 -0
  70. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/files/autosign.sh +23 -0
  71. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/files/hudson.tasks.Shell.xml +4 -0
  72. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/files/motd +4 -0
  73. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/files/polar_clock/index.html +198 -0
  74. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/apt.pp +9 -0
  75. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/aws_nodes.pp +54 -0
  76. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/base/aws.pp +9 -0
  77. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/base/rhel.pp +50 -0
  78. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/base/windows/hardening.pp +57 -0
  79. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/base/windows.pp +52 -0
  80. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/base.pp +79 -0
  81. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/cd4pe/artifactory.pp +64 -0
  82. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/cd4pe/connection.pp +95 -0
  83. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/cd4pe/haproxy.pp +65 -0
  84. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/cd4pe/replicated.pp +53 -0
  85. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/compile/balancer.pp +28 -0
  86. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/compile/master.pp +19 -0
  87. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/dns/host_record.pp +16 -0
  88. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/dns/server.pp +66 -0
  89. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/docker.pp +5 -0
  90. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/eyeunify/base.pp +43 -0
  91. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/eyeunify/core/database_connection.pp +42 -0
  92. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/eyeunify/core.pp +72 -0
  93. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/eyeunify/ctrl.pp +57 -0
  94. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/eyeunify/database.pp +32 -0
  95. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/eyeunify/exec.pp +11 -0
  96. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/file_sync/client.pp +165 -0
  97. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/file_sync/master_patch.pp +37 -0
  98. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/grafana/dashboard.pp +17 -0
  99. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/haproxy.pp +43 -0
  100. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/init.pp +3 -0
  101. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/jenkins/plugins.pp +87 -0
  102. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/jenkins.pp +65 -0
  103. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/jira/aio.pp +39 -0
  104. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/jira/app.pp +27 -0
  105. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/jira/db.pp +25 -0
  106. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/metrics/collectd/compile.pp +82 -0
  107. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/metrics/collectd.pp +28 -0
  108. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/metrics/dashboard.pp +28 -0
  109. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/mysql_server.pp +7 -0
  110. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/nginx.pp +24 -0
  111. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/polar_clock.pp +55 -0
  112. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/puppetmaster/api_auth.pp +82 -0
  113. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/puppetmaster/autosign.pp +33 -0
  114. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/puppetmaster/aws.pp +58 -0
  115. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/puppetmaster/tuning.pp +139 -0
  116. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/puppetmaster.pp +139 -0
  117. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/rvm.pp +13 -0
  118. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/sumologic.pp +11 -0
  119. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/sunburst/windows.pp +104 -0
  120. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/vagrant.pp +25 -0
  121. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/manifests/windows/webserver.pp +27 -0
  122. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/templates/cd4pe/connection_script.sh.epp +110 -0
  123. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/templates/controlrepo_deploy_jenkins_job.xml.epp +51 -0
  124. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/templates/dashboard.json.epp +403 -0
  125. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/templates/jenkins_secret_text.json.epp +1 -0
  126. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/templates/onceover_jenkins_job.xml.epp +51 -0
  127. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/profile/templates/userdata.epp +17 -0
  128. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/role/manifests/cd4pe.pp +29 -0
  129. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/role/manifests/clock.pp +16 -0
  130. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/role/manifests/compile/balancer.pp +5 -0
  131. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/role/manifests/compile/master.pp +5 -0
  132. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/role/manifests/eyeunify/aio.pp +10 -0
  133. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/role/manifests/eyeunify/controller.pp +10 -0
  134. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/role/manifests/eyeunify/database.pp +7 -0
  135. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/role/manifests/eyeunify/exec.pp +6 -0
  136. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/role/manifests/init.pp +3 -0
  137. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/role/manifests/lb.pp +14 -0
  138. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/role/manifests/metrics.pp +5 -0
  139. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/role/manifests/mysql.pp +13 -0
  140. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/role/manifests/windows/base.pp +5 -0
  141. data/spec/fixtures/controlrepos/puppet_controlrepo/site-modules/role/manifests/windows/webserver.pp +6 -0
  142. data/spec/fixtures/controlrepos/puppet_controlrepo/spec/.gitignore +5 -0
  143. data/spec/fixtures/controlrepos/puppet_controlrepo/spec/acceptance/nodesets/onceover-nodes.yml +94 -0
  144. data/spec/fixtures/controlrepos/puppet_controlrepo/spec/classes/test_spec.rb +8 -0
  145. data/spec/fixtures/controlrepos/puppet_controlrepo/spec/factsets/CentOS-7.0-64-master-2017.3.2.json +531 -0
  146. data/spec/fixtures/controlrepos/puppet_controlrepo/spec/factsets/CentOS-7.0-64-master.json +429 -0
  147. data/spec/fixtures/controlrepos/puppet_controlrepo/spec/factsets/CentOS-7.0-64.json +353 -0
  148. data/spec/fixtures/controlrepos/puppet_controlrepo/spec/factsets/Windows_Server-2008r2-64.json +184 -0
  149. data/spec/fixtures/controlrepos/puppet_controlrepo/spec/factsets/Windows_Server-2012r2-64.json +165 -0
  150. data/spec/fixtures/controlrepos/puppet_controlrepo/spec/hiera.yaml +18 -0
  151. data/spec/fixtures/controlrepos/puppet_controlrepo/spec/matchers/file_matchers.rb +16 -0
  152. data/spec/fixtures/controlrepos/puppet_controlrepo/spec/onceover.yaml +54 -0
  153. data/spec/fixtures/controlrepos/puppet_controlrepo/spec/pre_conditions/site.pp +150 -0
  154. data/spec/fixtures/controlrepos/puppet_controlrepo/spec/r10k.yaml +2 -0
  155. data/spec/fixtures/controlrepos/puppet_controlrepo/spec/shared_examples/helper.rb +91 -0
  156. data/spec/fixtures/controlrepos/puppet_controlrepo/spec/unit/00_parse_spec.rb +76 -0
  157. data/spec/fixtures/controlrepos/puppet_controlrepo/spec/unit/01_linting_spec_example.rb +69 -0
  158. data/spec/fixtures/controlrepos/puppet_controlrepo/spec/unit/03_puppetfile_spec_example.rb +35 -0
  159. data/spec/fixtures/controlrepos/vendored/Puppetfile +3 -0
  160. data/spec/fixtures/controlrepos/vendored/Puppetfile.cron +5 -0
  161. data/spec/fixtures/controlrepos/vendored/environment.conf +1 -0
  162. data/spec/fixtures/controlrepos/vendored/site-modules/role/manifests/cron.pp +9 -0
  163. data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/augeas_core-puppet_agent-7.30.0.json +1 -0
  164. data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/augeas_core-puppet_agent-8.6.0.json +1 -0
  165. data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/cron_core-puppet_agent-7.30.0.json +1 -0
  166. data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/cron_core-puppet_agent-8.6.0.json +1 -0
  167. data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/host_core-puppet_agent-7.30.0.json +1 -0
  168. data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/host_core-puppet_agent-8.6.0.json +1 -0
  169. data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/mount_core-puppet_agent-7.30.0.json +1 -0
  170. data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/mount_core-puppet_agent-8.6.0.json +1 -0
  171. data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/repo_tree-puppet_agent-7.30.0.json +1 -0
  172. data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/repo_tree-puppet_agent-8.6.0.json +1 -0
  173. data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/scheduled_task-puppet_agent-7.30.0.json +1 -0
  174. data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/scheduled_task-puppet_agent-8.6.0.json +1 -0
  175. data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/selinux_core-puppet_agent-7.30.0.json +1 -0
  176. data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/selinux_core-puppet_agent-8.6.0.json +1 -0
  177. data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/sshkeys_core-puppet_agent-7.30.0.json +1 -0
  178. data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/sshkeys_core-puppet_agent-8.6.0.json +1 -0
  179. data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/yumrepo_core-puppet_agent-7.30.0.json +1 -0
  180. data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/yumrepo_core-puppet_agent-8.6.0.json +1 -0
  181. data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/zfs_core-puppet_agent-7.30.0.json +1 -0
  182. data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/zfs_core-puppet_agent-8.6.0.json +1 -0
  183. data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/zone_core-puppet_agent-7.30.0.json +1 -0
  184. data/spec/fixtures/controlrepos/vendored/spec/vendored_modules/zone_core-puppet_agent-8.6.0.json +1 -0
  185. data/spec/onceover/controlrepo_spec.rb +1 -1
  186. data/templates/factsets_README.md.erb +1 -1
  187. data/templates/pre_conditions_README.md.erb +1 -1
  188. data/templates/spec_helper.rb.erb +0 -2
  189. data/templates/test_spec.rb.erb +3 -0
  190. metadata +173 -68
  191. data/.gitmodules +0 -4
@@ -1,5 +1,4 @@
1
1
  class ControlRepo_Helper
2
-
3
2
  attr_reader :tmp_folder
4
3
 
5
4
  def initialize( name )
@@ -34,5 +33,4 @@ class ControlRepo_Helper
34
33
  def add_line_to_puppetfile( line )
35
34
  open(puppetfile, 'a') { |f| f.puts line }
36
35
  end
37
-
38
36
  end
@@ -38,14 +38,7 @@ Feature: Run rspec and acceptance test suites
38
38
  When I run onceover command "run spec"
39
39
  Then I should see error with message pattern "The module acme-not_exists does not exist"
40
40
 
41
- # TODO: Work out why this is fialing on windows
42
- # Scenario: Run with local modifications
43
- # Given initialized control repo "basic"
44
- # When I run onceover command "run spec"
45
- # And I make local modifications
46
- # And I run onceover command "run spec"
47
- # Then I should see message pattern "local modifications"
48
-
41
+ @skip_on_windows
49
42
  Scenario: Force overwrite local modifications
50
43
  Given initialized control repo "basic"
51
44
  When I run onceover command "run spec"
@@ -35,18 +35,18 @@ RSpec.configure do |c|
35
35
 
36
36
  #default option values
37
37
  defaults = {
38
- :nodeset => 'onceover-nodes',
38
+ :nodeset => 'onceover-nodes',
39
39
  }
40
40
  #read env vars
41
41
  env_vars = {
42
- :color => ENV['BEAKER_color'] || ENV['RS_COLOR'],
43
- :nodeset => ENV['BEAKER_set'] || ENV['RS_SET'],
44
- :nodesetfile => ENV['BEAKER_setfile'] || ENV['RS_SETFILE'],
45
- :provision => ENV['BEAKER_provision'] || ENV['RS_PROVISION'],
46
- :keyfile => ENV['BEAKER_keyfile'] || ENV['RS_KEYFILE'],
47
- :debug => ENV['BEAKER_debug'] || ENV['RS_DEBUG'],
48
- :destroy => ENV['BEAKER_destroy'] || ENV['RS_DESTROY'],
49
- }.delete_if {|key, value| value.nil?}
42
+ :color => ENV['BEAKER_color'] || ENV.fetch('RS_COLOR', nil),
43
+ :nodeset => ENV['BEAKER_set'] || ENV.fetch('RS_SET', nil),
44
+ :nodesetfile => ENV['BEAKER_setfile'] || ENV.fetch('RS_SETFILE', nil),
45
+ :provision => ENV['BEAKER_provision'] || ENV.fetch('RS_PROVISION', nil),
46
+ :keyfile => ENV['BEAKER_keyfile'] || ENV.fetch('RS_KEYFILE', nil),
47
+ :debug => ENV['BEAKER_debug'] || ENV.fetch('RS_DEBUG', nil),
48
+ :destroy => ENV['BEAKER_destroy'] || ENV.fetch('RS_DESTROY', nil),
49
+ }.compact
50
50
  #combine defaults and env_vars to determine overall options
51
51
  options = defaults.merge(env_vars)
52
52
 
@@ -11,9 +11,8 @@ class Onceover
11
11
  # se or an array
12
12
 
13
13
  if facts.is_a?(Array)
14
- returnval = []
15
- facts.each do |fact|
16
- returnval << self.facts_to_vagrant_box(fact)
14
+ returnval = facts.map do |fact|
15
+ self.facts_to_vagrant_box(fact)
17
16
  end
18
17
  return returnval
19
18
  end
@@ -64,9 +63,8 @@ class Onceover
64
63
  warn "[DEPRECATION] #{__method__} is deprecated due to the removal of Beaker"
65
64
 
66
65
  if facts.is_a?(Array)
67
- returnval = []
68
- facts.each do |fact|
69
- returnval << self.facts_to_platform(fact)
66
+ returnval = facts.map do |fact|
67
+ self.facts_to_platform(fact)
70
68
  end
71
69
  return returnval
72
70
  end
@@ -131,9 +129,9 @@ class Onceover
131
129
 
132
130
  # Do an r10k deploy
133
131
  r10k_deploy(host, {
134
- :puppetfile => true,
135
- :configfile => '/tmp/r10k.yaml',
136
- })
132
+ :puppetfile => true,
133
+ :configfile => '/tmp/r10k.yaml',
134
+ })
137
135
  end
138
136
 
139
137
  # This actually provisions a node and checks that puppet will be able to run and
@@ -153,7 +151,6 @@ class Onceover
153
151
  opts = {:check_idempotency => true}.merge(opts)
154
152
  opts = {:deploy_controlrepo => true}.merge(opts)
155
153
 
156
-
157
154
  raise "Hosts must be a single host object, not an array" if host.is_a?(Array)
158
155
  raise "Class must be a single Class [String], not an array" unless puppet_class.is_a?(String)
159
156
 
@@ -216,8 +213,8 @@ class Onceover
216
213
  # to refer to each key as either a string or an object
217
214
  current_opts.default_proc = proc do |h, k|
218
215
  case k
219
- when String then sym = k.to_sym; h[sym] if h.key?(sym)
220
- when Symbol then str = k.to_s; h[str] if h.key?(str)
216
+ when String then sym = k.to_sym; h[sym] if h.key?(sym)
217
+ when Symbol then str = k.to_s; h[str] if h.key?(str)
221
218
  end
222
219
  end
223
220
 
@@ -44,6 +44,7 @@ This includes deploying using r10k and running all custom tests.
44
44
  optional nil, :format, 'Which RSpec formatter to use, valid options are: documentation, progress, FailureCollector, OnceoverFormatter. You also specify this multiple times', multiple: true, default: :defaults
45
45
  optional nil, :no_workarounds, 'Disables workarounds that have been added for convenience to get around common RSPec issues such as https://github.com/rodjek/rspec-puppet/issues/665'
46
46
  optional :ff, :fail_fast, 'Abort the run after the first failure'
47
+ optional nil, :auto_vendored, 'Attempt to resolve vendored puppet modules. Ex: puppetlabs/cron_core', default: false
47
48
 
48
49
  run do |opts, args, cmd|
49
50
  repo = Onceover::Controlrepo.new(opts)
@@ -119,7 +119,7 @@ class Onceover
119
119
  @spec_dir = opts[:spec_dir] || File.expand_path('./spec', @root)
120
120
  @facts_dir = opts[:facts_dir] || File.expand_path('factsets', @spec_dir)
121
121
  _facts_dirs = [@facts_dir, File.expand_path('../../factsets', __dir__)]
122
- _facts_files = opts[:facts_files] || _facts_dirs.map{|d| File.join(d, '*.json')}
122
+ _facts_files = opts[:facts_files] || _facts_dirs.map{|d| File.join(d, '*.json')}
123
123
  @facts_files = _facts_files.map{|_path| Dir[_path]}.flatten
124
124
 
125
125
  @nodeset_file = opts[:nodeset_file] || File.expand_path('./spec/acceptance/nodesets/onceover-nodes.yml', @root)
@@ -139,7 +139,6 @@ class Onceover
139
139
  end
140
140
  end
141
141
 
142
-
143
142
  def to_s
144
143
  require 'colored'
145
144
 
@@ -182,9 +181,8 @@ class Onceover
182
181
  end
183
182
 
184
183
  # Get all the classes from all of the manifests
185
- classes = []
186
- code_dirs.each do |dir|
187
- classes << get_classes(dir)
184
+ classes = code_dirs.map do |dir|
185
+ get_classes(dir)
188
186
  end
189
187
  classes.flatten
190
188
  end
@@ -208,9 +206,8 @@ class Onceover
208
206
  raise "Filter param must be a hash" unless filter.is_a?(Hash)
209
207
 
210
208
  all_facts.keep_if do |hash|
211
- matches = []
212
- filter.each do |filter_fact,value|
213
- matches << keypair_is_in_hash(hash,filter_fact,value)
209
+ matches = filter.map do |filter_fact,value|
210
+ keypair_is_in_hash(hash,filter_fact,value)
214
211
  end
215
212
  !matches.include? false
216
213
  end
@@ -231,10 +228,9 @@ class Onceover
231
228
  puppetfile.load!
232
229
 
233
230
  output_array = []
234
- threads = []
235
231
  error_array = []
236
- puppetfile.modules.each do |mod|
237
- threads << Thread.new do
232
+ threads = puppetfile.modules.map do |mod|
233
+ Thread.new do
238
234
  begin
239
235
  row = []
240
236
  logger.debug "Loading data for #{mod.full_name}"
@@ -268,7 +264,7 @@ class Onceover
268
264
  "PatchLevel_minor".green
269
265
  else
270
266
  "No".green
271
- end
267
+ end
272
268
 
273
269
  row << mod.v3_module.endorsement
274
270
  superseded_by = mod.v3_module.superseded_by
@@ -290,8 +286,8 @@ class Onceover
290
286
  error_array << error
291
287
  logger.debug "Error loading module #{mod.full_name} - #{e.inspect}"
292
288
  end
293
- end
294
289
  end
290
+ end
295
291
 
296
292
  threads.map(&:join)
297
293
 
@@ -313,13 +309,12 @@ class Onceover
313
309
  # TODO: Make sure we can deal with :latest
314
310
 
315
311
  # Create threading resources
316
- threads = []
317
- queue = Queue.new
312
+ queue = Queue.new
318
313
  queue.push(puppetfile_string)
319
314
 
320
315
  puppetfile.modules.keep_if {|m| m.is_a?(R10K::Module::Forge)}
321
- puppetfile.modules.each do |mod|
322
- threads << Thread.new do
316
+ threads = puppetfile.modules.map do |mod|
317
+ Thread.new do
323
318
  logger.debug "Getting latest version of #{mod.full_name}"
324
319
  latest_version = mod.v3_module.current_release.version
325
320
 
@@ -360,14 +355,14 @@ class Onceover
360
355
  # Set it up as a symlink, because we are using local files in the Puppetfile
361
356
  symlinks << {
362
357
  'name' => mod.name,
363
- 'dir' => mod.expected_version[:path]
358
+ 'dir' => mod.expected_version[:path]
364
359
  }
365
360
  elsif mod.expected_version.is_a?(String)
366
361
  # Set it up as a normal forge module
367
362
  forge_modules << {
368
363
  'name' => mod.name,
369
364
  'repo' => mod.title,
370
- 'ref' => mod.expected_version
365
+ 'ref' => mod.expected_version
371
366
  }
372
367
  end
373
368
  elsif mod.is_a? R10K::Module::Git
@@ -377,7 +372,7 @@ class Onceover
377
372
  # I know I shouldn't be doing this, but trust me, there are no methods
378
373
  # anywhere that expose this value, I looked.
379
374
  'repo' => mod.instance_variable_get(:@remote),
380
- 'ref' => mod.version
375
+ 'ref' => mod.version
381
376
  }
382
377
  end
383
378
  end
@@ -392,7 +387,7 @@ class Onceover
392
387
  Dir["#{dir}/*"].each do |mod|
393
388
  symlinks << {
394
389
  'name' => File.basename(mod),
395
- 'dir' => Pathname.new(File.expand_path(mod)).relative_path_from(Pathname.new(@root))#File.expand_path(mod)
390
+ 'dir' => Pathname.new(File.expand_path(mod)).relative_path_from(Pathname.new(@root))#File.expand_path(mod)
396
391
  }
397
392
  end
398
393
  end
@@ -517,7 +512,7 @@ class Onceover
517
512
  # Add .onceover to Gitignore
518
513
  gitignore_path = File.expand_path('.gitignore', repo.root)
519
514
  if File.exist? gitignore_path
520
- gitignore_content = (File.open(gitignore_path, 'r') {|f| f.read }).split("\n")
515
+ gitignore_content = (File.read(gitignore_path)).split("\n")
521
516
  message = "#{'changed'.green}"
522
517
  else
523
518
  message = "#{'created'.green}"
@@ -526,7 +521,7 @@ class Onceover
526
521
 
527
522
  unless gitignore_content.include?(".onceover")
528
523
  gitignore_content << ".onceover\n"
529
- File.open(gitignore_path, 'w') {|f| f.write(gitignore_content.join("\n")) }
524
+ File.write(gitignore_path, gitignore_content.join("\n"))
530
525
  puts "#{message} #{Pathname.new(gitignore_path).relative_path_from(Pathname.new(Dir.pwd)).to_s}"
531
526
  end
532
527
  end
@@ -574,9 +569,9 @@ class Onceover
574
569
  # Add the resulting info to the hosts hash. This is what the
575
570
  # template will output
576
571
  hosts_hash[node_name] = {
577
- :platform => platform,
578
- :boxname => boxname,
579
- :url => url,
572
+ :platform => platform,
573
+ :boxname => boxname,
574
+ :url => url,
580
575
  :comment_out => comment_out
581
576
  }
582
577
  end
@@ -611,7 +606,7 @@ class Onceover
611
606
  if File.exist?(out_file)
612
607
  puts "#{'skipped'.yellow} #{Pathname.new(out_file).relative_path_from(Pathname.new(Dir.pwd)).to_s} #{'(exists)'.yellow}"
613
608
  else
614
- File.open(out_file,'w') {|f| f.write(contents)}
609
+ File.write(out_file, contents)
615
610
  puts "#{'created'.green} #{Pathname.new(out_file).relative_path_from(Pathname.new(Dir.pwd)).to_s}"
616
611
  end
617
612
  end
@@ -13,6 +13,10 @@ class Onceover
13
13
  skip_r10k_default = !(File.file?(repo.puppetfile))
14
14
  skip_r10k = opts[:skip_r10k] || skip_r10k_default
15
15
  force = opts[:force] || false
16
+ # Only attempt to resolve vendored modules if configured to do so
17
+ auto_vendored = opts[:auto_vendored] || false
18
+
19
+ require 'onceover/vendored_modules' if auto_vendored
16
20
 
17
21
  if repo.tempdir == nil
18
22
  repo.tempdir = Dir.mktmpdir('r10k')
@@ -63,7 +67,11 @@ class Onceover
63
67
  # add to list of files copied to cache by onceover
64
68
  onceover_manifest << relative_source
65
69
 
66
- if File.directory? source
70
+ if File.symlink?(source)
71
+ # Handle symlinks
72
+ link_target = File.readlink(source) # Get the target of the symlink
73
+ FileUtils.ln_s link_target, target, force: true # Create symlink at target
74
+ elsif File.directory? source
67
75
  Find.prune if excluded_dirs.include? source
68
76
  FileUtils.mkdir target
69
77
  else
@@ -89,8 +97,27 @@ class Onceover
89
97
  # Avoid touching thing if we don't need to
90
98
  if /:control_branch/.match(puppetfile_contents)
91
99
  logger.debug "replacing :control_branch mentions in the Puppetfile with #{git_branch}"
92
- new_puppetfile_contents = puppetfile_contents.gsub(/:control_branch/, "'#{git_branch}'")
93
- File.write("#{temp_controlrepo}/Puppetfile", new_puppetfile_contents)
100
+ new_puppetfile_contents = puppetfile_contents.gsub(":control_branch", "'#{git_branch}'")
101
+ File.write("#{temp_controlrepo}/Puppetfile", new_puppetfile_contents)
102
+ end
103
+
104
+ if auto_vendored
105
+ tmp_puppetfile = File.join(temp_controlrepo, 'Puppetfile')
106
+ tmp_puppetfile_contents = File.read(tmp_puppetfile)
107
+ vm = Onceover::VendoredModules.new({ repo: repo })
108
+ puppetfile = R10K::ModuleLoader::Puppetfile.new(basedir: temp_controlrepo)
109
+ vm.puppetfile_missing_vendored(puppetfile)
110
+ unless vm.missing_vendored.empty?
111
+ missing_slugs = vm.missing_vendored.map do |missing_mod|
112
+ missing_mod.keys[0]
113
+ end
114
+ logger.debug "Adding #{missing_slugs} to #{tmp_puppetfile}"
115
+ modlines = vm.missing_vendored.map do |missing_mod|
116
+ mod_slug = missing_mod.keys[0]
117
+ "mod '#{mod_slug}',\n git: '#{missing_mod[mod_slug][:git]}',\n ref: '#{missing_mod[mod_slug][:ref]}'"
118
+ end.join("\n")
119
+ File.write(tmp_puppetfile, "#{tmp_puppetfile_contents}\n# Onceover Managed Vendored Modules\n#{modlines}")
120
+ end
94
121
  end
95
122
  end
96
123
 
@@ -28,10 +28,8 @@ class Onceover
28
28
  @members = []
29
29
  else
30
30
  # Turn it into a full list
31
- member_objects = []
32
-
33
31
  # This should also handle lists that include groups
34
- members.each { |member| member_objects << Onceover::TestConfig.find_list(member) }
32
+ member_objects = members.map { |member| Onceover::TestConfig.find_list(member) }
35
33
  member_objects.flatten!
36
34
 
37
35
  # Check that they are all the same type
@@ -8,8 +8,8 @@ module Onceover::Logger
8
8
  'bright',
9
9
  :levels => {
10
10
  :debug => :cyan,
11
- :info => :green,
12
- :warn => :yellow,
11
+ :info => :green,
12
+ :warn => :yellow,
13
13
  :error => :red,
14
14
  :fatal => [:white, :on_red]
15
15
  }
@@ -18,7 +18,7 @@ module Onceover::Logger
18
18
  Logging.appenders.stdout(
19
19
  'stdout',
20
20
  :layout => Logging.layouts.pattern(
21
- :pattern => '%l\t -> %m\n',
21
+ :pattern => '%l\t -> %m\n',
22
22
  :color_scheme => 'bright'
23
23
  )
24
24
  )
data/lib/onceover/node.rb CHANGED
@@ -4,7 +4,6 @@ class Onceover
4
4
  class Node
5
5
  @@all = []
6
6
 
7
-
8
7
  attr_accessor :name
9
8
  attr_accessor :beaker_node
10
9
  attr_accessor :fact_set
@@ -44,7 +43,6 @@ class Onceover
44
43
  end
45
44
 
46
45
  @@all << self
47
-
48
46
  end
49
47
 
50
48
  def self.find(node_name)
@@ -4,7 +4,6 @@ require 'pathname'
4
4
  @repo = nil
5
5
  @config = nil
6
6
 
7
-
8
7
  desc 'Writes a `fixtures.yml` file based on the Puppetfile'
9
8
  task :generate_fixtures do
10
9
  repo = Onceover::Controlrepo.new
@@ -15,7 +14,6 @@ task :generate_fixtures do
15
14
  File.write(File.expand_path('./.fixtures.yml', repo.root), repo.fixtures)
16
15
  end
17
16
 
18
-
19
17
  desc "Modifies your `hiera.yaml` to point at the hieradata relative to its position."
20
18
  task :hiera_setup do
21
19
  repo = Onceover::Controlrepo.new
@@ -45,7 +43,6 @@ task :generate_onceover_yaml do
45
43
  puts ERB.new(onceover_yaml_template, nil, '-').result(binding)
46
44
  end
47
45
 
48
-
49
46
  task :generate_nodesets do
50
47
  warn "[DEPRECATION] #{__method__} is deprecated due to the removal of Beaker"
51
48
 
@@ -75,7 +72,7 @@ task :generate_nodesets do
75
72
  comment_out = false
76
73
  box_info = MultiJson.load(response.body)
77
74
  box_info['current_version']['providers'].each do |provider|
78
- if provider['name'] == 'virtualbox'
75
+ if provider['name'] == 'virtualbox'
79
76
  url = provider['original_url']
80
77
  end
81
78
  end
@@ -86,5 +83,13 @@ task :generate_nodesets do
86
83
  fixtures_template = File.read(File.expand_path('./nodeset.yaml.erb', template_dir))
87
84
  puts ERB.new(fixtures_template, nil, '-').result(binding)
88
85
  end
86
+ end
87
+
88
+ desc 'Create cache for vendored modules'
89
+ task :generate_vendor_cache do
90
+ require 'onceover/controlrepo'
91
+ require 'onceover/vendored_modules'
89
92
 
93
+ repo = Onceover::Controlrepo.new(debug: true)
94
+ Onceover::VendoredModules.new({ repo: repo, cachedir: File.join(repo.spec_dir, 'vendored_modules'), force_update: true })
90
95
  end
@@ -127,9 +127,9 @@ class OnceoverFormatter
127
127
 
128
128
  scanned_errors.map do |error_matches|
129
129
  {
130
- text: error_matches[0],
131
- file: calculate_relative_source(error_matches[1]),
132
- line: error_matches[2],
130
+ text: error_matches[0],
131
+ file: calculate_relative_source(error_matches[1]),
132
+ line: error_matches[2],
133
133
  column: error_matches[3],
134
134
  }
135
135
  end
@@ -223,7 +223,6 @@ class OnceoverFormatter
223
223
  def longest_group
224
224
  RSpec.configuration.world.example_groups.max { |a,b| a.description.length <=> b.description.length}.description.length
225
225
  end
226
-
227
226
  end
228
227
 
229
228
  class OnceoverFormatterParallel < OnceoverFormatter
@@ -266,9 +265,7 @@ class OnceoverFormatterParallel < OnceoverFormatter
266
265
  FileUtils.mkdir_p "#{RSpec.configuration.onceover_tempdir}/parallel"
267
266
 
268
267
  # Dump the notification to a unique file
269
- File.open("#{RSpec.configuration.onceover_tempdir}/parallel/results-#{random_string}.yaml", "w") do |file|
270
- file.write(extract_failures(notification).to_yaml)
271
- end
268
+ File.write("#{RSpec.configuration.onceover_tempdir}/parallel/results-#{random_string}.yaml", extract_failures(notification).to_yaml)
272
269
  end
273
270
 
274
271
  def output_results(directory)
@@ -280,7 +277,7 @@ class OnceoverFormatterParallel < OnceoverFormatter
280
277
  # Merge data
281
278
  roles = files.reduce({}) do |errs, file|
282
279
  # Read all files and merge them
283
- errs.merge(YAML.load(File.read(file))) {|key, oldval, newval| [oldval, newval].flatten }# rubocop:disable Security/YAMLLoad
280
+ errs.merge(YAML.load_file(file)) {|key, oldval, newval| [oldval, newval].flatten }
284
281
  end
285
282
 
286
283
  # Delete files from the disk
@@ -78,7 +78,7 @@ class Onceover
78
78
  Dir.chdir(@repo.tempdir) do
79
79
  # Disable warnings unless we are running in debug mode
80
80
  unless logger.level.zero?
81
- previous_rubyopt = ENV['RUBYOPT']
81
+ previous_rubyopt = ENV.fetch('RUBYOPT', nil)
82
82
  ENV['RUBYOPT'] = ENV['RUBYOPT'].to_s + ' -W0'
83
83
  end
84
84
 
data/lib/onceover/test.rb CHANGED
@@ -12,9 +12,8 @@ class Onceover
12
12
  # it will then detect them and expand them out into their respective objects so that
13
13
  # we just end up with a list of nodes and classes
14
14
  def initialize(on_this, test_this, test_config)
15
-
16
15
  @default_test_config = {
17
- 'check_idempotency' => true,
16
+ 'check_idempotency' => true,
18
17
  'runs_before_idempotency' => 1
19
18
  }
20
19
 
@@ -72,7 +71,7 @@ class Onceover
72
71
  if classes.count > 1
73
72
  class_msg = "#{classes.count}_classes"
74
73
  else
75
- class_msg = classes[0].name.gsub(/::/,'__')
74
+ class_msg = classes[0].name.gsub("::",'__')
76
75
  end
77
76
 
78
77
  if nodes.count > 1
@@ -282,9 +282,9 @@ class Onceover
282
282
  def run_filters(tests)
283
283
  # All of this needs to be applied AFTER deduplication but BEFORE writing
284
284
  filters = {
285
- 'tags' => @filter_tags,
285
+ 'tags' => @filter_tags,
286
286
  'classes' => @filter_classes,
287
- 'nodes' => @filter_nodes
287
+ 'nodes' => @filter_nodes
288
288
  }
289
289
  filters.each do |method, filter_list|
290
290
  if filter_list