chef 12.5.0.alpha.1 → 12.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (275) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +21 -25
  3. data/Gemfile +46 -0
  4. data/README.md +4 -4
  5. data/Rakefile +5 -110
  6. data/distro/common/html/knife_cookbook_site.html +18 -18
  7. data/distro/common/man/man1/knife-cookbook-site.1 +11 -11
  8. data/lib/chef/application.rb +1 -1
  9. data/lib/chef/application/apply.rb +19 -1
  10. data/lib/chef/application/client.rb +11 -5
  11. data/lib/chef/application/knife.rb +2 -2
  12. data/lib/chef/application/windows_service_manager.rb +9 -7
  13. data/lib/chef/chef_class.rb +39 -0
  14. data/lib/chef/chef_fs/data_handler/client_data_handler.rb +3 -1
  15. data/lib/chef/chef_fs/file_system/acl_dir.rb +3 -4
  16. data/lib/chef/chef_fs/file_system/acls_dir.rb +5 -1
  17. data/lib/chef/chef_fs/file_system/base_fs_dir.rb +0 -5
  18. data/lib/chef/chef_fs/file_system/base_fs_object.rb +5 -2
  19. data/lib/chef/chef_fs/file_system/chef_repository_file_system_cookbook_dir.rb +2 -9
  20. data/lib/chef/chef_fs/file_system/chef_repository_file_system_cookbook_entry.rb +2 -9
  21. data/lib/chef/chef_fs/file_system/chef_repository_file_system_cookbooks_dir.rb +10 -17
  22. data/lib/chef/chef_fs/file_system/chef_repository_file_system_entry.rb +1 -12
  23. data/lib/chef/chef_fs/file_system/chef_repository_file_system_root_dir.rb +15 -11
  24. data/lib/chef/chef_fs/file_system/chef_server_root_dir.rb +8 -2
  25. data/lib/chef/chef_fs/file_system/cookbook_dir.rb +3 -4
  26. data/lib/chef/chef_fs/file_system/cookbooks_acl_dir.rb +1 -1
  27. data/lib/chef/chef_fs/file_system/cookbooks_dir.rb +3 -11
  28. data/lib/chef/chef_fs/file_system/data_bags_dir.rb +3 -5
  29. data/lib/chef/chef_fs/file_system/environments_dir.rb +1 -1
  30. data/lib/chef/chef_fs/file_system/file_system_entry.rb +7 -4
  31. data/lib/chef/chef_fs/file_system/memory_dir.rb +2 -3
  32. data/lib/chef/chef_fs/file_system/multiplexed_dir.rb +15 -0
  33. data/lib/chef/chef_fs/file_system/nodes_dir.rb +1 -1
  34. data/lib/chef/chef_fs/file_system/organization_members_entry.rb +2 -2
  35. data/lib/chef/chef_fs/file_system/rest_list_dir.rb +4 -9
  36. data/lib/chef/client.rb +2 -3
  37. data/lib/chef/config.rb +34 -2
  38. data/lib/chef/cookbook/metadata.rb +25 -3
  39. data/lib/chef/cookbook/synchronizer.rb +1 -1
  40. data/lib/chef/cookbook_site_streaming_uploader.rb +1 -1
  41. data/lib/chef/cookbook_version.rb +3 -3
  42. data/lib/chef/deprecation/mixin/template.rb +1 -2
  43. data/lib/chef/deprecation/provider/cookbook_file.rb +1 -1
  44. data/lib/chef/deprecation/provider/file.rb +1 -1
  45. data/lib/chef/deprecation/provider/remote_directory.rb +52 -0
  46. data/lib/chef/deprecation/provider/remote_file.rb +1 -2
  47. data/lib/chef/deprecation/provider/template.rb +1 -1
  48. data/lib/chef/deprecation/warnings.rb +3 -4
  49. data/lib/chef/dsl/reboot_pending.rb +3 -2
  50. data/lib/chef/dsl/recipe.rb +6 -5
  51. data/lib/chef/dsl/resources.rb +2 -2
  52. data/lib/chef/event_dispatch/base.rb +12 -7
  53. data/lib/chef/event_dispatch/dispatcher.rb +21 -6
  54. data/lib/chef/exceptions.rb +22 -0
  55. data/lib/chef/file_content_management/tempfile.rb +1 -1
  56. data/lib/chef/formatters/base.rb +3 -0
  57. data/lib/chef/formatters/doc.rb +53 -5
  58. data/lib/chef/formatters/error_inspectors/compile_error_inspector.rb +36 -0
  59. data/lib/chef/formatters/minimal.rb +2 -2
  60. data/lib/chef/knife.rb +35 -55
  61. data/lib/chef/knife/bootstrap.rb +41 -0
  62. data/lib/chef/knife/bootstrap/chef_vault_handler.rb +1 -0
  63. data/lib/chef/knife/bootstrap/client_builder.rb +16 -0
  64. data/lib/chef/knife/bootstrap/templates/README.md +3 -4
  65. data/lib/chef/knife/cookbook_create.rb +1 -1
  66. data/lib/chef/knife/cookbook_site_download.rb +1 -1
  67. data/lib/chef/knife/cookbook_site_install.rb +1 -1
  68. data/lib/chef/knife/cookbook_site_share.rb +6 -6
  69. data/lib/chef/knife/cookbook_site_unshare.rb +2 -2
  70. data/lib/chef/knife/core/bootstrap_context.rb +12 -4
  71. data/lib/chef/knife/core/custom_manifest_loader.rb +69 -0
  72. data/lib/chef/knife/core/gem_glob_loader.rb +138 -0
  73. data/lib/chef/knife/core/hashed_command_loader.rb +80 -0
  74. data/lib/chef/knife/core/node_presenter.rb +24 -1
  75. data/lib/chef/knife/core/object_loader.rb +1 -0
  76. data/lib/chef/knife/core/subcommand_loader.rb +131 -146
  77. data/lib/chef/knife/node_run_list_remove.rb +12 -1
  78. data/lib/chef/knife/null.rb +10 -0
  79. data/lib/chef/knife/rehash.rb +62 -0
  80. data/lib/chef/knife/search.rb +3 -3
  81. data/lib/chef/knife/ssh.rb +52 -30
  82. data/lib/chef/local_mode.rb +5 -0
  83. data/lib/chef/log.rb +5 -1
  84. data/lib/chef/mixin/deprecation.rb +8 -8
  85. data/lib/chef/mixin/params_validate.rb +2 -2
  86. data/lib/chef/mixin/template.rb +48 -0
  87. data/lib/chef/mixin/which.rb +1 -1
  88. data/lib/chef/mixin/wide_string.rb +72 -0
  89. data/lib/chef/mixin/windows_architecture_helper.rb +15 -39
  90. data/lib/chef/mixin/windows_env_helper.rb +4 -1
  91. data/lib/chef/monkey_patches/webrick-utils.rb +51 -0
  92. data/lib/chef/monkey_patches/win32/registry.rb +72 -0
  93. data/lib/chef/node.rb +97 -3
  94. data/lib/chef/node_map.rb +2 -2
  95. data/lib/chef/platform/provider_mapping.rb +5 -6
  96. data/lib/chef/platform/query_helpers.rb +46 -4
  97. data/lib/chef/platform/service_helpers.rb +30 -32
  98. data/lib/chef/policy_builder.rb +1 -8
  99. data/lib/chef/policy_builder/dynamic.rb +186 -0
  100. data/lib/chef/policy_builder/expand_node_object.rb +30 -15
  101. data/lib/chef/policy_builder/policyfile.rb +155 -18
  102. data/lib/chef/property.rb +38 -9
  103. data/lib/chef/provider.rb +104 -12
  104. data/lib/chef/provider/batch.rb +8 -0
  105. data/lib/chef/provider/deploy.rb +2 -2
  106. data/lib/chef/provider/directory.rb +14 -2
  107. data/lib/chef/provider/dsc_resource.rb +5 -9
  108. data/lib/chef/provider/group/pw.rb +1 -1
  109. data/lib/chef/provider/ifconfig.rb +2 -2
  110. data/lib/chef/provider/mount.rb +7 -3
  111. data/lib/chef/provider/package/dpkg.rb +5 -11
  112. data/lib/chef/provider/package/rpm.rb +2 -2
  113. data/lib/chef/provider/package/rubygems.rb +1 -1
  114. data/lib/chef/provider/package/windows/msi.rb +2 -2
  115. data/lib/chef/provider/package/yum.rb +17 -5
  116. data/lib/chef/provider/powershell_script.rb +27 -4
  117. data/lib/chef/provider/remote_directory.rb +190 -102
  118. data/lib/chef/provider/service.rb +12 -2
  119. data/lib/chef/provider/service/aix.rb +1 -1
  120. data/lib/chef/provider/service/debian.rb +3 -5
  121. data/lib/chef/provider/service/freebsd.rb +1 -1
  122. data/lib/chef/provider/service/gentoo.rb +3 -3
  123. data/lib/chef/provider/service/init.rb +3 -3
  124. data/lib/chef/provider/service/insserv.rb +2 -4
  125. data/lib/chef/provider/service/invokercd.rb +2 -4
  126. data/lib/chef/provider/service/openbsd.rb +2 -1
  127. data/lib/chef/provider/service/redhat.rb +52 -16
  128. data/lib/chef/provider/service/simple.rb +2 -2
  129. data/lib/chef/provider/service/systemd.rb +3 -5
  130. data/lib/chef/provider/service/upstart.rb +4 -6
  131. data/lib/chef/provider/subversion.rb +13 -7
  132. data/lib/chef/provider/template/content.rb +16 -6
  133. data/lib/chef/provider/user/solaris.rb +32 -4
  134. data/lib/chef/provider/windows_script.rb +3 -5
  135. data/lib/chef/provider_resolver.rb +2 -2
  136. data/lib/chef/resource.rb +85 -27
  137. data/lib/chef/resource/action_class.rb +83 -0
  138. data/lib/chef/resource/chef_gem.rb +3 -3
  139. data/lib/chef/resource/deploy.rb +8 -2
  140. data/lib/chef/resource/dsc_script.rb +2 -0
  141. data/lib/chef/resource/file/verification.rb +1 -1
  142. data/lib/chef/resource/registry_key.rb +1 -1
  143. data/lib/chef/resource/service.rb +10 -2
  144. data/lib/chef/resource/subversion.rb +5 -0
  145. data/lib/chef/resource/windows_script.rb +6 -2
  146. data/lib/chef/resource/yum_package.rb +10 -1
  147. data/lib/chef/resource_resolver.rb +3 -3
  148. data/lib/chef/run_context.rb +6 -8
  149. data/lib/chef/run_list/versioned_recipe_list.rb +15 -0
  150. data/lib/chef/run_lock.rb +30 -21
  151. data/lib/chef/util/powershell/ps_credential.rb +4 -0
  152. data/lib/chef/util/windows.rb +0 -32
  153. data/lib/chef/util/windows/net_group.rb +85 -106
  154. data/lib/chef/util/windows/net_use.rb +35 -71
  155. data/lib/chef/util/windows/net_user.rb +0 -1
  156. data/lib/chef/util/windows/volume.rb +19 -19
  157. data/lib/chef/version.rb +3 -3
  158. data/lib/chef/win32/api.rb +1 -0
  159. data/lib/chef/win32/api/file.rb +20 -0
  160. data/lib/chef/win32/api/net.rb +163 -43
  161. data/lib/chef/win32/api/registry.rb +51 -0
  162. data/lib/chef/win32/api/system.rb +23 -0
  163. data/lib/chef/win32/api/unicode.rb +0 -43
  164. data/lib/chef/win32/crypto.rb +2 -1
  165. data/lib/chef/win32/file.rb +28 -3
  166. data/lib/chef/win32/mutex.rb +1 -2
  167. data/lib/chef/win32/net.rb +162 -8
  168. data/lib/chef/win32/process.rb +13 -0
  169. data/lib/chef/win32/registry.rb +25 -28
  170. data/lib/chef/win32/security.rb +1 -1
  171. data/lib/chef/win32/security/token.rb +1 -1
  172. data/lib/chef/win32/system.rb +62 -0
  173. data/lib/chef/win32/unicode.rb +7 -2
  174. data/lib/chef/win32/version.rb +0 -4
  175. data/spec/data/cookbooks/openldap/templates/default/helpers.erb +14 -0
  176. data/spec/data/cookbooks/openldap/templates/default/nested_openldap_partials.erb +1 -0
  177. data/spec/data/cookbooks/openldap/templates/default/nested_partial.erb +1 -0
  178. data/spec/data/dsc_lcm.pfx +0 -0
  179. data/spec/functional/dsl/reboot_pending_spec.rb +33 -43
  180. data/spec/functional/knife/cookbook_delete_spec.rb +17 -7
  181. data/spec/functional/knife/ssh_spec.rb +16 -0
  182. data/spec/functional/resource/deploy_revision_spec.rb +1 -1
  183. data/spec/functional/resource/dsc_resource_spec.rb +2 -0
  184. data/spec/functional/resource/dsc_script_spec.rb +91 -2
  185. data/spec/functional/resource/group_spec.rb +67 -44
  186. data/spec/functional/resource/powershell_script_spec.rb +104 -15
  187. data/spec/functional/resource/windows_service_spec.rb +1 -1
  188. data/spec/functional/run_lock_spec.rb +368 -189
  189. data/spec/functional/win32/{registry_helper_spec.rb → registry_spec.rb} +4 -23
  190. data/spec/integration/client/client_spec.rb +51 -0
  191. data/spec/integration/knife/download_spec.rb +4 -0
  192. data/spec/integration/knife/list_spec.rb +8 -0
  193. data/spec/integration/knife/upload_spec.rb +1 -1
  194. data/spec/integration/recipes/recipe_dsl_spec.rb +1 -1
  195. data/spec/integration/recipes/remote_directory.rb +74 -0
  196. data/spec/integration/recipes/resource_action_spec.rb +42 -22
  197. data/spec/integration/recipes/resource_converge_if_changed_spec.rb +423 -0
  198. data/spec/integration/recipes/resource_load_spec.rb +206 -0
  199. data/spec/spec_helper.rb +8 -0
  200. data/spec/support/platform_helpers.rb +13 -0
  201. data/{lib/chef/mixin/wstring.rb → spec/support/shared/context/win32.rb} +15 -12
  202. data/spec/support/shared/functional/windows_script.rb +63 -26
  203. data/spec/support/shared/unit/mock_shellout.rb +46 -0
  204. data/spec/support/shared/unit/provider/file.rb +10 -4
  205. data/spec/unit/application/client_spec.rb +16 -3
  206. data/spec/unit/application/knife_spec.rb +2 -2
  207. data/spec/unit/chef_class_spec.rb +0 -4
  208. data/spec/unit/client_spec.rb +6 -1
  209. data/spec/unit/config_spec.rb +31 -0
  210. data/spec/unit/cookbook/metadata_spec.rb +23 -3
  211. data/spec/unit/cookbook/syntax_check_spec.rb +3 -0
  212. data/spec/unit/deprecation_spec.rb +3 -6
  213. data/spec/unit/dsl/reboot_pending_spec.rb +12 -6
  214. data/spec/unit/event_dispatch/dispatcher_spec.rb +65 -3
  215. data/spec/unit/event_dispatch/dsl_spec.rb +0 -4
  216. data/spec/unit/formatters/doc_spec.rb +32 -0
  217. data/spec/unit/formatters/error_inspectors/compile_error_inspector_spec.rb +26 -0
  218. data/spec/unit/knife/bootstrap/client_builder_spec.rb +27 -0
  219. data/spec/unit/knife/bootstrap_spec.rb +55 -3
  220. data/spec/unit/knife/cookbook_site_share_spec.rb +3 -3
  221. data/spec/unit/knife/core/bootstrap_context_spec.rb +21 -4
  222. data/spec/unit/knife/core/custom_manifest_loader_spec.rb +41 -0
  223. data/spec/unit/knife/core/gem_glob_loader_spec.rb +210 -0
  224. data/spec/unit/knife/core/hashed_command_loader_spec.rb +93 -0
  225. data/spec/unit/knife/core/subcommand_loader_spec.rb +16 -192
  226. data/spec/unit/knife/node_run_list_remove_spec.rb +17 -0
  227. data/spec/unit/mixin/enforce_ownership_and_permissions_spec.rb +10 -10
  228. data/spec/unit/mixin/template_spec.rb +5 -1
  229. data/spec/unit/mixin/windows_architecture_helper_spec.rb +13 -8
  230. data/spec/unit/node_spec.rb +213 -0
  231. data/spec/unit/platform/query_helpers_spec.rb +146 -3
  232. data/spec/unit/policy_builder/dynamic_spec.rb +275 -0
  233. data/spec/unit/policy_builder/expand_node_object_spec.rb +37 -38
  234. data/spec/unit/policy_builder/policyfile_spec.rb +260 -46
  235. data/spec/unit/property/validation_spec.rb +5 -0
  236. data/spec/unit/property_spec.rb +152 -26
  237. data/spec/unit/provider/deploy_spec.rb +5 -5
  238. data/spec/unit/provider/directory_spec.rb +35 -0
  239. data/spec/unit/provider/dsc_resource_spec.rb +3 -10
  240. data/spec/unit/provider/ifconfig_spec.rb +22 -2
  241. data/spec/unit/provider/mount/aix_spec.rb +2 -1
  242. data/spec/unit/provider/mount/mount_spec.rb +6 -0
  243. data/spec/unit/provider/mount/windows_spec.rb +14 -0
  244. data/spec/unit/provider/mount_spec.rb +12 -1
  245. data/spec/unit/provider/package/dpkg_spec.rb +8 -1
  246. data/spec/unit/provider/package/rpm_spec.rb +18 -1
  247. data/spec/unit/provider/package/rubygems_spec.rb +18 -0
  248. data/spec/unit/provider/package/yum_spec.rb +97 -24
  249. data/spec/unit/provider/powershell_script_spec.rb +52 -26
  250. data/spec/unit/provider/remote_directory_spec.rb +1 -2
  251. data/spec/unit/provider/service/aix_service_spec.rb +3 -3
  252. data/spec/unit/provider/service/gentoo_service_spec.rb +4 -4
  253. data/spec/unit/provider/service/openbsd_service_spec.rb +10 -8
  254. data/spec/unit/provider/service/redhat_spec.rb +88 -8
  255. data/spec/unit/provider/service/upstart_service_spec.rb +11 -7
  256. data/spec/unit/provider/service/windows_spec.rb +211 -200
  257. data/spec/unit/provider/subversion_spec.rb +50 -31
  258. data/spec/unit/provider/template/content_spec.rb +93 -2
  259. data/spec/unit/provider/user/solaris_spec.rb +66 -9
  260. data/spec/unit/provider_resolver_spec.rb +707 -650
  261. data/spec/unit/resource/deploy_spec.rb +7 -1
  262. data/spec/unit/resource/dsc_script_spec.rb +4 -0
  263. data/spec/unit/resource/file/verification_spec.rb +1 -1
  264. data/spec/unit/resource/powershell_script_spec.rb +17 -13
  265. data/spec/unit/resource/service_spec.rb +4 -4
  266. data/spec/unit/resource/subversion_spec.rb +4 -0
  267. data/spec/unit/resource/yum_package_spec.rb +10 -1
  268. data/spec/unit/run_list/versioned_recipe_list_spec.rb +5 -0
  269. data/spec/unit/win32/registry_spec.rb +394 -0
  270. data/tasks/external_tests.rb +47 -23
  271. data/tasks/maintainers.rb +155 -14
  272. metadata +51 -26
  273. data/lib/chef/knife/bootstrap/templates/archlinux-gems.erb +0 -76
  274. data/lib/chef/knife/bootstrap/templates/chef-aix.erb +0 -72
  275. data/spec/unit/registry_helper_spec.rb +0 -390
@@ -382,7 +382,7 @@ class Chef
382
382
 
383
383
  def emit_warnings
384
384
  if Chef::Config[:chef_gem_compile_time]
385
- Chef::Log.deprecation "setting chef_gem_compile_time to true is deprecated"
385
+ Chef.log_deprecation "setting chef_gem_compile_time to true is deprecated"
386
386
  end
387
387
  end
388
388
 
@@ -49,6 +49,24 @@ class Chef::Application::Apply < Chef::Application
49
49
  :description => "Load attributes from a JSON file or URL",
50
50
  :proc => nil
51
51
 
52
+ option :force_logger,
53
+ :long => "--force-logger",
54
+ :description => "Use logger output instead of formatter output",
55
+ :boolean => true,
56
+ :default => false
57
+
58
+ option :force_formatter,
59
+ :long => "--force-formatter",
60
+ :description => "Use formatter output instead of logger output",
61
+ :boolean => true,
62
+ :default => false
63
+
64
+ option :formatter,
65
+ :short => "-F FORMATTER",
66
+ :long => "--format FORMATTER",
67
+ :description => "output format to use",
68
+ :proc => lambda { |format| Chef::Config.add_formatter(format) }
69
+
52
70
  option :log_level,
53
71
  :short => "-l LEVEL",
54
72
  :long => "--log_level LEVEL",
@@ -82,7 +100,7 @@ class Chef::Application::Apply < Chef::Application
82
100
  option :color,
83
101
  :long => '--[no-]color',
84
102
  :boolean => true,
85
- :default => !Chef::Platform.windows?,
103
+ :default => true,
86
104
  :description => "Use colored output, defaults to enabled"
87
105
 
88
106
  option :minimal_ohai,
@@ -58,8 +58,8 @@ class Chef::Application::Client < Chef::Application
58
58
  option :color,
59
59
  :long => '--[no-]color',
60
60
  :boolean => true,
61
- :default => !Chef::Platform.windows?,
62
- :description => "Use colored output, defaults to false on Windows, true otherwise"
61
+ :default => true,
62
+ :description => "Use colored output, defaults to enabled"
63
63
 
64
64
  option :log_level,
65
65
  :short => "-l LEVEL",
@@ -160,6 +160,12 @@ class Chef::Application::Client < Chef::Application
160
160
  :description => "Set the client key file location",
161
161
  :proc => nil
162
162
 
163
+ option :named_run_list,
164
+ :short => "-n NAMED_RUN_LIST",
165
+ :long => "--named-run-list NAMED_RUN_LIST",
166
+ :description => "Use a policyfile's named run list instead of the default run list",
167
+ :default => nil
168
+
163
169
  option :environment,
164
170
  :short => '-E ENVIRONMENT',
165
171
  :long => '--environment ENVIRONMENT',
@@ -449,9 +455,9 @@ class Chef::Application::Client < Chef::Application
449
455
  end
450
456
 
451
457
  def audit_mode_settings_explanation
452
- "\n* To enable audit mode after converge, use command line option `--audit-mode enabled` or set `:audit_mode = :enabled` in your config file." +
453
- "\n* To disable audit mode, use command line option `--audit-mode disabled` or set `:audit_mode = :disabled` in your config file." +
454
- "\n* To only run audit mode, use command line option `--audit-mode audit-only` or set `:audit_mode = :audit_only` in your config file." +
458
+ "\n* To enable audit mode after converge, use command line option `--audit-mode enabled` or set `audit_mode :enabled` in your config file." +
459
+ "\n* To disable audit mode, use command line option `--audit-mode disabled` or set `audit_mode :disabled` in your config file." +
460
+ "\n* To only run audit mode, use command line option `--audit-mode audit-only` or set `audit_mode :audit_only` in your config file." +
455
461
  "\nAudit mode is disabled by default."
456
462
  end
457
463
 
@@ -44,8 +44,8 @@ class Chef::Application::Knife < Chef::Application
44
44
  option :color,
45
45
  :long => '--[no-]color',
46
46
  :boolean => true,
47
- :default => !Chef::Platform.windows?,
48
- :description => "Use colored output, defaults to false on Windows, true otherwise"
47
+ :default => true,
48
+ :description => "Use colored output, defaults to enabled"
49
49
 
50
50
  option :environment,
51
51
  :short => "-E ENVIRONMENT",
@@ -93,6 +93,7 @@ class Chef
93
93
  @service_start_name = service_options[:run_as_user]
94
94
  @password = service_options[:run_as_password]
95
95
  @delayed_start = service_options[:delayed_start]
96
+ @dependencies = service_options[:dependencies]
96
97
  end
97
98
 
98
99
  def run(params = ARGV)
@@ -114,16 +115,17 @@ class Chef
114
115
  cmd = "\"#{ruby}\" \"#{@service_file_path}\" #{opts}".gsub(File::SEPARATOR, File::ALT_SEPARATOR)
115
116
 
116
117
  ::Win32::Service.new(
117
- :service_name => @service_name,
118
- :display_name => @service_display_name,
119
- :description => @service_description,
118
+ :service_name => @service_name,
119
+ :display_name => @service_display_name,
120
+ :description => @service_description,
120
121
  # Prior to 0.8.5, win32-service creates interactive services by default,
121
122
  # and we don't want that, so we need to override the service type.
122
- :service_type => ::Win32::Service::SERVICE_WIN32_OWN_PROCESS,
123
- :start_type => ::Win32::Service::SERVICE_AUTO_START,
124
- :binary_path_name => cmd,
123
+ :service_type => ::Win32::Service::SERVICE_WIN32_OWN_PROCESS,
124
+ :start_type => ::Win32::Service::SERVICE_AUTO_START,
125
+ :binary_path_name => cmd,
125
126
  :service_start_name => @service_start_name,
126
- :password => @password,
127
+ :password => @password,
128
+ :dependencies => @dependencies
127
129
  )
128
130
  ::Win32::Service.configure(
129
131
  :service_name => @service_name,
@@ -190,6 +190,45 @@ class Chef
190
190
  def resource_handler_map
191
191
  @resource_handler_map ||= Chef::Platform::ResourceHandlerMap.instance
192
192
  end
193
+
194
+ #
195
+ # Emit a deprecation message.
196
+ #
197
+ # @param message The message to send.
198
+ # @param location The location. Defaults to the caller who called you (since
199
+ # generally the person who triggered the check is the one that needs to be
200
+ # fixed).
201
+ #
202
+ # @example
203
+ # Chef.deprecation("Deprecated!")
204
+ #
205
+ # @api private this will likely be removed in favor of an as-yet unwritten
206
+ # `Chef.log`
207
+ def log_deprecation(message, location=nil)
208
+ if !location
209
+ # Pick the first caller that is *not* part of the Chef gem, that's the
210
+ # thing the user wrote.
211
+ chef_gem_path = File.expand_path("../..", __FILE__)
212
+ caller(0..10).each do |c|
213
+ if !c.start_with?(chef_gem_path)
214
+ location = c
215
+ break
216
+ end
217
+ end
218
+ end
219
+ # `run_context.events` is the primary deprecation target if we're in a
220
+ # run. If we are not yet in a run, print to `Chef::Log`.
221
+ if run_context && run_context.events
222
+ run_context.events.deprecation(message, location)
223
+ else
224
+ Chef::Log.deprecation(message, location)
225
+ end
226
+ end
227
+ end
228
+
229
+ # @api private Only for test dependency injection; not evenly implemented as yet.
230
+ def self.path_to(path)
231
+ path
193
232
  end
194
233
 
195
234
  reset!
@@ -13,11 +13,13 @@ class Chef
13
13
  'validator' => false,
14
14
  'chef_type' => 'client'
15
15
  }
16
+ # Handle the fact that admin/validator have changed type from string -> boolean
17
+ client['admin'] = (client['admin'] == 'true') if client['admin'].is_a?(String)
18
+ client['validator'] = (client['validator'] == 'true') if client['validator'].is_a?(String)
16
19
  if entry.respond_to?(:org) && entry.org
17
20
  defaults['orgname'] = entry.org
18
21
  end
19
22
  result = normalize_hash(client, defaults)
20
- # You can NOT send json_class, or it will fail
21
23
  result.delete('json_class')
22
24
  result
23
25
  end
@@ -28,10 +28,9 @@ class Chef
28
28
  parent.parent.child(name).api_path
29
29
  end
30
30
 
31
- def child(name)
31
+ def make_child_entry(name, exists = nil)
32
32
  result = @children.select { |child| child.name == name }.first if @children
33
- result ||= can_have_child?(name, false) ?
34
- AclEntry.new(name, self) : NonexistentFSObject.new(name, self)
33
+ result || AclEntry.new(name, self, exists)
35
34
  end
36
35
 
37
36
  def can_have_child?(name, is_dir)
@@ -42,7 +41,7 @@ class Chef
42
41
  if @children.nil?
43
42
  # Grab the ACTUAL children (/nodes, /containers, etc.) and get their names
44
43
  names = parent.parent.child(name).children.map { |child| child.dir? ? "#{child.name}.json" : child.name }
45
- @children = names.map { |name| AclEntry.new(name, self, true) }
44
+ @children = names.map { |name| make_child_entry(name, true) }
46
45
  end
47
46
  @children
48
47
  end
@@ -40,8 +40,12 @@ class Chef
40
40
  parent.api_path
41
41
  end
42
42
 
43
+ def make_child_entry(name)
44
+ children.select { |child| child.name == name }.first
45
+ end
46
+
43
47
  def can_have_child?(name, is_dir)
44
- is_dir ? ENTITY_TYPES.include(name) : name == 'organization.json'
48
+ is_dir ? ENTITY_TYPES.include?(name) : name == 'organization.json'
45
49
  end
46
50
 
47
51
  def children
@@ -31,11 +31,6 @@ class Chef
31
31
  true
32
32
  end
33
33
 
34
- # Override child(name) to provide a child object by name without the network read
35
- def child(name)
36
- children.select { |child| child.name == name }.first || NonexistentFSObject.new(name, self)
37
- end
38
-
39
34
  def can_have_child?(name, is_dir)
40
35
  true
41
36
  end
@@ -95,7 +95,10 @@ class Chef
95
95
  # directly perform a network request to retrieve the y.json data bag. No
96
96
  # network request was necessary to retrieve
97
97
  def child(name)
98
- NonexistentFSObject.new(name, self)
98
+ if can_have_child?(name, true) || can_have_child?(name, false)
99
+ result = make_child_entry(name)
100
+ end
101
+ result || NonexistentFSObject.new(name, self)
99
102
  end
100
103
 
101
104
  # Override children to report your *actual* list of children as an array.
@@ -171,7 +174,7 @@ class Chef
171
174
 
172
175
  # Important directory attributes: name, parent, path, root
173
176
  # Overridable attributes: dir?, child(name), path_for_printing
174
- # Abstract: read, write, delete, children, can_have_child?, create_child, compare_to
177
+ # Abstract: read, write, delete, children, can_have_child?, create_child, compare_to, make_child_entry
175
178
  end # class BaseFsObject
176
179
  end
177
180
  end
@@ -58,14 +58,7 @@ class Chef
58
58
  end
59
59
 
60
60
  def children
61
- begin
62
- Dir.entries(file_path).sort.
63
- select { |child_name| can_have_child?(child_name, File.directory?(File.join(file_path, child_name))) }.
64
- map { |child_name| make_child(child_name) }.
65
- select { |entry| !(entry.dir? && entry.children.size == 0) }
66
- rescue Errno::ENOENT
67
- raise Chef::ChefFS::FileSystem::NotFoundError.new(self, $!)
68
- end
61
+ super.select { |entry| !(entry.dir? && entry.children.size == 0 ) }
69
62
  end
70
63
 
71
64
  def can_have_child?(name, is_dir)
@@ -99,7 +92,7 @@ class Chef
99
92
 
100
93
  protected
101
94
 
102
- def make_child(child_name)
95
+ def make_child_entry(child_name)
103
96
  segment_info = CookbookDir::COOKBOOK_SEGMENT_INFO[child_name.to_sym] || {}
104
97
  ChefRepositoryFileSystemCookbookEntry.new(child_name, self, nil, segment_info[:ruby_only], segment_info[:recursive])
105
98
  end
@@ -34,14 +34,7 @@ class Chef
34
34
  attr_reader :recursive
35
35
 
36
36
  def children
37
- begin
38
- Dir.entries(file_path).sort.
39
- select { |child_name| can_have_child?(child_name, File.directory?(File.join(file_path, child_name))) }.
40
- map { |child_name| make_child(child_name) }.
41
- select { |entry| !(entry.dir? && entry.children.size == 0) }
42
- rescue Errno::ENOENT
43
- raise Chef::ChefFS::FileSystem::NotFoundError.new(self, $!)
44
- end
37
+ super.select { |entry| !(entry.dir? && entry.children.size == 0 ) }
45
38
  end
46
39
 
47
40
  def can_have_child?(name, is_dir)
@@ -78,7 +71,7 @@ class Chef
78
71
 
79
72
  protected
80
73
 
81
- def make_child(child_name)
74
+ def make_child_entry(child_name)
82
75
  ChefRepositoryFileSystemCookbookEntry.new(child_name, self, nil, ruby_only, recursive)
83
76
  end
84
77
  end
@@ -37,21 +37,14 @@ class Chef
37
37
  attr_reader :chefignore
38
38
 
39
39
  def children
40
- begin
41
- Dir.entries(file_path).sort.
42
- select { |child_name| can_have_child?(child_name, File.directory?(File.join(file_path, child_name))) }.
43
- map { |child_name| make_child(child_name) }.
44
- select do |entry|
45
- # empty cookbooks and cookbook directories are ignored
46
- if !entry.can_upload?
47
- Chef::Log.warn("Cookbook '#{entry.name}' is empty or entirely chefignored at #{entry.path_for_printing}")
48
- false
49
- else
50
- true
51
- end
52
- end
53
- rescue Errno::ENOENT
54
- raise Chef::ChefFS::FileSystem::NotFoundError.new(self, $!)
40
+ super.select do |entry|
41
+ # empty cookbooks and cookbook directories are ignored
42
+ if !entry.can_upload?
43
+ Chef::Log.warn("Cookbook '#{entry.name}' is empty or entirely chefignored at #{entry.path_for_printing}")
44
+ false
45
+ else
46
+ true
47
+ end
55
48
  end
56
49
  end
57
50
 
@@ -61,7 +54,7 @@ class Chef
61
54
 
62
55
  def write_cookbook(cookbook_path, cookbook_version_json, from_fs)
63
56
  cookbook_name = File.basename(cookbook_path)
64
- child = make_child(cookbook_name)
57
+ child = make_child_entry(cookbook_name)
65
58
 
66
59
  # Use the copy/diff algorithm to copy it down so we don't destroy
67
60
  # chefignored data. This is terribly un-thread-safe.
@@ -80,7 +73,7 @@ class Chef
80
73
 
81
74
  protected
82
75
 
83
- def make_child(child_name)
76
+ def make_child_entry(child_name)
84
77
  ChefRepositoryFileSystemCookbookDir.new(child_name, self)
85
78
  end
86
79
  end
@@ -70,20 +70,9 @@ class Chef
70
70
  Chef::JSONCompat.to_json_pretty(object)
71
71
  end
72
72
 
73
- def children
74
- # Except cookbooks and data bag dirs, all things must be json files
75
- begin
76
- Dir.entries(file_path).sort.
77
- select { |child_name| can_have_child?(child_name, File.directory?(File.join(file_path, child_name))) }.
78
- map { |child_name| make_child(child_name) }
79
- rescue Errno::ENOENT
80
- raise Chef::ChefFS::FileSystem::NotFoundError.new(self, $!)
81
- end
82
- end
83
-
84
73
  protected
85
74
 
86
- def make_child(child_name)
75
+ def make_child_entry(child_name)
87
76
  ChefRepositoryFileSystemEntry.new(child_name, self)
88
77
  end
89
78
  end
@@ -68,13 +68,13 @@ class Chef
68
68
  attr_reader :child_paths
69
69
  attr_reader :versioned_cookbooks
70
70
 
71
- CHILDREN = %w(invitations.json members.json org.json)
71
+ CHILDREN = %w(org.json invitations.json members.json)
72
72
 
73
73
  def children
74
74
  @children ||= begin
75
- result = child_paths.keys.sort.map { |name| make_child_entry(name) }.select { |child| !child.nil? }
76
- result += root_dir.children.select { |c| CHILDREN.include?(c.name) } if root_dir
77
- result.sort_by { |c| c.name }
75
+ result = child_paths.keys.sort.map { |name| make_child_entry(name) }
76
+ result += CHILDREN.map { |name| make_child_entry(name) }
77
+ result.select { |c| c && c.exists? }.sort_by { |c| c.name }
78
78
  end
79
79
  end
80
80
 
@@ -149,19 +149,23 @@ class Chef
149
149
  # cookbooks from all of them when you list or grab them).
150
150
  #
151
151
  def make_child_entry(name)
152
- paths = child_paths[name].select do |path|
153
- File.exists?(path)
152
+ if CHILDREN.include?(name)
153
+ return nil if !root_dir
154
+ return root_dir.child(name)
154
155
  end
156
+
157
+ paths = (child_paths[name] || []).select { |path| File.exists?(path) }
155
158
  if paths.size == 0
156
- return nil
159
+ return NonexistentFSObject.new(name, self)
157
160
  end
158
- if name == 'cookbooks'
161
+ case name
162
+ when 'cookbooks'
159
163
  dirs = paths.map { |path| ChefRepositoryFileSystemCookbooksDir.new(name, self, path) }
160
- elsif name == 'data_bags'
164
+ when 'data_bags'
161
165
  dirs = paths.map { |path| ChefRepositoryFileSystemDataBagsDir.new(name, self, path) }
162
- elsif name == 'policies'
166
+ when 'policies'
163
167
  dirs = paths.map { |path| ChefRepositoryFileSystemPoliciesDir.new(name, self, path) }
164
- elsif name == 'acls'
168
+ when 'acls'
165
169
  dirs = paths.map { |path| ChefRepositoryFileSystemAclsDir.new(name, self, path) }
166
170
  else
167
171
  data_handler = case name
@@ -110,7 +110,8 @@ class Chef
110
110
  end
111
111
 
112
112
  def can_have_child?(name, is_dir)
113
- is_dir && children.any? { |child| child.name == name }
113
+ result = children.select { |child| child.name == name }.first
114
+ result && !!result.dir? == !!is_dir
114
115
  end
115
116
 
116
117
  def org
@@ -119,11 +120,16 @@ class Chef
119
120
  if File.dirname(path) == '/organizations'
120
121
  File.basename(path)
121
122
  else
122
- nil
123
+ # In Chef 12, everything is in an org.
124
+ 'chef'
123
125
  end
124
126
  end
125
127
  end
126
128
 
129
+ def make_child_entry(name)
130
+ children.select { |child| child.name == name }.first
131
+ end
132
+
127
133
  def children
128
134
  @children ||= begin
129
135
  result = [