chef 15.4.45-universal-mingw32 → 15.5.9-universal-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (246) 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/ext/win32-eventlog/Rakefile +9 -1
  6. data/ext/win32-eventlog/{chef-log.man → chef-log.man.erb} +4 -4
  7. data/lib/chef/application.rb +2 -2
  8. data/lib/chef/application/client.rb +1 -1
  9. data/lib/chef/application/knife.rb +1 -0
  10. data/lib/chef/application/solo.rb +1 -1
  11. data/lib/chef/chef_class.rb +1 -6
  12. data/lib/chef/chef_fs.rb +1 -1
  13. data/lib/chef/chef_fs/file_pattern.rb +1 -1
  14. data/lib/chef/chef_fs/file_system/chef_server/cookbook_artifacts_dir.rb +2 -2
  15. data/lib/chef/chef_fs/file_system/chef_server/versioned_cookbooks_dir.rb +2 -2
  16. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_artifact_dir.rb +1 -1
  17. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb +7 -1
  18. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb +4 -3
  19. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb +3 -3
  20. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_versioned_cookbook_dir.rb +1 -1
  21. data/lib/chef/chef_fs/file_system/repository/nodes_dir.rb +3 -3
  22. data/lib/chef/chef_fs/knife.rb +1 -1
  23. data/lib/chef/chef_fs/path_utils.rb +2 -2
  24. data/lib/chef/client.rb +4 -5
  25. data/lib/chef/config.rb +3 -2
  26. data/lib/chef/cookbook/chefignore.rb +16 -11
  27. data/lib/chef/cookbook/cookbook_version_loader.rb +1 -1
  28. data/lib/chef/cookbook/syntax_check.rb +5 -3
  29. data/lib/chef/cookbook_loader.rb +3 -3
  30. data/lib/chef/cookbook_uploader.rb +1 -1
  31. data/lib/chef/data_collector.rb +2 -2
  32. data/lib/chef/data_collector/run_end_message.rb +1 -0
  33. data/lib/chef/deprecated.rb +4 -0
  34. data/lib/chef/dsl/core.rb +1 -1
  35. data/lib/chef/dsl/platform_introspection.rb +9 -18
  36. data/lib/chef/event_loggers/windows_eventlog.rb +1 -1
  37. data/lib/chef/file_content_management/deploy.rb +3 -3
  38. data/lib/chef/file_content_management/deploy/mv_windows.rb +2 -2
  39. data/lib/chef/file_content_management/tempfile.rb +1 -1
  40. data/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb +2 -2
  41. data/lib/chef/http.rb +1 -1
  42. data/lib/chef/http/socketless_chef_zero_client.rb +1 -1
  43. data/lib/chef/knife.rb +4 -3
  44. data/lib/chef/knife/config_get.rb +2 -1
  45. data/lib/chef/knife/configure.rb +1 -1
  46. data/lib/chef/knife/cookbook_metadata_from_file.rb +6 -0
  47. data/lib/chef/knife/core/generic_presenter.rb +1 -1
  48. data/lib/chef/knife/core/status_presenter.rb +1 -1
  49. data/lib/chef/knife/ssh.rb +6 -0
  50. data/lib/chef/local_mode.rb +1 -1
  51. data/lib/chef/mash.rb +21 -232
  52. data/lib/chef/mixin/file_class.rb +2 -2
  53. data/lib/chef/mixin/lazy_module_include.rb +1 -1
  54. data/lib/chef/mixin/path_sanity.rb +3 -39
  55. data/lib/chef/mixin/securable.rb +1 -1
  56. data/lib/chef/mixin/shell_out.rb +4 -5
  57. data/lib/chef/mixin/template.rb +1 -1
  58. data/lib/chef/mixin/user_context.rb +3 -3
  59. data/lib/chef/mixin/which.rb +10 -38
  60. data/lib/chef/mixin/windows_architecture_helper.rb +6 -6
  61. data/lib/chef/mixin/windows_env_helper.rb +5 -5
  62. data/lib/chef/node/attribute.rb +2 -2
  63. data/lib/chef/node_map.rb +17 -4
  64. data/lib/chef/platform/query_helpers.rb +4 -2
  65. data/lib/chef/platform/rebooter.rb +1 -1
  66. data/lib/chef/platform/service_helpers.rb +14 -85
  67. data/lib/chef/provider.rb +2 -0
  68. data/lib/chef/provider/file.rb +2 -2
  69. data/lib/chef/provider/ifconfig/redhat.rb +1 -1
  70. data/lib/chef/provider/link.rb +3 -3
  71. data/lib/chef/provider/mount/solaris.rb +1 -1
  72. data/lib/chef/provider/package/yum.rb +1 -1
  73. data/lib/chef/provider/registry_key.rb +1 -1
  74. data/lib/chef/provider/remote_directory.rb +3 -3
  75. data/lib/chef/provider/remote_file/fetcher.rb +2 -2
  76. data/lib/chef/provider/remote_file/local_file.rb +1 -1
  77. data/lib/chef/provider/script.rb +3 -3
  78. data/lib/chef/provider/service.rb +5 -2
  79. data/lib/chef/provider/service/arch.rb +1 -1
  80. data/lib/chef/provider/service/debian.rb +4 -4
  81. data/lib/chef/provider/service/init.rb +1 -1
  82. data/lib/chef/provider/service/insserv.rb +4 -4
  83. data/lib/chef/provider/service/invokercd.rb +4 -4
  84. data/lib/chef/provider/service/redhat.rb +4 -4
  85. data/lib/chef/provider/service/systemd.rb +19 -3
  86. data/lib/chef/provider/service/upstart.rb +3 -3
  87. data/lib/chef/provider/subversion.rb +1 -1
  88. data/lib/chef/provider/systemd_unit.rb +26 -2
  89. data/lib/chef/provider/windows_path.rb +3 -3
  90. data/lib/chef/provider/windows_task.rb +4 -4
  91. data/lib/chef/resource.rb +1 -0
  92. data/lib/chef/resource/bash.rb +2 -0
  93. data/lib/chef/resource/batch.rb +2 -0
  94. data/lib/chef/resource/breakpoint.rb +3 -1
  95. data/lib/chef/resource/build_essential.rb +3 -3
  96. data/lib/chef/resource/chef_sleep.rb +70 -0
  97. data/lib/chef/resource/cookbook_file.rb +2 -1
  98. data/lib/chef/resource/csh.rb +2 -0
  99. data/lib/chef/resource/directory.rb +2 -0
  100. data/lib/chef/resource/dmg_package.rb +1 -1
  101. data/lib/chef/resource/dnf_package.rb +1 -1
  102. data/lib/chef/resource/execute.rb +2 -0
  103. data/lib/chef/resource/file.rb +2 -1
  104. data/lib/chef/resource/git.rb +2 -0
  105. data/lib/chef/resource/group.rb +1 -1
  106. data/lib/chef/resource/homebrew_package.rb +1 -1
  107. data/lib/chef/resource/http_request.rb +2 -0
  108. data/lib/chef/resource/ifconfig.rb +3 -1
  109. data/lib/chef/resource/ksh.rb +2 -0
  110. data/lib/chef/resource/link.rb +4 -2
  111. data/lib/chef/resource/locale.rb +1 -1
  112. data/lib/chef/resource/log.rb +2 -0
  113. data/lib/chef/resource/ohai.rb +2 -0
  114. data/lib/chef/resource/perl.rb +2 -0
  115. data/lib/chef/resource/python.rb +2 -0
  116. data/lib/chef/resource/reboot.rb +2 -0
  117. data/lib/chef/resource/registry_key.rb +2 -0
  118. data/lib/chef/resource/remote_directory.rb +3 -2
  119. data/lib/chef/resource/remote_file.rb +1 -0
  120. data/lib/chef/resource/ruby.rb +2 -0
  121. data/lib/chef/resource/ruby_block.rb +2 -0
  122. data/lib/chef/resource/scm.rb +2 -0
  123. data/lib/chef/resource/script.rb +2 -0
  124. data/lib/chef/resource/service.rb +9 -1
  125. data/lib/chef/resource/solaris_package.rb +1 -1
  126. data/lib/chef/resource/subversion.rb +2 -0
  127. data/lib/chef/resource/sudo.rb +1 -1
  128. data/lib/chef/resource/systemd_unit.rb +1 -0
  129. data/lib/chef/resource/template.rb +2 -0
  130. data/lib/chef/resource/user.rb +2 -0
  131. data/lib/chef/resource/user/aix_user.rb +2 -0
  132. data/lib/chef/resource/user/linux_user.rb +2 -0
  133. data/lib/chef/resource/user/pw_user.rb +2 -0
  134. data/lib/chef/resource/user/solaris_user.rb +2 -0
  135. data/lib/chef/resource/user/windows_user.rb +2 -0
  136. data/lib/chef/resource/whyrun_safe_ruby_block.rb +1 -0
  137. data/lib/chef/resource/windows_ad_join.rb +1 -1
  138. data/lib/chef/resource/windows_env.rb +1 -1
  139. data/lib/chef/resource/windows_feature.rb +2 -2
  140. data/lib/chef/resource/windows_feature_powershell.rb +1 -1
  141. data/lib/chef/resource/windows_firewall_rule.rb +11 -6
  142. data/lib/chef/resource/windows_script.rb +3 -1
  143. data/lib/chef/resource/yum_package.rb +1 -1
  144. data/lib/chef/resource_reporter.rb +1 -1
  145. data/lib/chef/resources.rb +1 -0
  146. data/lib/chef/run_context.rb +1 -1
  147. data/lib/chef/run_lock.rb +5 -5
  148. data/lib/chef/search/query.rb +0 -3
  149. data/lib/chef/train_transport.rb +3 -1
  150. data/lib/chef/util/powershell/ps_credential.rb +2 -2
  151. data/lib/chef/util/selinux.rb +1 -1
  152. data/lib/chef/util/windows/logon_session.rb +2 -2
  153. data/lib/chef/version.rb +1 -1
  154. data/lib/chef/win32/eventlog.rb +2 -2
  155. data/spec/data/cookbooks/starter/chefignore +8 -0
  156. data/spec/data/cookbooks/starter/files/sample.txt +1 -0
  157. data/spec/data/cookbooks/starter/metadata.rb +2 -0
  158. data/spec/data/cookbooks/starter/recipes/default.rb +4 -0
  159. data/spec/functional/event_loggers/windows_eventlog_spec.rb +1 -1
  160. data/spec/functional/mixin/user_context_spec.rb +2 -2
  161. data/spec/functional/rebooter_spec.rb +1 -1
  162. data/spec/functional/resource/cookbook_file_spec.rb +2 -2
  163. data/spec/functional/resource/template_spec.rb +1 -1
  164. data/spec/functional/version_spec.rb +1 -1
  165. data/spec/functional/win32/crypto_spec.rb +1 -1
  166. data/spec/functional/win32/security_spec.rb +1 -1
  167. data/spec/functional/win32/service_manager_spec.rb +1 -1
  168. data/spec/functional/win32/sid_spec.rb +2 -2
  169. data/spec/functional/win32/version_info_spec.rb +1 -1
  170. data/spec/functional/win32/versions_spec.rb +1 -1
  171. data/spec/integration/knife/config_get_profile_spec.rb +2 -2
  172. data/spec/integration/knife/config_get_spec.rb +9 -2
  173. data/spec/integration/knife/config_list_profiles_spec.rb +2 -2
  174. data/spec/integration/knife/config_use_profile_spec.rb +2 -2
  175. data/spec/integration/knife/list_spec.rb +2 -2
  176. data/spec/integration/solo/solo_spec.rb +1 -1
  177. data/spec/support/matchers/leak.rb +1 -1
  178. data/spec/support/mock/platform.rb +1 -1
  179. data/spec/support/platform_helpers.rb +2 -0
  180. data/spec/support/shared/integration/integration_helper.rb +1 -1
  181. data/spec/support/shared/integration/knife_support.rb +1 -1
  182. data/spec/support/shared/unit/provider/file.rb +4 -4
  183. data/spec/unit/application/client_spec.rb +2 -2
  184. data/spec/unit/application/knife_spec.rb +17 -0
  185. data/spec/unit/application_spec.rb +1 -1
  186. data/spec/unit/chef_fs/file_pattern_spec.rb +2 -2
  187. data/spec/unit/chef_fs/path_util_spec.rb +3 -3
  188. data/spec/unit/client_spec.rb +2 -2
  189. data/spec/unit/cookbook/chefignore_spec.rb +31 -11
  190. data/spec/unit/cookbook/cookbook_version_loader_spec.rb +1 -1
  191. data/spec/unit/cookbook/syntax_check_spec.rb +2 -2
  192. data/spec/unit/cookbook_loader_spec.rb +2 -2
  193. data/spec/unit/cookbook_uploader_spec.rb +6 -1
  194. data/spec/unit/data_bag_spec.rb +2 -2
  195. data/spec/unit/data_collector_spec.rb +7 -0
  196. data/spec/unit/dsl/platform_introspection_spec.rb +31 -1
  197. data/spec/unit/file_content_management/deploy/mv_windows_spec.rb +1 -1
  198. data/spec/unit/formatters/error_inspectors/compile_error_inspector_spec.rb +1 -1
  199. data/spec/unit/knife/cookbook_metadata_from_file_spec.rb +7 -0
  200. data/spec/unit/knife/cookbook_show_spec.rb +1 -1
  201. data/spec/unit/knife/core/gem_glob_loader_spec.rb +1 -1
  202. data/spec/unit/knife/core/hashed_command_loader_spec.rb +1 -1
  203. data/spec/unit/knife/core/subcommand_loader_spec.rb +1 -1
  204. data/spec/unit/knife/core/ui_spec.rb +2 -2
  205. data/spec/unit/knife/data_bag_from_file_spec.rb +2 -2
  206. data/spec/unit/knife/environment_from_file_spec.rb +2 -2
  207. data/spec/unit/knife/ssh_spec.rb +27 -17
  208. data/spec/unit/knife/status_spec.rb +1 -1
  209. data/spec/unit/knife/supermarket_install_spec.rb +1 -1
  210. data/spec/unit/mixin/path_sanity_spec.rb +3 -3
  211. data/spec/unit/mixin/shell_out_spec.rb +2 -3
  212. data/spec/unit/mixin/template_spec.rb +4 -4
  213. data/spec/unit/mixin/user_context_spec.rb +3 -3
  214. data/spec/unit/node_map_spec.rb +12 -12
  215. data/spec/unit/platform/query_helpers_spec.rb +9 -9
  216. data/spec/unit/provider/execute_spec.rb +1 -1
  217. data/spec/unit/provider/link_spec.rb +5 -5
  218. data/spec/unit/provider/package/openbsd_spec.rb +1 -1
  219. data/spec/unit/provider/package/smartos_spec.rb +1 -1
  220. data/spec/unit/provider/package/windows/exe_spec.rb +1 -1
  221. data/spec/unit/provider/package/windows_spec.rb +2 -2
  222. data/spec/unit/provider/remote_file/fetcher_spec.rb +2 -2
  223. data/spec/unit/provider/remote_file/local_file_spec.rb +1 -1
  224. data/spec/unit/provider/remote_file/network_file_spec.rb +1 -1
  225. data/spec/unit/provider/script_spec.rb +2 -2
  226. data/spec/unit/provider/service/systemd_service_spec.rb +26 -2
  227. data/spec/unit/provider/subversion_spec.rb +3 -3
  228. data/spec/unit/provider/systemd_unit_spec.rb +53 -4
  229. data/spec/unit/provider/user/dscl_spec.rb +1 -1
  230. data/spec/unit/provider_resolver_spec.rb +41 -61
  231. data/spec/unit/resource/chef_sleep_spec.rb +30 -0
  232. data/spec/unit/resource/cookbook_file_spec.rb +3 -3
  233. data/spec/unit/resource/remote_file_spec.rb +3 -3
  234. data/spec/unit/resource/windows_firewall_rule_spec.rb +69 -12
  235. data/spec/unit/role_spec.rb +2 -2
  236. data/spec/unit/shell_spec.rb +1 -1
  237. data/spec/unit/util/selinux_spec.rb +2 -2
  238. data/spec/unit/win32/error_spec.rb +1 -1
  239. data/spec/unit/win32/link_spec.rb +1 -1
  240. data/spec/unit/win32/security_spec.rb +1 -1
  241. data/spec/unit/windows_service_spec.rb +1 -1
  242. data/tasks/docs.rb +10 -2
  243. data/tasks/rspec.rb +8 -6
  244. metadata +33 -9
  245. data/lib/chef/mixin/train_helpers.rb +0 -60
  246. data/spec/unit/mash_spec.rb +0 -51
@@ -4,7 +4,7 @@
4
4
  # Author:: AJ Christensen (<aj@chef.io>)
5
5
  # Author:: Mark Mzyk (<mmzyk@chef.io>)
6
6
  # Author:: Kyle Goodwin (<kgoodwin@primerevenue.com>)
7
- # Copyright:: Copyright 2008-2016, Chef Software Inc.
7
+ # Copyright:: Copyright 2008-2019, Chef Software Inc.
8
8
  # License:: Apache License, Version 2.0
9
9
  #
10
10
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -28,6 +28,7 @@ require "chef-config/logger"
28
28
  ChefConfig.logger = Chef::Log
29
29
 
30
30
  require "chef-config/config"
31
+ require "chef-utils" unless defined?(ChefUtils::CANARY)
31
32
  require_relative "platform/query_helpers"
32
33
 
33
34
  # Ohai::Config defines its own log_level and log_location. When loaded, it will
@@ -55,7 +56,7 @@ class Chef
55
56
 
56
57
  default :event_loggers do
57
58
  evt_loggers = []
58
- if ChefConfig.windows? && !Chef::Platform.windows_nano_server?
59
+ if ChefUtils.windows? && !Chef::Platform.windows_nano_server?
59
60
  evt_loggers << :win_evt
60
61
  end
61
62
  evt_loggers
@@ -24,11 +24,9 @@ class Chef
24
24
  attr_reader :ignores
25
25
 
26
26
  def initialize(ignore_file_or_repo)
27
- # Check the 'ignore_file_or_repo' path first and then look in the parent directory
27
+ # Check the 'ignore_file_or_repo' path first and then look in the parent directories till root
28
28
  # to handle both the chef repo cookbook layout and a standalone cookbook
29
29
  @ignore_file = find_ignore_file(ignore_file_or_repo)
30
- @ignore_file = find_ignore_file(File.dirname(ignore_file_or_repo)) unless readable_file_or_symlink?(@ignore_file)
31
-
32
30
  @ignores = parse_ignore_file
33
31
  end
34
32
 
@@ -50,27 +48,34 @@ class Chef
50
48
 
51
49
  def parse_ignore_file
52
50
  ignore_globs = []
53
- if readable_file_or_symlink?(@ignore_file)
51
+ if @ignore_file && readable_file_or_symlink?(@ignore_file)
54
52
  File.foreach(@ignore_file) do |line|
55
53
  ignore_globs << line.strip unless line =~ COMMENTS_AND_WHITESPACE
56
54
  end
57
55
  else
58
- Chef::Log.trace("No chefignore file found at #{@ignore_file} no files will be ignored")
56
+ Chef::Log.debug("No chefignore file found. No files will be ignored!")
59
57
  end
60
58
  ignore_globs
61
59
  end
62
60
 
61
+ # Lookup of chefignore file till the root dir of the provided path.
62
+ # If file refer then lookup the parent dir till the root.
63
+ # eg. path: /var/.chef/cookbook_name
64
+ # Lookup at '/var/.chef/cookbook_name/chefignore', '/var/.chef/chefignore' '/var/chefignore' and '/chefignore' until exist
63
65
  def find_ignore_file(path)
64
- if File.basename(path) =~ /chefignore/
65
- path
66
- else
67
- File.join(path, "chefignore")
66
+ Pathname.new(path).ascend do |dir|
67
+ next unless dir.directory?
68
+
69
+ file = dir.join("chefignore")
70
+ return file.expand_path.to_s if file.exist?
68
71
  end
72
+
73
+ nil
69
74
  end
70
75
 
71
76
  def readable_file_or_symlink?(path)
72
- File.exist?(@ignore_file) && File.readable?(@ignore_file) &&
73
- (File.file?(@ignore_file) || File.symlink?(@ignore_file))
77
+ File.exist?(path) && File.readable?(path) &&
78
+ (File.file?(path) || File.symlink?(path))
74
79
  end
75
80
  end
76
81
  end
@@ -189,7 +189,7 @@ class Chef
189
189
  end
190
190
 
191
191
  def chefignore
192
- @chefignore ||= Chefignore.new(File.basename(cookbook_path))
192
+ @chefignore ||= Chefignore.new(cookbook_path)
193
193
  end
194
194
 
195
195
  # Enumerate all the files in a cookbook and assign the resulting list to
@@ -84,11 +84,13 @@ class Chef
84
84
  # If no +cookbook_path+ is given, +Chef::Config.cookbook_path+ is used.
85
85
  def self.for_cookbook(cookbook_name, cookbook_path = nil)
86
86
  cookbook_path ||= Chef::Config.cookbook_path
87
- unless cookbook_path
88
- raise ArgumentError, "Cannot find cookbook #{cookbook_name} unless Chef::Config.cookbook_path is set or an explicit cookbook path is given"
87
+
88
+ Array(cookbook_path).each do |entry|
89
+ path = File.expand_path(File.join(entry, cookbook_name.to_s))
90
+ return new(path) if Dir.exist?(path)
89
91
  end
90
92
 
91
- new(File.join(cookbook_path, cookbook_name.to_s))
93
+ raise ArgumentError, "Cannot find cookbook #{cookbook_name} unless Chef::Config.cookbook_path is set or an explicit cookbook path is given"
92
94
  end
93
95
 
94
96
  # Create a new SyntaxCheck object
@@ -49,8 +49,8 @@ class Chef
49
49
 
50
50
  # @param repo_paths [Array<String>] the array of repo paths containing cookbook dirs
51
51
  def initialize(*repo_paths)
52
- @repo_paths = repo_paths.flatten.map { |p| File.expand_path(p) }
53
- raise ArgumentError, "You must specify at least one cookbook repo path" if repo_paths.empty?
52
+ @repo_paths = repo_paths.flatten.compact.map { |p| File.expand_path(p) }
53
+ raise ArgumentError, "You must specify at least one cookbook repo path" if @repo_paths.empty?
54
54
  end
55
55
 
56
56
  # The primary function of this class is to build this Mash mapping cookbook names as a string to
@@ -171,7 +171,7 @@ class Chef
171
171
  begin
172
172
  mash = Mash.new
173
173
  all_directories_in_repo_paths.each do |cookbook_path|
174
- loader = Cookbook::CookbookVersionLoader.new(cookbook_path, chefignore(File.dirname(cookbook_path)))
174
+ loader = Cookbook::CookbookVersionLoader.new(cookbook_path, chefignore(cookbook_path))
175
175
  cookbook_name = loader.cookbook_name
176
176
  if mash.key?(cookbook_name)
177
177
  raise Chef::Exceptions::CookbookMergingError, "Cookbook merging is no longer supported, the cookbook named #{cookbook_name} can only appear once in the cookbook_path"
@@ -139,7 +139,7 @@ class Chef
139
139
 
140
140
  def validate_cookbooks
141
141
  cookbooks.each do |cb|
142
- syntax_checker = Chef::Cookbook::SyntaxCheck.for_cookbook(cb.name)
142
+ syntax_checker = Chef::Cookbook::SyntaxCheck.new(cb.root_dir)
143
143
  Chef::Log.info("Validating ruby files")
144
144
  exit(1) unless syntax_checker.validate_ruby_files
145
145
  Chef::Log.info("Validating templates")
@@ -64,8 +64,8 @@ class Chef
64
64
  # @param events [Chef::EventDispatch::Dispatcher] the event dispatcher
65
65
  def initialize(events)
66
66
  @events = events
67
- @expanded_run_list = {}
68
- @deprecations = Set.new
67
+ @expanded_run_list = {}
68
+ @deprecations = Set.new
69
69
  end
70
70
 
71
71
  # Hook to grab the run_status. We also make the decision to run or not run here (our
@@ -57,6 +57,7 @@ class Chef
57
57
  "resources" => all_action_records(action_collection),
58
58
  "run_id" => run_status&.run_id,
59
59
  "run_list" => node&.run_list&.for_json || [],
60
+ "cookbooks" => ( node && node["cookbooks"] ) || {},
60
61
  "policy_name" => node&.policy_name,
61
62
  "policy_group" => node&.policy_group,
62
63
  "start_time" => run_status.start_time.utc.iso8601,
@@ -229,6 +229,10 @@ class Chef
229
229
  target 27
230
230
  end
231
231
 
232
+ class ChefSugar < Base
233
+ target 28
234
+ end
235
+
232
236
  class Generic < Base
233
237
  def url
234
238
  "https://docs.chef.io/chef_deprecations_client.html"
@@ -1,7 +1,7 @@
1
1
  #--
2
2
  # Author:: Adam Jacob (<adam@chef.io>)
3
3
  # Author:: Christopher Walters (<cw@chef.io>)
4
- # Copyright:: Copyright 2008-2016 Chef Software, Inc.
4
+ # Copyright:: Copyright 2008-2019, Chef Software Inc.
5
5
  # License:: Apache License, Version 2.0
6
6
  #
7
7
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Adam Jacob (<adam@chef.io>)
3
- # Copyright:: Copyright 2008-2018, Chef Software Inc.
3
+ # Copyright:: Copyright 2008-2019, 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");
@@ -16,13 +16,15 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
+ require "chef-utils" unless defined?(ChefUtils::CANARY)
20
+
19
21
  class Chef
20
22
  module DSL
21
-
22
23
  # == Chef::DSL::PlatformIntrospection
23
24
  # Provides the DSL for platform-dependent switch logic, such as
24
25
  # #value_for_platform.
25
26
  module PlatformIntrospection
27
+ include ChefUtils
26
28
 
27
29
  # Implementation class for determining platform dependent values
28
30
  class PlatformDependentValue
@@ -245,27 +247,16 @@ class Chef
245
247
  end
246
248
  end
247
249
 
248
- # Shamelessly stolen from https://github.com/sethvargo/chef-sugar/blob/master/lib/chef/sugar/docker.rb
249
- # Given a node object, returns whether the node is a docker container.
250
- #
251
- # === Parameters
252
- # node:: [Chef::Node] The node to check.
253
- #
254
- # === Returns
255
- # true:: if the current node is a docker container
256
- # false:: if the current node is not a docker container
257
- def docker?(node = run_context.nil? ? nil : run_context.node)
258
- # Using "File.exist?('/.dockerinit') || File.exist?('/.dockerenv')" makes Travis sad,
259
- # and that makes us sad too.
260
- !!(node && node[:virtualization] && node[:virtualization][:systems] &&
261
- node[:virtualization][:systems][:docker] && node[:virtualization][:systems][:docker] == "guest")
262
- end
263
-
264
250
  # a simple helper to determine if we're on a windows release pre-2012 / 8
265
251
  # @return [Boolean] Is the system older than Windows 8 / 2012
266
252
  def older_than_win_2012_or_8?(node = run_context.nil? ? nil : run_context.node)
267
253
  node["platform_version"].to_f < 6.2
268
254
  end
255
+
256
+ # ^^^^^^ NOTE: PLEASE DO NOT CONTINUE TO ADD THESE KINDS OF PLATFORM_VERSION APIS WITHOUT ^^^^^^^
257
+ # ^^^^^^ GOING THROUGH THE DESIGN REVIEW PROCESS AND ADDRESS THE EXISTING CHEF-SUGAR ONES ^^^^^^^
258
+ # ^^^^^^ DO "THE HARD RIGHT THING" AND ADDRESS THE BROADER PROBLEM AND FIX IT ALL. ^^^^^^^
259
+
269
260
  end
270
261
  end
271
262
  end
@@ -39,7 +39,7 @@ class Chef
39
39
  SOURCE = "#{Chef::Dist::PRODUCT}".freeze
40
40
 
41
41
  def self.available?
42
- Chef::Platform.windows?
42
+ ChefUtils.windows?
43
43
  end
44
44
 
45
45
  def initialize
@@ -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-2019, 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");
@@ -18,7 +18,7 @@
18
18
 
19
19
  require_relative "deploy/cp"
20
20
  require_relative "deploy/mv_unix"
21
- if Chef::Platform.windows?
21
+ if ChefUtils.windows?
22
22
  require_relative "deploy/mv_windows"
23
23
  end
24
24
 
@@ -27,7 +27,7 @@ class Chef
27
27
  class Deploy
28
28
  def self.strategy(atomic_update)
29
29
  if atomic_update
30
- Chef::Platform.windows? ? MvWindows.new : MvUnix.new
30
+ ChefUtils.windows? ? MvWindows.new : MvUnix.new
31
31
  else
32
32
  Cp.new
33
33
  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-2019, 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");
@@ -22,7 +22,7 @@
22
22
  #
23
23
 
24
24
  require_relative "../../platform/query_helpers"
25
- if Chef::Platform.windows?
25
+ if ChefUtils.windows?
26
26
  require_relative "../../win32/security"
27
27
  end
28
28
 
@@ -67,7 +67,7 @@ class Chef
67
67
  basename = ::File.basename(@new_resource.path, tempfile_extension)
68
68
  # the leading "[.]chef-" here should be considered a public API and should not be changed
69
69
  basename.insert 0, "chef-"
70
- basename.insert 0, "." unless Chef::Platform.windows? # dotfile if we're not on windows
70
+ basename.insert 0, "." unless ChefUtils.windows? # dotfile if we're not on windows
71
71
  basename.scrub
72
72
  end
73
73
 
@@ -1,7 +1,7 @@
1
1
  #--
2
2
  # Author:: Daniel DeLeo (<dan@chef.io>)
3
3
  # Author:: Tyler Cloke (<tyler@chef.io>)
4
- # Copyright:: Copyright 2012-2016, Chef Software Inc.
4
+ # Copyright:: Copyright 2012-2019, Chef Software Inc.
5
5
  # License:: Apache License, Version 2.0
6
6
  #
7
7
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -52,7 +52,7 @@ class Chef
52
52
  error_description.section("Template Context:", "#{exception.source_location}\n#{exception.source_listing}")
53
53
  end
54
54
 
55
- if Chef::Platform.windows?
55
+ if ChefUtils.windows?
56
56
  require_relative "../../win32/security"
57
57
 
58
58
  unless Chef::ReservedNames::Win32::Security.has_admin_privileges?
@@ -519,7 +519,7 @@ class Chef
519
519
  content_length = response["Content-Length"]
520
520
  if tf.nil?
521
521
  tf = Tempfile.open("chef-rest")
522
- if Chef::Platform.windows?
522
+ if ChefUtils.windows?
523
523
  tf.binmode # required for binary files on Windows platforms
524
524
  end
525
525
  end
@@ -44,7 +44,7 @@
44
44
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
45
45
 
46
46
  require "chef_zero/server"
47
- require "chef/dist"
47
+ require_relative "../dist"
48
48
 
49
49
  class Chef
50
50
  class HTTP
@@ -1,7 +1,7 @@
1
1
  #
2
2
  # Author:: Adam Jacob (<adam@chef.io>)
3
3
  # Author:: Christopher Brown (<cb@chef.io>)
4
- # Copyright:: Copyright 2009-2018, Chef Software Inc.
4
+ # Copyright:: Copyright 2009-2019, Chef Software Inc.
5
5
  # License:: Apache License, Version 2.0
6
6
  #
7
7
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -20,6 +20,7 @@
20
20
  require "forwardable" unless defined?(Forwardable)
21
21
  require_relative "version"
22
22
  require "mixlib/cli" unless defined?(Mixlib::CLI)
23
+ require "chef-utils/dsl/path_sanity" unless defined?(ChefUtils::DSL::PathSanity)
23
24
  require_relative "workstation_config_loader"
24
25
  require_relative "mixin/convert_to_class_name"
25
26
  require_relative "mixin/path_sanity"
@@ -39,7 +40,7 @@ class Chef
39
40
  Chef::HTTP::HTTPRequest.user_agent = "#{Chef::Dist::PRODUCT} Knife#{Chef::HTTP::HTTPRequest::UA_COMMON}"
40
41
 
41
42
  include Mixlib::CLI
42
- include Chef::Mixin::PathSanity
43
+ include ChefUtils::DSL::PathSanity
43
44
  extend Chef::Mixin::ConvertToClassName
44
45
  extend Forwardable
45
46
 
@@ -479,7 +480,7 @@ class Chef
479
480
  unless respond_to?(:run)
480
481
  ui.error "You need to add a #run method to your knife command before you can use it"
481
482
  end
482
- enforce_path_sanity
483
+ ENV["PATH"] = sanitized_path if Chef::Config[:enforce_path_sanity]
483
484
  maybe_setup_fips
484
485
  Chef::LocalMode.with_server_connectivity do
485
486
  run
@@ -47,9 +47,10 @@ class Chef
47
47
  if wcl.config_location
48
48
  loading_from("configuration", wcl.config_location)
49
49
  end
50
+
50
51
  if Chef::Config[:config_d_dir]
51
52
  wcl.find_dot_d(Chef::Config[:config_d_dir]).each do |path|
52
- loading_from(".d/ configuration", wcl.config_location)
53
+ loading_from(".d/ configuration", path)
53
54
  end
54
55
  end
55
56
  end
@@ -120,7 +120,7 @@ class Chef
120
120
  @admin_client_key = config[:admin_client_key] || ask_question("Please enter the location of the existing admin's private key: ", default: "#{Chef::Dist::SERVER_CONF_DIR}/admin.pem")
121
121
  @admin_client_key = File.expand_path(@admin_client_key)
122
122
  else
123
- @new_client_name = config[:node_name] || ask_question("Please enter an existing username or clientname for the API: ", default: Etc.getlogin)
123
+ @new_client_name = config[:node_name] || ask_question("Please enter an existing username or clientname for the API: ", default: Etc.getlogin)
124
124
  end
125
125
 
126
126
  @new_client_key = config[:client_key] || File.join(chef_config_path, "#{@new_client_name}.pem")
@@ -31,6 +31,12 @@ class Chef
31
31
  banner "knife cookbook metadata from file FILE (options)"
32
32
 
33
33
  def run
34
+ if @name_args.length < 1
35
+ show_usage
36
+ ui.fatal("You must specify the FILE.")
37
+ exit(1)
38
+ end
39
+
34
40
  file = @name_args[0]
35
41
  cookbook = File.basename(File.dirname(file))
36
42
 
@@ -191,7 +191,7 @@ class Chef
191
191
  data =
192
192
  if data.is_a?(Array)
193
193
  data[attr.to_i]
194
- elsif data.respond_to?(:[], false) && data.key?(attr)
194
+ elsif data.respond_to?(:[], false) && data.respond_to?(:key?) && data.key?(attr)
195
195
  data[attr]
196
196
  elsif data.respond_to?(attr.to_sym, false)
197
197
  # handles -a chef_environment and other things that hang of the node and aren't really attributes
@@ -112,7 +112,7 @@ class Chef
112
112
 
113
113
  if node["ohai_time"]
114
114
  hours, minutes, seconds = time_difference_in_hms(node["ohai_time"])
115
- hours_text = "#{hours} hour#{hours == 1 ? " " : "s"}"
115
+ hours_text = "#{hours} hour#{hours == 1 ? " " : "s"}"
116
116
  minutes_text = "#{minutes} minute#{minutes == 1 ? " " : "s"}"
117
117
  seconds_text = "#{seconds} second#{seconds == 1 ? " " : "s"}"
118
118
  if hours > 24
@@ -593,6 +593,12 @@ class Chef
593
593
  def run
594
594
  @longest = 0
595
595
 
596
+ if @name_args.length < 1
597
+ show_usage
598
+ ui.fatal("You must specify the SEARCH QUERY.")
599
+ exit(1)
600
+ end
601
+
596
602
  configure_user
597
603
  configure_password
598
604
  @password = config[:ssh_password] if config[:ssh_password]
@@ -16,7 +16,7 @@
16
16
  # limitations under the License.
17
17
 
18
18
  require_relative "config"
19
- require_relative "monkey_patches/webrick-utils" if Chef::Platform.windows?
19
+ require_relative "monkey_patches/webrick-utils" if ChefUtils.windows?
20
20
  require_relative "dist"
21
21
 
22
22
  class Chef