chef 15.4.45 → 15.5.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (244) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +5 -3
  3. data/Rakefile +5 -3
  4. data/chef.gemspec +2 -1
  5. data/lib/chef/application.rb +2 -2
  6. data/lib/chef/application/client.rb +1 -1
  7. data/lib/chef/application/knife.rb +1 -0
  8. data/lib/chef/application/solo.rb +1 -1
  9. data/lib/chef/chef_class.rb +1 -6
  10. data/lib/chef/chef_fs.rb +1 -1
  11. data/lib/chef/chef_fs/file_pattern.rb +1 -1
  12. data/lib/chef/chef_fs/file_system/chef_server/cookbook_artifacts_dir.rb +2 -2
  13. data/lib/chef/chef_fs/file_system/chef_server/versioned_cookbooks_dir.rb +2 -2
  14. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_artifact_dir.rb +1 -1
  15. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb +7 -1
  16. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb +4 -3
  17. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb +3 -3
  18. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_versioned_cookbook_dir.rb +1 -1
  19. data/lib/chef/chef_fs/file_system/repository/nodes_dir.rb +3 -3
  20. data/lib/chef/chef_fs/knife.rb +1 -1
  21. data/lib/chef/chef_fs/path_utils.rb +2 -2
  22. data/lib/chef/client.rb +4 -5
  23. data/lib/chef/config.rb +3 -2
  24. data/lib/chef/cookbook/chefignore.rb +16 -11
  25. data/lib/chef/cookbook/cookbook_version_loader.rb +1 -1
  26. data/lib/chef/cookbook/syntax_check.rb +5 -3
  27. data/lib/chef/cookbook_loader.rb +3 -3
  28. data/lib/chef/cookbook_uploader.rb +1 -1
  29. data/lib/chef/data_collector.rb +2 -2
  30. data/lib/chef/data_collector/run_end_message.rb +1 -0
  31. data/lib/chef/deprecated.rb +4 -0
  32. data/lib/chef/dsl/core.rb +1 -1
  33. data/lib/chef/dsl/platform_introspection.rb +9 -18
  34. data/lib/chef/event_loggers/windows_eventlog.rb +1 -1
  35. data/lib/chef/file_content_management/deploy.rb +3 -3
  36. data/lib/chef/file_content_management/deploy/mv_windows.rb +2 -2
  37. data/lib/chef/file_content_management/tempfile.rb +1 -1
  38. data/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb +2 -2
  39. data/lib/chef/http.rb +1 -1
  40. data/lib/chef/http/socketless_chef_zero_client.rb +1 -1
  41. data/lib/chef/knife.rb +4 -3
  42. data/lib/chef/knife/config_get.rb +2 -1
  43. data/lib/chef/knife/configure.rb +1 -1
  44. data/lib/chef/knife/cookbook_metadata_from_file.rb +6 -0
  45. data/lib/chef/knife/core/generic_presenter.rb +1 -1
  46. data/lib/chef/knife/core/status_presenter.rb +1 -1
  47. data/lib/chef/knife/ssh.rb +6 -0
  48. data/lib/chef/local_mode.rb +1 -1
  49. data/lib/chef/mash.rb +21 -232
  50. data/lib/chef/mixin/file_class.rb +2 -2
  51. data/lib/chef/mixin/lazy_module_include.rb +1 -1
  52. data/lib/chef/mixin/path_sanity.rb +3 -39
  53. data/lib/chef/mixin/securable.rb +1 -1
  54. data/lib/chef/mixin/shell_out.rb +4 -5
  55. data/lib/chef/mixin/template.rb +1 -1
  56. data/lib/chef/mixin/user_context.rb +3 -3
  57. data/lib/chef/mixin/which.rb +10 -38
  58. data/lib/chef/mixin/windows_architecture_helper.rb +6 -6
  59. data/lib/chef/mixin/windows_env_helper.rb +5 -5
  60. data/lib/chef/node/attribute.rb +2 -2
  61. data/lib/chef/node_map.rb +17 -4
  62. data/lib/chef/platform/query_helpers.rb +4 -2
  63. data/lib/chef/platform/rebooter.rb +1 -1
  64. data/lib/chef/platform/service_helpers.rb +14 -85
  65. data/lib/chef/provider.rb +2 -0
  66. data/lib/chef/provider/file.rb +2 -2
  67. data/lib/chef/provider/ifconfig/redhat.rb +1 -1
  68. data/lib/chef/provider/link.rb +3 -3
  69. data/lib/chef/provider/mount/solaris.rb +1 -1
  70. data/lib/chef/provider/package/yum.rb +1 -1
  71. data/lib/chef/provider/registry_key.rb +1 -1
  72. data/lib/chef/provider/remote_directory.rb +3 -3
  73. data/lib/chef/provider/remote_file/fetcher.rb +2 -2
  74. data/lib/chef/provider/remote_file/local_file.rb +1 -1
  75. data/lib/chef/provider/script.rb +3 -3
  76. data/lib/chef/provider/service.rb +5 -2
  77. data/lib/chef/provider/service/arch.rb +1 -1
  78. data/lib/chef/provider/service/debian.rb +4 -4
  79. data/lib/chef/provider/service/init.rb +1 -1
  80. data/lib/chef/provider/service/insserv.rb +4 -4
  81. data/lib/chef/provider/service/invokercd.rb +4 -4
  82. data/lib/chef/provider/service/redhat.rb +4 -4
  83. data/lib/chef/provider/service/systemd.rb +19 -3
  84. data/lib/chef/provider/service/upstart.rb +3 -3
  85. data/lib/chef/provider/subversion.rb +1 -1
  86. data/lib/chef/provider/systemd_unit.rb +26 -2
  87. data/lib/chef/provider/windows_path.rb +3 -3
  88. data/lib/chef/provider/windows_task.rb +4 -4
  89. data/lib/chef/resource.rb +1 -0
  90. data/lib/chef/resource/bash.rb +2 -0
  91. data/lib/chef/resource/batch.rb +2 -0
  92. data/lib/chef/resource/breakpoint.rb +3 -1
  93. data/lib/chef/resource/build_essential.rb +3 -3
  94. data/lib/chef/resource/chef_sleep.rb +70 -0
  95. data/lib/chef/resource/cookbook_file.rb +2 -1
  96. data/lib/chef/resource/csh.rb +2 -0
  97. data/lib/chef/resource/directory.rb +2 -0
  98. data/lib/chef/resource/dmg_package.rb +1 -1
  99. data/lib/chef/resource/dnf_package.rb +1 -1
  100. data/lib/chef/resource/execute.rb +2 -0
  101. data/lib/chef/resource/file.rb +2 -1
  102. data/lib/chef/resource/git.rb +2 -0
  103. data/lib/chef/resource/group.rb +1 -1
  104. data/lib/chef/resource/homebrew_package.rb +1 -1
  105. data/lib/chef/resource/http_request.rb +2 -0
  106. data/lib/chef/resource/ifconfig.rb +3 -1
  107. data/lib/chef/resource/ksh.rb +2 -0
  108. data/lib/chef/resource/link.rb +4 -2
  109. data/lib/chef/resource/locale.rb +1 -1
  110. data/lib/chef/resource/log.rb +2 -0
  111. data/lib/chef/resource/ohai.rb +2 -0
  112. data/lib/chef/resource/perl.rb +2 -0
  113. data/lib/chef/resource/python.rb +2 -0
  114. data/lib/chef/resource/reboot.rb +2 -0
  115. data/lib/chef/resource/registry_key.rb +2 -0
  116. data/lib/chef/resource/remote_directory.rb +3 -2
  117. data/lib/chef/resource/remote_file.rb +1 -0
  118. data/lib/chef/resource/ruby.rb +2 -0
  119. data/lib/chef/resource/ruby_block.rb +2 -0
  120. data/lib/chef/resource/scm.rb +2 -0
  121. data/lib/chef/resource/script.rb +2 -0
  122. data/lib/chef/resource/service.rb +9 -1
  123. data/lib/chef/resource/solaris_package.rb +1 -1
  124. data/lib/chef/resource/subversion.rb +2 -0
  125. data/lib/chef/resource/sudo.rb +1 -1
  126. data/lib/chef/resource/systemd_unit.rb +1 -0
  127. data/lib/chef/resource/template.rb +2 -0
  128. data/lib/chef/resource/user.rb +2 -0
  129. data/lib/chef/resource/user/aix_user.rb +2 -0
  130. data/lib/chef/resource/user/linux_user.rb +2 -0
  131. data/lib/chef/resource/user/pw_user.rb +2 -0
  132. data/lib/chef/resource/user/solaris_user.rb +2 -0
  133. data/lib/chef/resource/user/windows_user.rb +2 -0
  134. data/lib/chef/resource/whyrun_safe_ruby_block.rb +1 -0
  135. data/lib/chef/resource/windows_ad_join.rb +1 -1
  136. data/lib/chef/resource/windows_env.rb +1 -1
  137. data/lib/chef/resource/windows_feature.rb +2 -2
  138. data/lib/chef/resource/windows_feature_powershell.rb +1 -1
  139. data/lib/chef/resource/windows_firewall_rule.rb +11 -6
  140. data/lib/chef/resource/windows_script.rb +3 -1
  141. data/lib/chef/resource/yum_package.rb +1 -1
  142. data/lib/chef/resource_reporter.rb +1 -1
  143. data/lib/chef/resources.rb +1 -0
  144. data/lib/chef/run_context.rb +1 -1
  145. data/lib/chef/run_lock.rb +5 -5
  146. data/lib/chef/search/query.rb +0 -3
  147. data/lib/chef/train_transport.rb +3 -1
  148. data/lib/chef/util/powershell/ps_credential.rb +2 -2
  149. data/lib/chef/util/selinux.rb +1 -1
  150. data/lib/chef/util/windows/logon_session.rb +2 -2
  151. data/lib/chef/version.rb +1 -1
  152. data/lib/chef/win32/eventlog.rb +2 -2
  153. data/spec/data/cookbooks/starter/chefignore +8 -0
  154. data/spec/data/cookbooks/starter/files/sample.txt +1 -0
  155. data/spec/data/cookbooks/starter/metadata.rb +2 -0
  156. data/spec/data/cookbooks/starter/recipes/default.rb +4 -0
  157. data/spec/functional/event_loggers/windows_eventlog_spec.rb +1 -1
  158. data/spec/functional/mixin/user_context_spec.rb +2 -2
  159. data/spec/functional/rebooter_spec.rb +1 -1
  160. data/spec/functional/resource/cookbook_file_spec.rb +2 -2
  161. data/spec/functional/resource/template_spec.rb +1 -1
  162. data/spec/functional/version_spec.rb +1 -1
  163. data/spec/functional/win32/crypto_spec.rb +1 -1
  164. data/spec/functional/win32/security_spec.rb +1 -1
  165. data/spec/functional/win32/service_manager_spec.rb +1 -1
  166. data/spec/functional/win32/sid_spec.rb +2 -2
  167. data/spec/functional/win32/version_info_spec.rb +1 -1
  168. data/spec/functional/win32/versions_spec.rb +1 -1
  169. data/spec/integration/knife/config_get_profile_spec.rb +2 -2
  170. data/spec/integration/knife/config_get_spec.rb +9 -2
  171. data/spec/integration/knife/config_list_profiles_spec.rb +2 -2
  172. data/spec/integration/knife/config_use_profile_spec.rb +2 -2
  173. data/spec/integration/knife/list_spec.rb +2 -2
  174. data/spec/integration/solo/solo_spec.rb +1 -1
  175. data/spec/support/matchers/leak.rb +1 -1
  176. data/spec/support/mock/platform.rb +1 -1
  177. data/spec/support/platform_helpers.rb +2 -0
  178. data/spec/support/shared/integration/integration_helper.rb +1 -1
  179. data/spec/support/shared/integration/knife_support.rb +1 -1
  180. data/spec/support/shared/unit/provider/file.rb +4 -4
  181. data/spec/unit/application/client_spec.rb +2 -2
  182. data/spec/unit/application/knife_spec.rb +17 -0
  183. data/spec/unit/application_spec.rb +1 -1
  184. data/spec/unit/chef_fs/file_pattern_spec.rb +2 -2
  185. data/spec/unit/chef_fs/path_util_spec.rb +3 -3
  186. data/spec/unit/client_spec.rb +2 -2
  187. data/spec/unit/cookbook/chefignore_spec.rb +31 -11
  188. data/spec/unit/cookbook/cookbook_version_loader_spec.rb +1 -1
  189. data/spec/unit/cookbook/syntax_check_spec.rb +2 -2
  190. data/spec/unit/cookbook_loader_spec.rb +2 -2
  191. data/spec/unit/cookbook_uploader_spec.rb +6 -1
  192. data/spec/unit/data_bag_spec.rb +2 -2
  193. data/spec/unit/data_collector_spec.rb +7 -0
  194. data/spec/unit/dsl/platform_introspection_spec.rb +31 -1
  195. data/spec/unit/file_content_management/deploy/mv_windows_spec.rb +1 -1
  196. data/spec/unit/formatters/error_inspectors/compile_error_inspector_spec.rb +1 -1
  197. data/spec/unit/knife/cookbook_metadata_from_file_spec.rb +7 -0
  198. data/spec/unit/knife/cookbook_show_spec.rb +1 -1
  199. data/spec/unit/knife/core/gem_glob_loader_spec.rb +1 -1
  200. data/spec/unit/knife/core/hashed_command_loader_spec.rb +1 -1
  201. data/spec/unit/knife/core/subcommand_loader_spec.rb +1 -1
  202. data/spec/unit/knife/core/ui_spec.rb +2 -2
  203. data/spec/unit/knife/data_bag_from_file_spec.rb +2 -2
  204. data/spec/unit/knife/environment_from_file_spec.rb +2 -2
  205. data/spec/unit/knife/ssh_spec.rb +27 -17
  206. data/spec/unit/knife/status_spec.rb +1 -1
  207. data/spec/unit/knife/supermarket_install_spec.rb +1 -1
  208. data/spec/unit/mixin/path_sanity_spec.rb +3 -3
  209. data/spec/unit/mixin/shell_out_spec.rb +2 -3
  210. data/spec/unit/mixin/template_spec.rb +4 -4
  211. data/spec/unit/mixin/user_context_spec.rb +3 -3
  212. data/spec/unit/node_map_spec.rb +12 -12
  213. data/spec/unit/platform/query_helpers_spec.rb +9 -9
  214. data/spec/unit/provider/execute_spec.rb +1 -1
  215. data/spec/unit/provider/link_spec.rb +5 -5
  216. data/spec/unit/provider/package/openbsd_spec.rb +1 -1
  217. data/spec/unit/provider/package/smartos_spec.rb +1 -1
  218. data/spec/unit/provider/package/windows/exe_spec.rb +1 -1
  219. data/spec/unit/provider/package/windows_spec.rb +2 -2
  220. data/spec/unit/provider/remote_file/fetcher_spec.rb +2 -2
  221. data/spec/unit/provider/remote_file/local_file_spec.rb +1 -1
  222. data/spec/unit/provider/remote_file/network_file_spec.rb +1 -1
  223. data/spec/unit/provider/script_spec.rb +2 -2
  224. data/spec/unit/provider/service/systemd_service_spec.rb +26 -2
  225. data/spec/unit/provider/subversion_spec.rb +3 -3
  226. data/spec/unit/provider/systemd_unit_spec.rb +53 -4
  227. data/spec/unit/provider/user/dscl_spec.rb +1 -1
  228. data/spec/unit/provider_resolver_spec.rb +41 -61
  229. data/spec/unit/resource/chef_sleep_spec.rb +30 -0
  230. data/spec/unit/resource/cookbook_file_spec.rb +3 -3
  231. data/spec/unit/resource/remote_file_spec.rb +3 -3
  232. data/spec/unit/resource/windows_firewall_rule_spec.rb +69 -12
  233. data/spec/unit/role_spec.rb +2 -2
  234. data/spec/unit/shell_spec.rb +1 -1
  235. data/spec/unit/util/selinux_spec.rb +2 -2
  236. data/spec/unit/win32/error_spec.rb +1 -1
  237. data/spec/unit/win32/link_spec.rb +1 -1
  238. data/spec/unit/win32/security_spec.rb +1 -1
  239. data/spec/unit/windows_service_spec.rb +1 -1
  240. data/tasks/docs.rb +10 -2
  241. data/tasks/rspec.rb +8 -6
  242. metadata +32 -8
  243. data/lib/chef/mixin/train_helpers.rb +0 -60
  244. data/spec/unit/mash_spec.rb +0 -51
@@ -23,7 +23,7 @@ require_relative "version_string"
23
23
 
24
24
  class Chef
25
25
  CHEF_ROOT = File.expand_path("../..", __FILE__)
26
- VERSION = Chef::VersionString.new("15.4.45")
26
+ VERSION = Chef::VersionString.new("15.5.9")
27
27
  end
28
28
 
29
29
  #
@@ -1,7 +1,7 @@
1
1
  #
2
2
  # Author:: Jay Mundrawala (<jdm@chef.io>)
3
3
  #
4
- # Copyright:: Copyright 2015-2016, Chef Software, Inc.
4
+ # Copyright:: Copyright 2015-2019, Chef Software Inc.
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
7
7
  # you may not use this file except in compliance with the License.
@@ -16,7 +16,7 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- if Chef::Platform.windows?
19
+ if ChefUtils.windows?
20
20
  unless defined? Chef::Win32EventLogLoaded
21
21
  if defined? Windows::Constants
22
22
  %i{INFINITE WAIT_FAILED FORMAT_MESSAGE_IGNORE_INSERTS ERROR_INSUFFICIENT_BUFFER}.each do |c|
@@ -0,0 +1,8 @@
1
+ #
2
+ # The ignore file allows you to skip files in cookbooks with the same name that appear
3
+ # later in the search path.
4
+ #
5
+
6
+ recipes/default.rb
7
+ # comments can be indented
8
+ ignored
@@ -0,0 +1 @@
1
+ This is a Chef cookbook file. It is used to copy content verbatim on to a server.
@@ -0,0 +1,2 @@
1
+ name "starter"
2
+ version "1.0.0"
@@ -0,0 +1,4 @@
1
+ # This is a Chef recipe file. It can be used to specify resources which will
2
+ # apply configuration to a server.
3
+
4
+ # For more information, see the documentation: https://docs.chef.io/essentials_cookbook_recipes.html
@@ -19,7 +19,7 @@
19
19
  require "spec_helper"
20
20
  require "securerandom"
21
21
  require "chef/event_loggers/windows_eventlog"
22
- if Chef::Platform.windows?
22
+ if ChefUtils.windows?
23
23
  require "win32/eventlog"
24
24
  include Win32
25
25
  end
@@ -17,8 +17,8 @@
17
17
 
18
18
  require "spec_helper"
19
19
 
20
- require "chef/win32/api" if Chef::Platform.windows?
21
- require "chef/win32/api/error" if Chef::Platform.windows?
20
+ require "chef/win32/api" if ChefUtils.windows?
21
+ require "chef/win32/api/error" if ChefUtils.windows?
22
22
  require "chef/mixin/user_context"
23
23
 
24
24
  describe Chef::Mixin::UserContext, windows_only: true do
@@ -72,7 +72,7 @@ describe Chef::Platform::Rebooter do
72
72
 
73
73
  shared_context "test a reboot method" do
74
74
  def test_rebooter_method(method_sym, is_windows, is_solaris, expected_reboot_str)
75
- allow(ChefConfig).to receive(:windows?).and_return(is_windows)
75
+ allow(ChefUtils).to receive(:windows?).and_return(is_windows)
76
76
  node.automatic["os"] = node.automatic["platform"] = node.automatic["platform_family"] = "solaris2" if is_solaris
77
77
  expect(rebooter).to receive(:shell_out!).once.with(expected_reboot_str)
78
78
  expect(rebooter).to receive(:raise).with(Chef::Exceptions::Reboot)
@@ -68,11 +68,11 @@ describe Chef::Resource::CookbookFile do
68
68
  let(:path) { File.join(windows_non_temp_dir, make_tmpname(file_base)) }
69
69
 
70
70
  before do
71
- FileUtils.mkdir_p(windows_non_temp_dir) if Chef::Platform.windows?
71
+ FileUtils.mkdir_p(windows_non_temp_dir) if ChefUtils.windows?
72
72
  end
73
73
 
74
74
  after do
75
- FileUtils.rm_r(windows_non_temp_dir) if Chef::Platform.windows? && File.exists?(windows_non_temp_dir)
75
+ FileUtils.rm_r(windows_non_temp_dir) if ChefUtils.windows? && File.exists?(windows_non_temp_dir)
76
76
  end
77
77
 
78
78
  end
@@ -203,7 +203,7 @@ describe Chef::Resource::Template do
203
203
  it "output should contain platform's line endings" do
204
204
  resource.run_action(:create)
205
205
  binread(path).each_line do |line|
206
- expect(line).to end_with(Chef::Platform.windows? ? "\r\n" : "\n")
206
+ expect(line).to end_with(ChefUtils.windows? ? "\r\n" : "\n")
207
207
  end
208
208
  end
209
209
  end
@@ -21,7 +21,7 @@ require "chef/version"
21
21
  require "ohai/version"
22
22
  require "chef/dist"
23
23
 
24
- describe "Chef Versions" do
24
+ describe "Chef Versions", :executables do
25
25
  include Chef::Mixin::ShellOut
26
26
  let(:chef_dir) { File.join(File.dirname(__FILE__), "..", "..") }
27
27
 
@@ -17,7 +17,7 @@
17
17
  #
18
18
 
19
19
  require "spec_helper"
20
- if Chef::Platform.windows?
20
+ if ChefUtils.windows?
21
21
  require "chef/win32/crypto"
22
22
  end
23
23
 
@@ -19,7 +19,7 @@
19
19
  require "spec_helper"
20
20
  require "mixlib/shellout"
21
21
  require "chef/mixin/user_context"
22
- if Chef::Platform.windows?
22
+ if ChefUtils.windows?
23
23
  require "chef/win32/security"
24
24
  end
25
25
 
@@ -17,7 +17,7 @@
17
17
  #
18
18
 
19
19
  require "spec_helper"
20
- if Chef::Platform.windows?
20
+ if ChefUtils.windows?
21
21
  require "chef/application/windows_service_manager"
22
22
  end
23
23
 
@@ -17,12 +17,12 @@
17
17
  #
18
18
 
19
19
  require "spec_helper"
20
- if Chef::Platform.windows?
20
+ if ChefUtils.windows?
21
21
  require "chef/win32/security"
22
22
  end
23
23
 
24
24
  describe "Chef::ReservedNames::Win32::SID", :windows_only do
25
- if Chef::Platform.windows?
25
+ if ChefUtils.windows?
26
26
  SID ||= Chef::ReservedNames::Win32::Security::SID
27
27
  end
28
28
 
@@ -17,7 +17,7 @@
17
17
  #
18
18
 
19
19
  require "spec_helper"
20
- if Chef::Platform.windows?
20
+ if ChefUtils.windows?
21
21
  require "chef/win32/file/version_info"
22
22
  end
23
23
 
@@ -17,7 +17,7 @@
17
17
  #
18
18
 
19
19
  require "spec_helper"
20
- if Chef::Platform.windows?
20
+ if ChefUtils.windows?
21
21
  require "chef/win32/version"
22
22
  end
23
23
 
@@ -50,7 +50,7 @@ describe "knife config get-profile", :workstation do
50
50
  ENV["KNIFE_HOME"] = old_knife_home
51
51
  ENV["HOME"] = old_home
52
52
  Dir.chdir(old_wd)
53
- ENV[ChefConfig.windows? ? "CD" : "PWD"] = Dir.pwd
53
+ ENV[ChefUtils.windows? ? "CD" : "PWD"] = Dir.pwd
54
54
  ChefConfig::PathHelper.per_tool_home_environment = nil
55
55
  end
56
56
  end
@@ -60,7 +60,7 @@ describe "knife config get-profile", :workstation do
60
60
  # because it has to run after the before set in the "with a chef repo" shared context.
61
61
  directory("repo")
62
62
  Dir.chdir(path_to("repo"))
63
- ENV[ChefConfig.windows? ? "CD" : "PWD"] = Dir.pwd
63
+ ENV[ChefUtils.windows? ? "CD" : "PWD"] = Dir.pwd
64
64
  ENV["HOME"] = path_to(".")
65
65
  end
66
66
 
@@ -54,7 +54,7 @@ describe "knife config get", :workstation do
54
54
  ENV["KNIFE_HOME"] = old_knife_home
55
55
  ENV["HOME"] = old_home
56
56
  Dir.chdir(old_wd)
57
- ENV[ChefConfig.windows? ? "CD" : "PWD"] = Dir.pwd
57
+ ENV[ChefUtils.windows? ? "CD" : "PWD"] = Dir.pwd
58
58
  ChefConfig::PathHelper.per_tool_home_environment = nil
59
59
  end
60
60
  end
@@ -64,7 +64,7 @@ describe "knife config get", :workstation do
64
64
  # because it has to run after the before set in the "with a chef repo" shared context.
65
65
  directory("repo")
66
66
  Dir.chdir(path_to("repo"))
67
- ENV[ChefConfig.windows? ? "CD" : "PWD"] = Dir.pwd
67
+ ENV[ChefUtils.windows? ? "CD" : "PWD"] = Dir.pwd
68
68
  ENV["HOME"] = path_to(".")
69
69
  end
70
70
 
@@ -110,6 +110,13 @@ describe "knife config get", :workstation do
110
110
  it { is_expected.to match(/^node_name:\s+one$/) }
111
111
  end
112
112
 
113
+ context "with a config dot d files" do
114
+ before { file(".chef/config.d/abc.rb", "node_name 'one'\n") }
115
+
116
+ it { is_expected.to match(%r{^Loading from .d/ configuration file .*/#{File.basename(path_to("."))}/.chef/config.d/abc.rb$}) }
117
+ it { is_expected.to match(/^node_name:\s+one$/) }
118
+ end
119
+
113
120
  context "with a credentials file and CHEF_HOME" do
114
121
  before do
115
122
  file(".chef/credentials", "[default]\nclient_name = \"three\"\n")
@@ -44,7 +44,7 @@ describe "knife config list-profiles", :workstation do
44
44
  ensure
45
45
  ENV["HOME"] = old_home
46
46
  Dir.chdir(old_wd)
47
- ENV[ChefConfig.windows? ? "CD" : "PWD"] = Dir.pwd
47
+ ENV[ChefUtils.windows? ? "CD" : "PWD"] = Dir.pwd
48
48
  end
49
49
  end
50
50
 
@@ -53,7 +53,7 @@ describe "knife config list-profiles", :workstation do
53
53
  # because it has to run after the before set in the "with a chef repo" shared context.
54
54
  directory("repo")
55
55
  Dir.chdir(path_to("repo"))
56
- ENV[ChefConfig.windows? ? "CD" : "PWD"] = Dir.pwd
56
+ ENV[ChefUtils.windows? ? "CD" : "PWD"] = Dir.pwd
57
57
  ENV["HOME"] = path_to(".")
58
58
  end
59
59
 
@@ -51,7 +51,7 @@ describe "knife config use-profile", :workstation do
51
51
  ENV["KNIFE_HOME"] = old_knife_home
52
52
  ENV["HOME"] = old_home
53
53
  Dir.chdir(old_wd)
54
- ENV[ChefConfig.windows? ? "CD" : "PWD"] = Dir.pwd
54
+ ENV[ChefUtils.windows? ? "CD" : "PWD"] = Dir.pwd
55
55
  ChefConfig::PathHelper.per_tool_home_environment = nil
56
56
  end
57
57
  end
@@ -61,7 +61,7 @@ describe "knife config use-profile", :workstation do
61
61
  # because it has to run after the before set in the "with a chef repo" shared context.
62
62
  directory("repo")
63
63
  Dir.chdir(path_to("repo"))
64
- ENV[ChefConfig.windows? ? "CD" : "PWD"] = Dir.pwd
64
+ ENV[ChefUtils.windows? ? "CD" : "PWD"] = Dir.pwd
65
65
  ENV["HOME"] = path_to(".")
66
66
  end
67
67
 
@@ -466,7 +466,7 @@ describe "knife list", :workstation do
466
466
  end
467
467
  end
468
468
 
469
- when_the_repository "has a cookbooks directory and a symlinked cookbooks directory", skip: (Chef::Platform.windows?) do
469
+ when_the_repository "has a cookbooks directory and a symlinked cookbooks directory", skip: (ChefUtils.windows?) do
470
470
  before do
471
471
  directory "cookbooks"
472
472
  symlink "symlinked", "cookbooks"
@@ -503,7 +503,7 @@ describe "knife list", :workstation do
503
503
  end
504
504
  end
505
505
 
506
- when_the_repository "has a real_cookbooks directory and a cookbooks symlink to it", skip: (Chef::Platform.windows?) do
506
+ when_the_repository "has a real_cookbooks directory and a cookbooks symlink to it", skip: (ChefUtils.windows?) do
507
507
  before do
508
508
  directory "real_cookbooks"
509
509
  symlink "cookbooks", "real_cookbooks"
@@ -4,7 +4,7 @@ require "chef/run_lock"
4
4
  require "chef/config"
5
5
  require "timeout"
6
6
  require "fileutils"
7
- require "chef/win32/security" if Chef::Platform.windows?
7
+ require "chef/win32/security" if ChefUtils.windows?
8
8
  require "chef/dist"
9
9
 
10
10
  describe Chef::Dist::SOLOEXEC do
@@ -60,7 +60,7 @@ module Matchers
60
60
 
61
61
  def profiler
62
62
  @profiler ||= begin
63
- if Chef::Platform.windows?
63
+ if ChefUtils.windows?
64
64
  require File.join(File.dirname(__FILE__), "..", "platforms", "prof", "win32")
65
65
  RSpec::Prof::Win32::Profiler.new
66
66
  else
@@ -6,7 +6,7 @@
6
6
  # testing code that mixes in platform specific modules like +Chef::Mixin::Securable+
7
7
  # or +Chef::FileAccessControl+
8
8
  def platform_mock(platform = :unix)
9
- allow(ChefConfig).to receive(:windows?).and_return(platform == :windows ? true : false)
9
+ allow(ChefUtils).to receive(:windows?).and_return(platform == :windows ? true : false)
10
10
  ENV["SYSTEMDRIVE"] = (platform == :windows ? "C:" : nil)
11
11
 
12
12
  if platform == :windows
@@ -35,6 +35,8 @@ def ruby_32bit?
35
35
  end
36
36
 
37
37
  def windows?
38
+ # NOTE this deliberately does not use ChefUtils.windows? because otherwise it would
39
+ # pick up the node out of tests, while this tests the hosts running the specs.
38
40
  !!(RUBY_PLATFORM =~ /mswin|mingw|windows/)
39
41
  end
40
42
 
@@ -128,7 +128,7 @@ module IntegrationSupport
128
128
  # TODO: "force" actually means "silence all exceptions". this
129
129
  # silences a weird permissions error on Windows that we should track
130
130
  # down, but for now there's no reason for it to blow up our CI.
131
- FileUtils.remove_entry_secure(@repository_dir, force = Chef::Platform.windows?)
131
+ FileUtils.remove_entry_secure(@repository_dir, force = ChefUtils.windows?)
132
132
  ensure
133
133
  @repository_dir = nil
134
134
  end
@@ -181,7 +181,7 @@ module KnifeSupport
181
181
  expect(stderr_actual).to eq(expected[:stderr])
182
182
  end
183
183
  stdout_actual = @stdout
184
- if Chef::Platform.windows?
184
+ if ChefUtils.windows?
185
185
  stderr_actual = stderr_actual.gsub("\r\n", "\n")
186
186
  stdout_actual = stdout_actual.gsub("\r\n", "\n")
187
187
  end
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Lamont Granquist (<lamont@chef.io>)
3
- # Copyright:: Copyright 2013-2016, Chef Software, Inc.
3
+ # Copyright:: Copyright 2013-2018, Chef Software Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -256,7 +256,7 @@ shared_examples_for Chef::Provider::File do
256
256
  context "examining file security metadata on Unix with a file that exists" do
257
257
  before do
258
258
  # fake that we're on unix even if we're on windows
259
- allow(ChefConfig).to receive(:windows?).and_return(false)
259
+ allow(ChefUtils).to receive(:windows?).and_return(false)
260
260
  # mock up the filesystem to behave like unix
261
261
  setup_normal_file
262
262
  stat_struct = double("::File.stat", mode: 0600, uid: 0, gid: 0, mtime: 10000)
@@ -332,7 +332,7 @@ shared_examples_for Chef::Provider::File do
332
332
  context "examining file security metadata on Unix with a file that does not exist" do
333
333
  before do
334
334
  # fake that we're on unix even if we're on windows
335
- allow(ChefConfig).to receive(:windows?).and_return(false)
335
+ allow(ChefUtils).to receive(:windows?).and_return(false)
336
336
  setup_missing_file
337
337
  end
338
338
 
@@ -381,7 +381,7 @@ shared_examples_for Chef::Provider::File do
381
381
 
382
382
  before do
383
383
  # fake that we're on unix even if we're on windows
384
- allow(ChefConfig).to receive(:windows?).and_return(false)
384
+ allow(ChefUtils).to receive(:windows?).and_return(false)
385
385
  # mock up the filesystem to behave like unix
386
386
  setup_normal_file
387
387
  stat_struct = double("::File.stat", mode: 0600, uid: 0, gid: 0, mtime: 10000)
@@ -323,7 +323,7 @@ describe Chef::Application::Client, "reconfigure" do
323
323
 
324
324
  it "should terminate with message when interval is given" do
325
325
  Chef::Config[:interval] = 600
326
- allow(ChefConfig).to receive(:windows?).and_return(false)
326
+ allow(ChefUtils).to receive(:windows?).and_return(false)
327
327
  expect(Chef::Application).to receive(:fatal!).with(
328
328
  /Unforked .* interval runs are disabled by default\.
329
329
  Configuration settings:
@@ -336,7 +336,7 @@ Enable .* interval runs by setting `:client_fork = true` in your config file or
336
336
  context "when interval is given on windows" do
337
337
  before do
338
338
  Chef::Config[:interval] = 600
339
- allow(ChefConfig).to receive(:windows?).and_return(true)
339
+ allow(ChefUtils).to receive(:windows?).and_return(true)
340
340
  end
341
341
 
342
342
  it "should terminate" do
@@ -77,6 +77,23 @@ describe Chef::Application::Knife do
77
77
  expect(Chef::Config[:color]).to be_truthy
78
78
  end
79
79
 
80
+ context "validate --format option" do
81
+ it "should set the default format summary" do
82
+ with_argv(*%w{noop knife command}) do
83
+ expect(@knife).to receive(:exit).with(0)
84
+ @knife.run
85
+ expect(@knife.default_config[:format]).to eq("summary")
86
+ end
87
+ end
88
+
89
+ it "should raise the error for invalid value" do
90
+ with_argv(*%w{noop knife command -F abc}) do
91
+ expect(STDOUT).to receive(:puts).at_least(2).times
92
+ expect { @knife.run }.to raise_error(SystemExit) { |e| expect(e.status).to eq(2) }
93
+ end
94
+ end
95
+ end
96
+
80
97
  context "when given fips flags" do
81
98
  context "when Chef::Config[:fips]=false" do
82
99
  before do
@@ -277,7 +277,7 @@ describe Chef::Application do
277
277
  end
278
278
  end
279
279
 
280
- if Chef::Platform.windows?
280
+ if ChefUtils.windows?
281
281
  it_behaves_like "sets log_location", :win_evt, Chef::Log::WinEvt
282
282
  it_behaves_like "sets log_location", "win_evt", Chef::Log::WinEvt
283
283
  else
@@ -157,7 +157,7 @@ describe Chef::ChefFS::FilePattern do
157
157
  end
158
158
  end
159
159
 
160
- context 'with simple pattern "a\*\b"', skip: (Chef::Platform.windows?) do
160
+ context 'with simple pattern "a\*\b"', skip: (ChefUtils.windows?) do
161
161
  let(:pattern) { Chef::ChefFS::FilePattern.new('a\*\b') }
162
162
  it "match?" do
163
163
  expect(pattern.match?("a*b")).to be_truthy
@@ -264,7 +264,7 @@ describe Chef::ChefFS::FilePattern do
264
264
  end
265
265
  end
266
266
 
267
- context 'with star pattern "/abc/d[a-z][0-9]f/ghi"', skip: (Chef::Platform.windows?) do
267
+ context 'with star pattern "/abc/d[a-z][0-9]f/ghi"', skip: (ChefUtils.windows?) do
268
268
  let(:pattern) { Chef::ChefFS::FilePattern.new("/abc/d[a-z][0-9]f/ghi") }
269
269
  it "match?" do
270
270
  expect(pattern.match?("/abc/de1f/ghi")).to be_truthy