chef 12.13.37 → 12.14.60

Sign up to get free protection for your applications and to get access to all the features.
Files changed (338) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +48 -95
  3. data/Gemfile +6 -1
  4. data/README.md +9 -11
  5. data/VERSION +1 -1
  6. data/acceptance/.shared/kitchen_acceptance/.kitchen.ec2.yml +0 -1
  7. data/acceptance/Gemfile +4 -7
  8. data/acceptance/Gemfile.lock +59 -92
  9. data/acceptance/basics/test/integration/helpers/serverspec/Gemfile +8 -0
  10. data/acceptance/data-collector/test/integration/helpers/serverspec/Gemfile +8 -0
  11. data/acceptance/fips/test/integration/fips-integration/serverspec/Gemfile +6 -0
  12. data/acceptance/fips/test/integration/fips-unit-functional/serverspec/Gemfile +4 -0
  13. data/chef.gemspec +3 -2
  14. data/lib/chef/application/client.rb +4 -4
  15. data/lib/chef/application/solo.rb +2 -2
  16. data/lib/chef/chef_fs/command_line.rb +36 -34
  17. data/lib/chef/chef_fs/data_handler/data_handler_base.rb +2 -2
  18. data/lib/chef/chef_fs/file_pattern.rb +1 -1
  19. data/lib/chef/chef_fs/file_system.rb +139 -137
  20. data/lib/chef/chef_fs/parallelizer/parallel_enumerable.rb +2 -6
  21. data/lib/chef/cookbook/cookbook_version_loader.rb +27 -22
  22. data/lib/chef/cookbook/metadata.rb +1 -1
  23. data/lib/chef/cookbook/synchronizer.rb +3 -3
  24. data/lib/chef/cookbook_site_streaming_uploader.rb +3 -3
  25. data/lib/chef/cookbook_uploader.rb +1 -1
  26. data/lib/chef/cookbook_version.rb +6 -6
  27. data/lib/chef/dsl/powershell.rb +1 -1
  28. data/lib/chef/event_dispatch/base.rb +2 -2
  29. data/lib/chef/exceptions.rb +1 -1
  30. data/lib/chef/file_cache.rb +1 -1
  31. data/lib/chef/formatters/base.rb +2 -2
  32. data/lib/chef/formatters/doc.rb +2 -2
  33. data/lib/chef/http.rb +48 -18
  34. data/lib/chef/http/auth_credentials.rb +1 -1
  35. data/lib/chef/http/basic_client.rb +11 -2
  36. data/lib/chef/http/socketless_chef_zero_client.rb +2 -2
  37. data/lib/chef/key.rb +55 -56
  38. data/lib/chef/knife.rb +70 -61
  39. data/lib/chef/knife/client_delete.rb +2 -2
  40. data/lib/chef/knife/cookbook_bulk_delete.rb +1 -1
  41. data/lib/chef/knife/cookbook_show.rb +1 -1
  42. data/lib/chef/knife/core/gem_glob_loader.rb +3 -3
  43. data/lib/chef/knife/search.rb +2 -2
  44. data/lib/chef/knife/ssh.rb +19 -21
  45. data/lib/chef/knife/status.rb +2 -2
  46. data/lib/chef/mixin/command/unix.rb +2 -2
  47. data/lib/chef/mixin/powershell_type_coercions.rb +1 -1
  48. data/lib/chef/mixin/properties.rb +3 -0
  49. data/lib/chef/mixin/securable.rb +2 -2
  50. data/lib/chef/mixin/shell_out.rb +30 -0
  51. data/lib/chef/mixin/uris.rb +2 -1
  52. data/lib/chef/mixin/windows_architecture_helper.rb +3 -4
  53. data/lib/chef/monkey_patches/webrick-utils.rb +2 -2
  54. data/lib/chef/monologger.rb +1 -1
  55. data/lib/chef/node.rb +2 -2
  56. data/lib/chef/node/attribute.rb +3 -3
  57. data/lib/chef/platform/provider_mapping.rb +5 -2
  58. data/lib/chef/property.rb +14 -3
  59. data/lib/chef/provider/apt_repository.rb +3 -7
  60. data/lib/chef/provider/apt_update.rb +4 -6
  61. data/lib/chef/provider/cron.rb +1 -2
  62. data/lib/chef/provider/dsc_script.rb +4 -4
  63. data/lib/chef/provider/group/usermod.rb +1 -1
  64. data/lib/chef/provider/link.rb +10 -3
  65. data/lib/chef/provider/osx_profile.rb +10 -10
  66. data/lib/chef/provider/package.rb +2 -12
  67. data/lib/chef/provider/package/rubygems.rb +17 -16
  68. data/lib/chef/provider/package/windows.rb +2 -0
  69. data/lib/chef/provider/package/windows/exe.rb +1 -1
  70. data/lib/chef/provider/package/windows/registry_uninstall_entry.rb +0 -2
  71. data/lib/chef/provider/package/yum/rpm_utils.rb +8 -8
  72. data/lib/chef/provider/package/yum/yum_cache.rb +1 -1
  73. data/lib/chef/provider/remote_file/ftp.rb +2 -2
  74. data/lib/chef/provider/remote_file/sftp.rb +2 -2
  75. data/lib/chef/provider/service/debian.rb +2 -2
  76. data/lib/chef/provider/service/simple.rb +4 -3
  77. data/lib/chef/provider/service/solaris.rb +1 -1
  78. data/lib/chef/provider/service/systemd.rb +2 -2
  79. data/lib/chef/provider/service/upstart.rb +8 -5
  80. data/lib/chef/provider/support/yum_repo.erb +125 -0
  81. data/lib/chef/provider/systemd_unit.rb +11 -2
  82. data/lib/chef/provider/template_finder.rb +1 -1
  83. data/lib/chef/provider/user.rb +20 -16
  84. data/lib/chef/provider/user/aix.rb +5 -2
  85. data/lib/chef/provider/user/dscl.rb +1 -0
  86. data/lib/chef/provider/user/linux.rb +128 -0
  87. data/lib/chef/provider/user/pw.rb +2 -1
  88. data/lib/chef/provider/user/solaris.rb +3 -2
  89. data/lib/chef/provider/user/useradd.rb +5 -4
  90. data/lib/chef/provider/user/windows.rb +1 -1
  91. data/lib/chef/provider/windows_script.rb +5 -2
  92. data/lib/chef/provider/yum_repository.rb +121 -0
  93. data/lib/chef/providers.rb +4 -2
  94. data/lib/chef/resource.rb +7 -9
  95. data/lib/chef/resource/conditional.rb +9 -1
  96. data/lib/chef/resource/launchd.rb +1 -1
  97. data/lib/chef/resource/user.rb +3 -3
  98. data/lib/chef/resource/user/aix_user.rb +31 -0
  99. data/lib/chef/resource/user/dscl_user.rb +31 -0
  100. data/lib/chef/resource/user/linux_user.rb +51 -0
  101. data/lib/chef/resource/user/pw_user.rb +31 -0
  102. data/lib/chef/resource/user/solaris_user.rb +31 -0
  103. data/lib/chef/resource/user/windows_user.rb +31 -0
  104. data/lib/chef/resource/yum_package.rb +13 -12
  105. data/lib/chef/resource/yum_repository.rb +76 -0
  106. data/lib/chef/resource_builder.rb +1 -1
  107. data/lib/chef/resource_collection/stepable_iterator.rb +1 -3
  108. data/lib/chef/resource_reporter.rb +5 -5
  109. data/lib/chef/resources.rb +7 -0
  110. data/lib/chef/run_context.rb +5 -3
  111. data/lib/chef/run_context/cookbook_compiler.rb +3 -2
  112. data/lib/chef/run_list.rb +2 -2
  113. data/lib/chef/search/query.rb +11 -8
  114. data/lib/chef/shell/ext.rb +2 -2
  115. data/lib/chef/shell/shell_session.rb +1 -1
  116. data/lib/chef/util/dsc/configuration_generator.rb +1 -1
  117. data/lib/chef/util/powershell/cmdlet.rb +5 -2
  118. data/lib/chef/util/selinux.rb +1 -1
  119. data/lib/chef/version.rb +1 -1
  120. data/lib/chef/version_class.rb +2 -2
  121. data/lib/chef/version_constraint.rb +2 -2
  122. data/lib/chef/win32/api/error.rb +2 -2
  123. data/lib/chef/win32/api/net.rb +1 -1
  124. data/lib/chef/win32/eventlog.rb +1 -1
  125. data/lib/chef/win32/net.rb +1 -1
  126. data/lib/chef/win32/security/sid.rb +1 -1
  127. data/spec/functional/assets/testchefsubsys +2 -3
  128. data/spec/functional/event_loggers/windows_eventlog_spec.rb +11 -8
  129. data/spec/functional/file_content_management/deploy_strategies_spec.rb +1 -1
  130. data/spec/functional/http/simple_spec.rb +2 -2
  131. data/spec/functional/knife/cookbook_delete_spec.rb +5 -5
  132. data/spec/functional/knife/exec_spec.rb +6 -6
  133. data/spec/functional/knife/ssh_spec.rb +4 -4
  134. data/spec/functional/notifications_spec.rb +2 -2
  135. data/spec/functional/provider/whyrun_safe_ruby_block_spec.rb +2 -2
  136. data/spec/functional/rebooter_spec.rb +5 -5
  137. data/spec/functional/resource/bash_spec.rb +2 -2
  138. data/spec/functional/resource/deploy_revision_spec.rb +1 -1
  139. data/spec/functional/resource/dpkg_package_spec.rb +2 -2
  140. data/spec/functional/resource/dsc_resource_spec.rb +5 -5
  141. data/spec/functional/resource/dsc_script_spec.rb +27 -22
  142. data/spec/functional/resource/env_spec.rb +4 -4
  143. data/spec/functional/resource/execute_spec.rb +4 -4
  144. data/spec/functional/resource/group_spec.rb +20 -8
  145. data/spec/functional/resource/link_spec.rb +34 -0
  146. data/spec/functional/resource/ohai_spec.rb +6 -6
  147. data/spec/functional/resource/reboot_spec.rb +2 -2
  148. data/spec/functional/resource/remote_file_spec.rb +16 -7
  149. data/spec/functional/resource/user/dscl_spec.rb +3 -3
  150. data/spec/functional/resource/user/useradd_spec.rb +32 -26
  151. data/spec/functional/resource/windows_service_spec.rb +15 -15
  152. data/spec/functional/rest_spec.rb +2 -2
  153. data/spec/functional/run_lock_spec.rb +9 -9
  154. data/spec/functional/tiny_server_spec.rb +9 -8
  155. data/spec/functional/win32/crypto_spec.rb +1 -1
  156. data/spec/functional/win32/security_spec.rb +8 -8
  157. data/spec/integration/client/client_spec.rb +6 -4
  158. data/spec/integration/knife/chef_repo_path_spec.rb +70 -1
  159. data/spec/integration/knife/upload_spec.rb +1 -1
  160. data/spec/integration/recipes/lwrp_inline_resources_spec.rb +6 -6
  161. data/spec/integration/recipes/noop_resource_spec.rb +4 -4
  162. data/spec/integration/recipes/provider_choice.rb +3 -3
  163. data/spec/integration/recipes/recipe_dsl_spec.rb +318 -317
  164. data/spec/integration/recipes/resource_action_spec.rb +50 -54
  165. data/spec/integration/recipes/resource_converge_if_changed_spec.rb +34 -34
  166. data/spec/integration/recipes/resource_load_spec.rb +24 -24
  167. data/spec/integration/solo/solo_spec.rb +21 -30
  168. data/spec/scripts/ssl-serve.rb +1 -1
  169. data/spec/spec_helper.rb +1 -0
  170. data/spec/stress/win32/security_spec.rb +4 -4
  171. data/spec/support/chef_helpers.rb +22 -0
  172. data/spec/support/platform_helpers.rb +5 -1
  173. data/spec/support/shared/context/client.rb +3 -2
  174. data/spec/support/shared/functional/file_resource.rb +5 -4
  175. data/spec/support/shared/functional/http.rb +16 -16
  176. data/spec/support/shared/functional/securable_resource.rb +5 -5
  177. data/spec/support/shared/functional/win32_service.rb +5 -7
  178. data/spec/support/shared/integration/app_server_support.rb +1 -3
  179. data/spec/support/shared/integration/knife_support.rb +0 -2
  180. data/spec/support/shared/shared_examples.rb +2 -2
  181. data/spec/support/shared/unit/api_versioning.rb +2 -2
  182. data/spec/support/shared/unit/application_dot_d.rb +9 -6
  183. data/spec/support/shared/unit/provider/file.rb +2 -2
  184. data/spec/support/shared/unit/provider/useradd_based_user_provider.rb +49 -80
  185. data/spec/support/shared/unit/resource/static_provider_resolution.rb +2 -2
  186. data/spec/support/shared/unit/script_resource.rb +4 -4
  187. data/spec/support/shared/unit/user_and_client_shared.rb +4 -4
  188. data/spec/tiny_server.rb +51 -66
  189. data/spec/unit/api_client_v1_spec.rb +2 -2
  190. data/spec/unit/application_spec.rb +1 -1
  191. data/spec/unit/audit/audit_event_proxy_spec.rb +34 -27
  192. data/spec/unit/audit/audit_reporter_spec.rb +32 -23
  193. data/spec/unit/audit/control_group_data_spec.rb +19 -14
  194. data/spec/unit/chef_class_spec.rb +1 -1
  195. data/spec/unit/chef_fs/data_handler/group_handler_spec.rb +1 -1
  196. data/spec/unit/chef_fs/diff_spec.rb +4 -4
  197. data/spec/unit/chef_fs/file_system/operation_failed_error_spec.rb +4 -4
  198. data/spec/unit/chef_fs/file_system_spec.rb +2 -2
  199. data/spec/unit/chef_fs/parallelizer.rb +5 -7
  200. data/spec/unit/cookbook/metadata_spec.rb +98 -98
  201. data/spec/unit/cookbook/synchronizer_spec.rb +7 -0
  202. data/spec/unit/cookbook_loader_spec.rb +24 -24
  203. data/spec/unit/cookbook_version_file_specificity_spec.rb +8 -8
  204. data/spec/unit/daemon_spec.rb +1 -1
  205. data/spec/unit/data_bag_item_spec.rb +18 -18
  206. data/spec/unit/data_bag_spec.rb +2 -2
  207. data/spec/unit/data_collector/messages/helpers_spec.rb +9 -9
  208. data/spec/unit/data_collector/messages_spec.rb +2 -2
  209. data/spec/unit/data_collector_spec.rb +19 -19
  210. data/spec/unit/dsl/audit_spec.rb +3 -3
  211. data/spec/unit/dsl/data_query_spec.rb +3 -2
  212. data/spec/unit/dsl/declare_resource_spec.rb +10 -10
  213. data/spec/unit/encrypted_data_bag_item/check_encrypted_spec.rb +3 -2
  214. data/spec/unit/encrypted_data_bag_item_spec.rb +3 -2
  215. data/spec/unit/environment_spec.rb +6 -6
  216. data/spec/unit/event_dispatch/dispatcher_spec.rb +2 -2
  217. data/spec/unit/file_access_control_spec.rb +3 -3
  218. data/spec/unit/file_content_management/tempfile_spec.rb +2 -2
  219. data/spec/unit/formatters/error_inspectors/api_error_formatting_spec.rb +2 -2
  220. data/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb +2 -2
  221. data/spec/unit/http/basic_client_spec.rb +20 -0
  222. data/spec/unit/http/validate_content_length_spec.rb +8 -8
  223. data/spec/unit/http_spec.rb +14 -0
  224. data/spec/unit/knife/bootstrap/chef_vault_handler_spec.rb +2 -2
  225. data/spec/unit/knife/bootstrap/client_builder_spec.rb +2 -2
  226. data/spec/unit/knife/bootstrap_spec.rb +8 -6
  227. data/spec/unit/knife/client_bulk_delete_spec.rb +8 -8
  228. data/spec/unit/knife/client_edit_spec.rb +2 -2
  229. data/spec/unit/knife/configure_client_spec.rb +2 -2
  230. data/spec/unit/knife/cookbook_metadata_spec.rb +4 -4
  231. data/spec/unit/knife/cookbook_site_install_spec.rb +6 -5
  232. data/spec/unit/knife/cookbook_site_share_spec.rb +2 -2
  233. data/spec/unit/knife/core/hashed_command_loader_spec.rb +5 -4
  234. data/spec/unit/knife/core/node_editor_spec.rb +3 -3
  235. data/spec/unit/knife/core/ui_spec.rb +2 -2
  236. data/spec/unit/knife/data_bag_from_file_spec.rb +4 -3
  237. data/spec/unit/knife/data_bag_show_spec.rb +3 -2
  238. data/spec/unit/knife/key_create_spec.rb +14 -14
  239. data/spec/unit/knife/key_delete_spec.rb +2 -2
  240. data/spec/unit/knife/key_edit_spec.rb +16 -16
  241. data/spec/unit/knife/key_list_spec.rb +6 -6
  242. data/spec/unit/knife/key_show_spec.rb +4 -4
  243. data/spec/unit/knife/status_spec.rb +3 -2
  244. data/spec/unit/knife/user_create_spec.rb +4 -4
  245. data/spec/unit/knife_spec.rb +7 -6
  246. data/spec/unit/lwrp_spec.rb +6 -6
  247. data/spec/unit/mixin/api_version_request_handling_spec.rb +2 -2
  248. data/spec/unit/mixin/command_spec.rb +17 -14
  249. data/spec/unit/mixin/deprecation_spec.rb +1 -1
  250. data/spec/unit/mixin/homebrew_user_spec.rb +2 -2
  251. data/spec/unit/mixin/params_validate_spec.rb +53 -52
  252. data/spec/unit/mixin/powershell_out_spec.rb +2 -2
  253. data/spec/unit/mixin/powershell_type_coercions_spec.rb +2 -2
  254. data/spec/unit/mixin/shell_out_spec.rb +1 -1
  255. data/spec/unit/mixin/xml_escape_spec.rb +3 -3
  256. data/spec/unit/node_spec.rb +2 -2
  257. data/spec/unit/platform/query_helpers_spec.rb +3 -3
  258. data/spec/unit/property_spec.rb +4 -4
  259. data/spec/unit/provider/cookbook_file_spec.rb +4 -4
  260. data/spec/unit/provider/cron/unix_spec.rb +4 -4
  261. data/spec/unit/provider/cron_spec.rb +2 -2
  262. data/spec/unit/provider/deploy_spec.rb +8 -8
  263. data/spec/unit/provider/dsc_resource_spec.rb +11 -10
  264. data/spec/unit/provider/dsc_script_spec.rb +9 -9
  265. data/spec/unit/provider/env/windows_spec.rb +8 -8
  266. data/spec/unit/provider/file/content_spec.rb +6 -6
  267. data/spec/unit/provider/file_spec.rb +4 -4
  268. data/spec/unit/provider/launchd_spec.rb +2 -1
  269. data/spec/unit/provider/link_spec.rb +155 -0
  270. data/spec/unit/provider/mount/mount_spec.rb +5 -5
  271. data/spec/unit/provider/mount/solaris_spec.rb +48 -48
  272. data/spec/unit/provider/osx_profile_spec.rb +6 -0
  273. data/spec/unit/provider/package/chocolatey_spec.rb +4 -4
  274. data/spec/unit/provider/package/freebsd/port_spec.rb +4 -4
  275. data/spec/unit/provider/package/rubygems_spec.rb +50 -44
  276. data/spec/unit/provider/package/windows/exe_spec.rb +9 -0
  277. data/spec/unit/provider/package/yum_spec.rb +61 -60
  278. data/spec/unit/provider/package_spec.rb +2 -2
  279. data/spec/unit/provider/powershell_script_spec.rb +4 -4
  280. data/spec/unit/provider/remote_directory_spec.rb +1 -1
  281. data/spec/unit/provider/remote_file/ftp_spec.rb +4 -4
  282. data/spec/unit/provider/remote_file/local_file_spec.rb +4 -2
  283. data/spec/unit/provider/remote_file/sftp_spec.rb +4 -4
  284. data/spec/unit/provider/remote_file_spec.rb +4 -4
  285. data/spec/unit/provider/script_spec.rb +4 -4
  286. data/spec/unit/provider/service/debian_service_spec.rb +4 -4
  287. data/spec/unit/provider/service/freebsd_service_spec.rb +12 -8
  288. data/spec/unit/provider/service/openbsd_service_spec.rb +12 -8
  289. data/spec/unit/provider/service/systemd_service_spec.rb +4 -4
  290. data/spec/unit/provider/service/upstart_service_spec.rb +27 -12
  291. data/spec/unit/provider/service/windows_spec.rb +10 -10
  292. data/spec/unit/provider/systemd_unit_spec.rb +2 -2
  293. data/spec/unit/provider/template/content_spec.rb +8 -8
  294. data/spec/unit/provider/template_spec.rb +8 -8
  295. data/spec/unit/provider/user/dscl_spec.rb +51 -51
  296. data/spec/unit/provider/user/linux_spec.rb +76 -0
  297. data/spec/unit/provider/user/pw_spec.rb +3 -6
  298. data/spec/unit/provider/user/solaris_spec.rb +5 -5
  299. data/spec/unit/provider/user/windows_spec.rb +3 -3
  300. data/spec/unit/provider/user_spec.rb +2 -2
  301. data/spec/unit/provider/yum_repository_spec.rb +35 -0
  302. data/spec/unit/provider_resolver_spec.rb +306 -264
  303. data/spec/unit/recipe_spec.rb +8 -7
  304. data/spec/unit/resource/apt_repository_spec.rb +4 -4
  305. data/spec/unit/resource/apt_update_spec.rb +4 -4
  306. data/spec/unit/resource/conditional_spec.rb +46 -0
  307. data/spec/unit/resource/dsc_resource_spec.rb +8 -8
  308. data/spec/unit/resource/dsc_script_spec.rb +4 -4
  309. data/spec/unit/resource/freebsd_package_spec.rb +6 -6
  310. data/spec/unit/resource/launchd_spec.rb +3 -2
  311. data/spec/unit/resource/osx_profile_spec.rb +3 -2
  312. data/spec/unit/resource/remote_file_spec.rb +6 -6
  313. data/spec/unit/resource/service_spec.rb +14 -14
  314. data/spec/unit/resource/user_spec.rb +1 -1
  315. data/spec/unit/resource/yum_repository_spec.rb +49 -0
  316. data/spec/unit/resource_collection_spec.rb +4 -4
  317. data/spec/unit/resource_definition_spec.rb +11 -11
  318. data/spec/unit/resource_reporter_spec.rb +4 -4
  319. data/spec/unit/resource_resolver_spec.rb +6 -6
  320. data/spec/unit/resource_spec.rb +36 -16
  321. data/spec/unit/run_context/child_run_context_spec.rb +4 -4
  322. data/spec/unit/run_context/cookbook_compiler_spec.rb +43 -1
  323. data/spec/unit/run_context_spec.rb +8 -8
  324. data/spec/unit/run_list/run_list_expansion_spec.rb +2 -2
  325. data/spec/unit/runner_spec.rb +2 -2
  326. data/spec/unit/search/query_spec.rb +15 -14
  327. data/spec/unit/user_v1_spec.rb +8 -8
  328. data/spec/unit/util/dsc/configuration_generator_spec.rb +12 -12
  329. data/spec/unit/util/dsc/local_configuration_manager_spec.rb +12 -9
  330. data/spec/unit/util/dsc/resource_store.rb +8 -6
  331. data/spec/unit/util/editor_spec.rb +6 -6
  332. data/spec/unit/util/powershell/cmdlet_spec.rb +10 -10
  333. data/tasks/bin/bundle-platform +1 -0
  334. data/tasks/bin/bundler_patch.rb +27 -0
  335. data/tasks/cbgb.rb +2 -2
  336. data/tasks/maintainers.rb +2 -2
  337. metadata +37 -8
  338. data/spec/unit/provider/user/useradd_spec.rb +0 -51
@@ -0,0 +1,8 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Until https://github.com/test-kitchen/busser-serverspec/pull/42 is merged and
4
+ # released, we need to include rake and rspec-core in the Gemfile
5
+ gem "rake"
6
+ gem "rspec-core"
7
+ gem "busser-serverspec"
8
+ gem "serverspec"
@@ -0,0 +1,8 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Until https://github.com/test-kitchen/busser-serverspec/pull/42 is merged and
4
+ # released, we need to include rake and rspec-core in the Gemfile
5
+ gem "rake"
6
+ gem "rspec-core"
7
+ gem "busser-serverspec"
8
+ gem "serverspec"
@@ -1,3 +1,9 @@
1
1
  source "https://rubygems.org"
2
2
 
3
+ # Until https://github.com/test-kitchen/busser-serverspec/pull/42 is merged and
4
+ # released, we need to include rake and rspec-core in the Gemfile
5
+ gem "rake"
6
+ gem "rspec-core"
7
+ gem "busser-serverspec"
8
+ gem "serverspec"
3
9
  gem "mixlib-shellout"
@@ -1,3 +1,7 @@
1
1
  source "https://rubygems.org"
2
2
 
3
+ # Until https://github.com/test-kitchen/busser-serverspec/pull/42 is merged and
4
+ # released, we need to include rake and rspec-core in the Gemfile
5
+ gem "rake"
6
+ gem "rspec-core"
3
7
  gem "mixlib-shellout"
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
13
13
  s.email = "adam@chef.io"
14
14
  s.homepage = "http://www.chef.io"
15
15
 
16
- s.required_ruby_version = ">= 2.1.0"
16
+ s.required_ruby_version = ">= 2.2.0"
17
17
 
18
18
  s.add_dependency "chef-config", "= #{Chef::VERSION}"
19
19
 
@@ -32,10 +32,11 @@ Gem::Specification.new do |s|
32
32
  s.add_dependency "erubis", "~> 2.7"
33
33
  s.add_dependency "diff-lcs", "~> 1.2", ">= 1.2.4"
34
34
 
35
- s.add_dependency "chef-zero", "~> 4.8"
35
+ s.add_dependency "chef-zero", ">= 4.8"
36
36
 
37
37
  s.add_dependency "plist", "~> 3.2"
38
38
  s.add_dependency "iniparse", "~> 1.4"
39
+ s.add_dependency "addressable"
39
40
 
40
41
  # Audit mode requires these, so they are non-developmental dependencies now
41
42
  %w{rspec-core rspec-expectations rspec-mocks}.each { |gem| s.add_dependency gem, "~> 3.5" }
@@ -204,9 +204,9 @@ class Chef::Application::Client < Chef::Application
204
204
  :description => "Replace current run list with specified items for a single run",
205
205
  :proc => lambda {|items|
206
206
  items = items.split(",")
207
- items.compact.map {|item|
207
+ items.compact.map do |item|
208
208
  Chef::RunList::RunListItem.new(item)
209
- }
209
+ end
210
210
  }
211
211
 
212
212
  option :runlist,
@@ -215,9 +215,9 @@ class Chef::Application::Client < Chef::Application
215
215
  :description => "Permanently replace current run list with specified items",
216
216
  :proc => lambda {|items|
217
217
  items = items.split(",")
218
- items.compact.map {|item|
218
+ items.compact.map do |item|
219
219
  Chef::RunList::RunListItem.new(item)
220
- }
220
+ end
221
221
  }
222
222
  option :why_run,
223
223
  :short => "-W",
@@ -168,9 +168,9 @@ class Chef::Application::Solo < Chef::Application
168
168
  :description => "Replace current run list with specified items",
169
169
  :proc => lambda {|items|
170
170
  items = items.split(",")
171
- items.compact.map {|item|
171
+ items.compact.map do |item|
172
172
  Chef::RunList::RunListItem.new(item)
173
- }
173
+ end
174
174
  }
175
175
 
176
176
  option :client_fork,
@@ -242,48 +242,50 @@ class Chef
242
242
  return [ [ :error, old_entry, new_entry, nil, nil, e ] ]
243
243
  end
244
244
 
245
- private
245
+ class << self
246
+ private
246
247
 
247
- def self.sort_keys(json_object)
248
- if json_object.is_a?(Array)
249
- json_object.map { |o| sort_keys(o) }
250
- elsif json_object.is_a?(Hash)
251
- new_hash = {}
252
- json_object.keys.sort.each { |key| new_hash[key] = sort_keys(json_object[key]) }
253
- new_hash
254
- else
255
- json_object
248
+ def sort_keys(json_object)
249
+ if json_object.is_a?(Array)
250
+ json_object.map { |o| sort_keys(o) }
251
+ elsif json_object.is_a?(Hash)
252
+ new_hash = {}
253
+ json_object.keys.sort.each { |key| new_hash[key] = sort_keys(json_object[key]) }
254
+ new_hash
255
+ else
256
+ json_object
257
+ end
256
258
  end
257
- end
258
259
 
259
- def self.canonicalize_json(json_text)
260
- parsed_json = Chef::JSONCompat.parse(json_text)
261
- sorted_json = sort_keys(parsed_json)
262
- Chef::JSONCompat.to_json_pretty(sorted_json)
263
- end
264
-
265
- def self.diff_text(old_path, new_path, old_value, new_value)
266
- # Copy to tempfiles before diffing
267
- # TODO don't copy things that are already in files! Or find an in-memory diff algorithm
268
- begin
269
- new_tempfile = Tempfile.new("new")
270
- new_tempfile.write(new_value)
271
- new_tempfile.close
260
+ def canonicalize_json(json_text)
261
+ parsed_json = Chef::JSONCompat.parse(json_text)
262
+ sorted_json = sort_keys(parsed_json)
263
+ Chef::JSONCompat.to_json_pretty(sorted_json)
264
+ end
272
265
 
266
+ def diff_text(old_path, new_path, old_value, new_value)
267
+ # Copy to tempfiles before diffing
268
+ # TODO don't copy things that are already in files! Or find an in-memory diff algorithm
273
269
  begin
274
- old_tempfile = Tempfile.new("old")
275
- old_tempfile.write(old_value)
276
- old_tempfile.close
270
+ new_tempfile = Tempfile.new("new")
271
+ new_tempfile.write(new_value)
272
+ new_tempfile.close
277
273
 
278
- result = Chef::Util::Diff.new.udiff(old_tempfile.path, new_tempfile.path)
279
- result = result.gsub(/^--- #{old_tempfile.path}/, "--- #{old_path}")
280
- result = result.gsub(/^\+\+\+ #{new_tempfile.path}/, "+++ #{new_path}")
281
- result
274
+ begin
275
+ old_tempfile = Tempfile.new("old")
276
+ old_tempfile.write(old_value)
277
+ old_tempfile.close
278
+
279
+ result = Chef::Util::Diff.new.udiff(old_tempfile.path, new_tempfile.path)
280
+ result = result.gsub(/^--- #{old_tempfile.path}/, "--- #{old_path}")
281
+ result = result.gsub(/^\+\+\+ #{new_tempfile.path}/, "+++ #{new_path}")
282
+ result
283
+ ensure
284
+ old_tempfile.close!
285
+ end
282
286
  ensure
283
- old_tempfile.close!
287
+ new_tempfile.close!
284
288
  end
285
- ensure
286
- new_tempfile.close!
287
289
  end
288
290
  end
289
291
  end
@@ -93,7 +93,7 @@ class Chef
93
93
  # name to recipe[name]. Then calls uniq on the result.
94
94
  #
95
95
  def normalize_run_list(run_list)
96
- run_list.map {|item|
96
+ run_list.map do |item|
97
97
  case item.to_s
98
98
  when /^recipe\[.*\]$/
99
99
  item # explicit recipe
@@ -102,7 +102,7 @@ class Chef
102
102
  else
103
103
  "recipe[#{item}]"
104
104
  end
105
- }.uniq
105
+ end.uniq
106
106
  end
107
107
 
108
108
  #
@@ -160,7 +160,7 @@ class Chef
160
160
  pattern
161
161
  end
162
162
 
163
- private
163
+ private
164
164
 
165
165
  def regexp
166
166
  calculate
@@ -68,7 +68,7 @@ class Chef
68
68
  list_from(exact_child, &block)
69
69
  end
70
70
 
71
- # Otherwise, go through all children and find any matches
71
+ # Otherwise, go through all children and find any matches
72
72
  elsif entry.dir?
73
73
  results = Parallelizer.parallelize(entry.children) { |child| Chef::ChefFS::FileSystem.list(child, pattern) }
74
74
  results.flatten(1).each(&block)
@@ -257,172 +257,174 @@ class Chef
257
257
  [ are_same, a_value, b_value ]
258
258
  end
259
259
 
260
- private
261
-
262
- # Copy two entries (could be files or dirs)
263
- def self.copy_entries(src_entry, dest_entry, new_dest_parent, recurse_depth, options, ui, format_path)
264
- # A NOTE about this algorithm:
265
- # There are cases where this algorithm does too many network requests.
266
- # knife upload with a specific filename will first check if the file
267
- # exists (a "dir" in the parent) before deciding whether to POST or
268
- # PUT it. If we just tried PUT (or POST) and then tried the other if
269
- # the conflict failed, we wouldn't need to check existence.
270
- # On the other hand, we may already have DONE the request, in which
271
- # case we shouldn't waste time trying PUT if we know the file doesn't
272
- # exist.
273
- # Will need to decide how that works with checksums, though.
274
- error = false
275
- begin
276
- dest_path = format_path.call(dest_entry) if ui
277
- src_path = format_path.call(src_entry) if ui
278
- if !src_entry.exists?
279
- if options[:purge]
280
- # If we would not have uploaded it, we will not purge it.
281
- if src_entry.parent.can_have_child?(dest_entry.name, dest_entry.dir?)
282
- if options[:dry_run]
283
- ui.output "Would delete #{dest_path}" if ui
284
- else
285
- begin
286
- dest_entry.delete(true)
287
- ui.output "Deleted extra entry #{dest_path} (purge is on)" if ui
288
- rescue Chef::ChefFS::FileSystem::NotFoundError
289
- ui.output "Entry #{dest_path} does not exist. Nothing to do. (purge is on)" if ui
260
+ class << self
261
+ private
262
+
263
+ # Copy two entries (could be files or dirs)
264
+ def copy_entries(src_entry, dest_entry, new_dest_parent, recurse_depth, options, ui, format_path)
265
+ # A NOTE about this algorithm:
266
+ # There are cases where this algorithm does too many network requests.
267
+ # knife upload with a specific filename will first check if the file
268
+ # exists (a "dir" in the parent) before deciding whether to POST or
269
+ # PUT it. If we just tried PUT (or POST) and then tried the other if
270
+ # the conflict failed, we wouldn't need to check existence.
271
+ # On the other hand, we may already have DONE the request, in which
272
+ # case we shouldn't waste time trying PUT if we know the file doesn't
273
+ # exist.
274
+ # Will need to decide how that works with checksums, though.
275
+ error = false
276
+ begin
277
+ dest_path = format_path.call(dest_entry) if ui
278
+ src_path = format_path.call(src_entry) if ui
279
+ if !src_entry.exists?
280
+ if options[:purge]
281
+ # If we would not have uploaded it, we will not purge it.
282
+ if src_entry.parent.can_have_child?(dest_entry.name, dest_entry.dir?)
283
+ if options[:dry_run]
284
+ ui.output "Would delete #{dest_path}" if ui
285
+ else
286
+ begin
287
+ dest_entry.delete(true)
288
+ ui.output "Deleted extra entry #{dest_path} (purge is on)" if ui
289
+ rescue Chef::ChefFS::FileSystem::NotFoundError
290
+ ui.output "Entry #{dest_path} does not exist. Nothing to do. (purge is on)" if ui
291
+ end
290
292
  end
291
- end
292
- else
293
- ui.output ("Not deleting extra entry #{dest_path} (purge is off)") if ui
294
- end
295
- end
296
-
297
- elsif !dest_entry.exists?
298
- if new_dest_parent.can_have_child?(src_entry.name, src_entry.dir?)
299
- # If the entry can do a copy directly from filesystem, do that.
300
- if new_dest_parent.respond_to?(:create_child_from)
301
- if options[:dry_run]
302
- ui.output "Would create #{dest_path}" if ui
303
293
  else
304
- new_dest_parent.create_child_from(src_entry)
305
- ui.output "Created #{dest_path}" if ui
294
+ ui.output ("Not deleting extra entry #{dest_path} (purge is off)") if ui
306
295
  end
307
- return
308
296
  end
309
297
 
310
- if src_entry.dir?
311
- if options[:dry_run]
312
- ui.output "Would create #{dest_path}" if ui
313
- new_dest_dir = new_dest_parent.child(src_entry.name)
314
- else
315
- new_dest_dir = new_dest_parent.create_child(src_entry.name, nil)
316
- ui.output "Created #{dest_path}" if ui
317
- end
318
- # Directory creation is recursive.
319
- if recurse_depth != 0
320
- parallel_do(src_entry.children) do |src_child|
321
- new_dest_child = new_dest_dir.child(src_child.name)
322
- child_error = copy_entries(src_child, new_dest_child, new_dest_dir, recurse_depth ? recurse_depth - 1 : recurse_depth, options, ui, format_path)
323
- error ||= child_error
298
+ elsif !dest_entry.exists?
299
+ if new_dest_parent.can_have_child?(src_entry.name, src_entry.dir?)
300
+ # If the entry can do a copy directly from filesystem, do that.
301
+ if new_dest_parent.respond_to?(:create_child_from)
302
+ if options[:dry_run]
303
+ ui.output "Would create #{dest_path}" if ui
304
+ else
305
+ new_dest_parent.create_child_from(src_entry)
306
+ ui.output "Created #{dest_path}" if ui
324
307
  end
308
+ return
325
309
  end
326
- else
327
- if options[:dry_run]
328
- ui.output "Would create #{dest_path}" if ui
329
- else
330
- child = new_dest_parent.create_child(src_entry.name, src_entry.read)
331
- ui.output "Created #{format_path.call(child)}" if ui
332
- end
333
- end
334
- end
335
-
336
- else
337
- # Both exist.
338
310
 
339
- # If the entry can do a copy directly, do that.
340
- if dest_entry.respond_to?(:copy_from)
341
- if options[:force] || compare(src_entry, dest_entry)[0] == false
342
- if options[:dry_run]
343
- ui.output "Would update #{dest_path}" if ui
311
+ if src_entry.dir?
312
+ if options[:dry_run]
313
+ ui.output "Would create #{dest_path}" if ui
314
+ new_dest_dir = new_dest_parent.child(src_entry.name)
315
+ else
316
+ new_dest_dir = new_dest_parent.create_child(src_entry.name, nil)
317
+ ui.output "Created #{dest_path}" if ui
318
+ end
319
+ # Directory creation is recursive.
320
+ if recurse_depth != 0
321
+ parallel_do(src_entry.children) do |src_child|
322
+ new_dest_child = new_dest_dir.child(src_child.name)
323
+ child_error = copy_entries(src_child, new_dest_child, new_dest_dir, recurse_depth ? recurse_depth - 1 : recurse_depth, options, ui, format_path)
324
+ error ||= child_error
325
+ end
326
+ end
344
327
  else
345
- dest_entry.copy_from(src_entry, options)
346
- ui.output "Updated #{dest_path}" if ui
328
+ if options[:dry_run]
329
+ ui.output "Would create #{dest_path}" if ui
330
+ else
331
+ child = new_dest_parent.create_child(src_entry.name, src_entry.read)
332
+ ui.output "Created #{format_path.call(child)}" if ui
333
+ end
347
334
  end
348
335
  end
349
- return
350
- end
351
336
 
352
- # If they are different types, log an error.
353
- if src_entry.dir?
354
- if dest_entry.dir?
355
- # If both are directories, recurse into their children
356
- if recurse_depth != 0
357
- parallel_do(child_pairs(src_entry, dest_entry)) do |src_child, dest_child|
358
- child_error = copy_entries(src_child, dest_child, dest_entry, recurse_depth ? recurse_depth - 1 : recurse_depth, options, ui, format_path)
359
- error ||= child_error
337
+ else
338
+ # Both exist.
339
+
340
+ # If the entry can do a copy directly, do that.
341
+ if dest_entry.respond_to?(:copy_from)
342
+ if options[:force] || compare(src_entry, dest_entry)[0] == false
343
+ if options[:dry_run]
344
+ ui.output "Would update #{dest_path}" if ui
345
+ else
346
+ dest_entry.copy_from(src_entry, options)
347
+ ui.output "Updated #{dest_path}" if ui
360
348
  end
361
349
  end
362
- else
363
- # If they are different types.
364
- ui.error("File #{src_path} is a directory while file #{dest_path} is a regular file\n") if ui
365
350
  return
366
351
  end
367
- else
368
- if dest_entry.dir?
369
- ui.error("File #{src_path} is a regular file while file #{dest_path} is a directory\n") if ui
370
- return
371
- else
372
352
 
373
- # Both are files! Copy them unless we're sure they are the same.'
374
- if options[:diff] == false
375
- should_copy = false
376
- elsif options[:force]
377
- should_copy = true
378
- src_value = nil
353
+ # If they are different types, log an error.
354
+ if src_entry.dir?
355
+ if dest_entry.dir?
356
+ # If both are directories, recurse into their children
357
+ if recurse_depth != 0
358
+ parallel_do(child_pairs(src_entry, dest_entry)) do |src_child, dest_child|
359
+ child_error = copy_entries(src_child, dest_child, dest_entry, recurse_depth ? recurse_depth - 1 : recurse_depth, options, ui, format_path)
360
+ error ||= child_error
361
+ end
362
+ end
379
363
  else
380
- are_same, src_value, _dest_value = compare(src_entry, dest_entry)
381
- should_copy = !are_same
364
+ # If they are different types.
365
+ ui.error("File #{src_path} is a directory while file #{dest_path} is a regular file\n") if ui
366
+ return
382
367
  end
383
- if should_copy
384
- if options[:dry_run]
385
- ui.output "Would update #{dest_path}" if ui
368
+ else
369
+ if dest_entry.dir?
370
+ ui.error("File #{src_path} is a regular file while file #{dest_path} is a directory\n") if ui
371
+ return
372
+ else
373
+
374
+ # Both are files! Copy them unless we're sure they are the same.'
375
+ if options[:diff] == false
376
+ should_copy = false
377
+ elsif options[:force]
378
+ should_copy = true
379
+ src_value = nil
386
380
  else
387
- src_value = src_entry.read if src_value.nil?
388
- dest_entry.write(src_value)
389
- ui.output "Updated #{dest_path}" if ui
381
+ are_same, src_value, _dest_value = compare(src_entry, dest_entry)
382
+ should_copy = !are_same
383
+ end
384
+ if should_copy
385
+ if options[:dry_run]
386
+ ui.output "Would update #{dest_path}" if ui
387
+ else
388
+ src_value = src_entry.read if src_value.nil?
389
+ dest_entry.write(src_value)
390
+ ui.output "Updated #{dest_path}" if ui
391
+ end
390
392
  end
391
393
  end
392
394
  end
393
395
  end
396
+ rescue RubyFileError => e
397
+ ui.warn "#{format_path.call(e.entry)} #{e.reason}." if ui
398
+ rescue DefaultEnvironmentCannotBeModifiedError => e
399
+ ui.warn "#{format_path.call(e.entry)} #{e.reason}." if ui
400
+ rescue OperationFailedError => e
401
+ ui.error "#{format_path.call(e.entry)} failed to #{e.operation}: #{e.message}" if ui
402
+ error = true
403
+ rescue OperationNotAllowedError => e
404
+ ui.error "#{format_path.call(e.entry)} #{e.reason}." if ui
405
+ error = true
394
406
  end
395
- rescue RubyFileError => e
396
- ui.warn "#{format_path.call(e.entry)} #{e.reason}." if ui
397
- rescue DefaultEnvironmentCannotBeModifiedError => e
398
- ui.warn "#{format_path.call(e.entry)} #{e.reason}." if ui
399
- rescue OperationFailedError => e
400
- ui.error "#{format_path.call(e.entry)} failed to #{e.operation}: #{e.message}" if ui
401
- error = true
402
- rescue OperationNotAllowedError => e
403
- ui.error "#{format_path.call(e.entry)} #{e.reason}." if ui
404
- error = true
407
+ error
405
408
  end
406
- error
407
- end
408
409
 
409
- def self.get_or_create_parent(entry, options, ui, format_path)
410
- parent = entry.parent
411
- if parent && !parent.exists?
412
- parent_path = format_path.call(parent) if ui
413
- parent_parent = get_or_create_parent(parent, options, ui, format_path)
414
- if options[:dry_run]
415
- ui.output "Would create #{parent_path}" if ui
416
- else
417
- parent = parent_parent.create_child(parent.name, nil)
418
- ui.output "Created #{parent_path}" if ui
410
+ def get_or_create_parent(entry, options, ui, format_path)
411
+ parent = entry.parent
412
+ if parent && !parent.exists?
413
+ parent_path = format_path.call(parent) if ui
414
+ parent_parent = get_or_create_parent(parent, options, ui, format_path)
415
+ if options[:dry_run]
416
+ ui.output "Would create #{parent_path}" if ui
417
+ else
418
+ parent = parent_parent.create_child(parent.name, nil)
419
+ ui.output "Created #{parent_path}" if ui
420
+ end
419
421
  end
422
+ return parent
420
423
  end
421
- return parent
422
- end
423
424
 
424
- def self.parallel_do(enum, options = {}, &block)
425
- Chef::ChefFS::Parallelizer.parallel_do(enum, options, &block)
425
+ def parallel_do(enum, options = {}, &block)
426
+ Chef::ChefFS::Parallelizer.parallel_do(enum, options, &block)
427
+ end
426
428
  end
427
429
  end
428
430
  end