chef 16.3.45 → 16.4.35

Sign up to get free protection for your applications and to get access to all the features.
Files changed (201) hide show
  1. checksums.yaml +4 -4
  2. data/chef-universal-mingw32.gemspec +0 -1
  3. data/lib/chef/action_collection.rb +4 -0
  4. data/lib/chef/api_client/registration.rb +8 -8
  5. data/lib/chef/application.rb +6 -1
  6. data/lib/chef/application/apply.rb +5 -5
  7. data/lib/chef/application/base.rb +2 -0
  8. data/lib/chef/application/client.rb +3 -0
  9. data/lib/chef/application/windows_service.rb +27 -27
  10. data/lib/chef/chef_class.rb +0 -1
  11. data/lib/chef/chef_fs/chef_fs_data_store.rb +54 -54
  12. data/lib/chef/chef_fs/file_system/chef_server/acl_entry.rb +10 -10
  13. data/lib/chef/chef_fs/file_system/chef_server/organization_invites_entry.rb +8 -8
  14. data/lib/chef/chef_fs/file_system/chef_server/organization_members_entry.rb +8 -8
  15. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb +2 -2
  16. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb +1 -1
  17. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb +18 -18
  18. data/lib/chef/chef_fs/file_system/repository/directory.rb +1 -1
  19. data/lib/chef/chef_fs/file_system/repository/file_system_entry.rb +1 -1
  20. data/lib/chef/client.rb +11 -11
  21. data/lib/chef/data_collector/run_end_message.rb +11 -1
  22. data/lib/chef/dsl/platform_introspection.rb +8 -8
  23. data/lib/chef/encrypted_data_bag_item/decryptor.rb +1 -1
  24. data/lib/chef/environment.rb +2 -2
  25. data/lib/chef/exceptions.rb +1 -1
  26. data/lib/chef/file_content_management/tempfile.rb +9 -9
  27. data/lib/chef/http.rb +2 -1
  28. data/lib/chef/json_compat.rb +1 -1
  29. data/lib/chef/knife/bootstrap.rb +2 -2
  30. data/lib/chef/knife/cookbook_download.rb +1 -1
  31. data/lib/chef/knife/cookbook_metadata.rb +1 -1
  32. data/lib/chef/knife/cookbook_upload.rb +23 -23
  33. data/lib/chef/knife/core/generic_presenter.rb +1 -1
  34. data/lib/chef/knife/core/hashed_command_loader.rb +2 -2
  35. data/lib/chef/knife/core/windows_bootstrap_context.rb +32 -24
  36. data/lib/chef/knife/delete.rb +15 -15
  37. data/lib/chef/knife/exec.rb +2 -2
  38. data/lib/chef/knife/ssh.rb +6 -6
  39. data/lib/chef/knife/xargs.rb +19 -19
  40. data/lib/chef/knife/yaml_convert.rb +1 -1
  41. data/lib/chef/mixin/checksum.rb +0 -1
  42. data/lib/chef/mixin/deep_merge.rb +35 -6
  43. data/lib/chef/mixin/openssl_helper.rb +3 -1
  44. data/lib/chef/mixin/shell_out.rb +1 -1
  45. data/lib/chef/mixin/which.rb +1 -1
  46. data/lib/chef/monkey_patches/webrick-utils.rb +10 -10
  47. data/lib/chef/node/attribute.rb +2 -4
  48. data/lib/chef/platform/service_helpers.rb +1 -1
  49. data/lib/chef/property.rb +1 -1
  50. data/lib/chef/provider/cron/unix.rb +0 -2
  51. data/lib/chef/provider/git.rb +5 -5
  52. data/lib/chef/provider/group.rb +0 -2
  53. data/lib/chef/provider/group/suse.rb +5 -5
  54. data/lib/chef/provider/ifconfig.rb +1 -4
  55. data/lib/chef/provider/mount.rb +0 -2
  56. data/lib/chef/provider/package.rb +0 -2
  57. data/lib/chef/provider/package/rubygems.rb +1 -1
  58. data/lib/chef/provider/package/snap.rb +1 -1
  59. data/lib/chef/provider/package/windows/registry_uninstall_entry.rb +9 -9
  60. data/lib/chef/provider/powershell_script.rb +21 -5
  61. data/lib/chef/provider/route.rb +1 -1
  62. data/lib/chef/provider/service/arch.rb +1 -1
  63. data/lib/chef/provider/service/debian.rb +1 -1
  64. data/lib/chef/provider/service/gentoo.rb +2 -2
  65. data/lib/chef/provider/service/macosx.rb +2 -2
  66. data/lib/chef/provider/service/openbsd.rb +1 -4
  67. data/lib/chef/provider/service/redhat.rb +2 -2
  68. data/lib/chef/provider/service/upstart.rb +1 -1
  69. data/lib/chef/provider/service/windows.rb +10 -10
  70. data/lib/chef/provider/systemd_unit.rb +0 -2
  71. data/lib/chef/provider/template/content.rb +1 -0
  72. data/lib/chef/provider/user/dscl.rb +2 -2
  73. data/lib/chef/provider/user/mac.rb +9 -9
  74. data/lib/chef/provider/windows_task.rb +0 -3
  75. data/lib/chef/provider/zypper_repository.rb +0 -1
  76. data/lib/chef/providers.rb +0 -1
  77. data/lib/chef/recipe.rb +1 -1
  78. data/lib/chef/resource.rb +6 -10
  79. data/lib/chef/resource/apt_repository.rb +1 -10
  80. data/lib/chef/resource/chef_client_systemd_timer.rb +2 -2
  81. data/lib/chef/resource/chef_vault_secret.rb +13 -13
  82. data/lib/chef/resource/execute.rb +2 -3
  83. data/lib/chef/resource/homebrew_update.rb +2 -2
  84. data/lib/chef/resource/openssl_dhparam.rb +2 -0
  85. data/lib/chef/resource/openssl_ec_private_key.rb +2 -0
  86. data/lib/chef/resource/openssl_ec_public_key.rb +2 -0
  87. data/lib/chef/resource/openssl_rsa_private_key.rb +2 -0
  88. data/lib/chef/resource/openssl_rsa_public_key.rb +2 -0
  89. data/lib/chef/resource/openssl_x509_certificate.rb +24 -21
  90. data/lib/chef/resource/openssl_x509_crl.rb +2 -0
  91. data/lib/chef/resource/openssl_x509_request.rb +23 -20
  92. data/lib/chef/resource/osx_profile.rb +227 -5
  93. data/lib/chef/resource/powershell_package_source.rb +1 -1
  94. data/lib/chef/resource/powershell_script.rb +24 -30
  95. data/lib/chef/resource/sudo.rb +1 -1
  96. data/lib/chef/resource/sysctl.rb +5 -5
  97. data/lib/chef/resource/windows_ad_join.rb +2 -0
  98. data/lib/chef/resource/windows_audit_policy.rb +3 -0
  99. data/lib/chef/resource/windows_auto_run.rb +2 -0
  100. data/lib/chef/resource/windows_certificate.rb +2 -0
  101. data/lib/chef/resource/windows_dfs_folder.rb +2 -0
  102. data/lib/chef/resource/windows_dfs_namespace.rb +2 -0
  103. data/lib/chef/resource/windows_dfs_server.rb +2 -0
  104. data/lib/chef/resource/windows_dns_record.rb +10 -7
  105. data/lib/chef/resource/windows_dns_zone.rb +12 -7
  106. data/lib/chef/resource/windows_feature.rb +2 -0
  107. data/lib/chef/resource/windows_feature_dism.rb +10 -0
  108. data/lib/chef/resource/windows_feature_powershell.rb +14 -2
  109. data/lib/chef/resource/windows_firewall_profile.rb +4 -2
  110. data/lib/chef/resource/windows_firewall_rule.rb +5 -3
  111. data/lib/chef/resource/windows_font.rb +3 -1
  112. data/lib/chef/resource/windows_pagefile.rb +4 -0
  113. data/lib/chef/resource/windows_printer.rb +17 -18
  114. data/lib/chef/resource/windows_printer_port.rb +14 -13
  115. data/lib/chef/resource/windows_security_policy.rb +2 -0
  116. data/lib/chef/resource/windows_share.rb +5 -3
  117. data/lib/chef/resource/windows_shortcut.rb +2 -0
  118. data/lib/chef/resource/windows_uac.rb +2 -0
  119. data/lib/chef/resource/windows_user_privilege.rb +2 -0
  120. data/lib/chef/resource/windows_workgroup.rb +2 -3
  121. data/lib/chef/resource_collection/stepable_iterator.rb +1 -2
  122. data/lib/chef/role.rb +2 -2
  123. data/lib/chef/run_context/cookbook_compiler.rb +20 -20
  124. data/lib/chef/run_status.rb +2 -6
  125. data/lib/chef/shell.rb +1 -1
  126. data/lib/chef/util/backup.rb +1 -1
  127. data/lib/chef/util/diff.rb +11 -11
  128. data/lib/chef/util/powershell/cmdlet.rb +1 -1
  129. data/lib/chef/version.rb +1 -1
  130. data/lib/chef/win32/file.rb +2 -2
  131. data/lib/chef/win32/file/version_info.rb +5 -5
  132. data/spec/data/ssl/chef-rspec.cert +15 -15
  133. data/spec/functional/resource/aixinit_service_spec.rb +7 -7
  134. data/spec/functional/resource/bff_spec.rb +2 -2
  135. data/spec/functional/resource/cookbook_file_spec.rb +1 -1
  136. data/spec/functional/resource/dsc_resource_spec.rb +1 -1
  137. data/spec/functional/resource/dsc_script_spec.rb +0 -1
  138. data/spec/functional/resource/group_spec.rb +6 -6
  139. data/spec/functional/resource/insserv_spec.rb +4 -4
  140. data/spec/functional/resource/link_spec.rb +20 -20
  141. data/spec/functional/resource/powershell_script_spec.rb +4 -4
  142. data/spec/functional/resource/rpm_spec.rb +2 -2
  143. data/spec/functional/resource/windows_certificate_spec.rb +3 -3
  144. data/spec/functional/resource/windows_font_spec.rb +49 -0
  145. data/spec/functional/resource/windows_security_policy_spec.rb +0 -3
  146. data/spec/functional/run_lock_spec.rb +24 -24
  147. data/spec/functional/win32/registry_spec.rb +8 -8
  148. data/spec/functional/win32/service_manager_spec.rb +1 -1
  149. data/spec/integration/knife/common_options_spec.rb +12 -12
  150. data/spec/integration/knife/config_get_profile_spec.rb +69 -68
  151. data/spec/integration/knife/config_get_spec.rb +126 -125
  152. data/spec/integration/knife/config_list_profiles_spec.rb +181 -180
  153. data/spec/integration/knife/config_use_profile_spec.rb +110 -109
  154. data/spec/integration/knife/diff_spec.rb +3 -1
  155. data/spec/integration/knife/download_spec.rb +3 -1
  156. data/spec/integration/knife/serve_spec.rb +5 -5
  157. data/spec/integration/knife/upload_spec.rb +3 -1
  158. data/spec/integration/recipes/lwrp_inline_resources_spec.rb +1 -1
  159. data/spec/spec_helper.rb +6 -6
  160. data/spec/support/platform_helpers.rb +9 -9
  161. data/spec/support/platforms/win32/spec_service.rb +1 -1
  162. data/spec/support/shared/functional/directory_resource.rb +1 -1
  163. data/spec/support/shared/functional/execute_resource.rb +1 -1
  164. data/spec/support/shared/functional/file_resource.rb +20 -20
  165. data/spec/support/shared/functional/win32_service.rb +1 -1
  166. data/spec/support/shared/functional/windows_script.rb +3 -3
  167. data/spec/support/shared/integration/integration_helper.rb +22 -52
  168. data/spec/support/shared/unit/script_resource.rb +6 -20
  169. data/spec/support/shared/unit/windows_script_resource.rb +15 -28
  170. data/spec/unit/data_collector_spec.rb +22 -0
  171. data/spec/unit/environment_spec.rb +7 -7
  172. data/spec/unit/knife/bootstrap_spec.rb +14 -14
  173. data/spec/unit/knife/cookbook_download_spec.rb +4 -4
  174. data/spec/unit/knife/cookbook_metadata_from_file_spec.rb +1 -1
  175. data/spec/unit/knife/core/hashed_command_loader_spec.rb +3 -3
  176. data/spec/unit/knife/core/windows_bootstrap_context_spec.rb +21 -12
  177. data/spec/unit/knife/supermarket_share_spec.rb +1 -1
  178. data/spec/unit/mixin/template_spec.rb +30 -30
  179. data/spec/unit/mixin/windows_architecture_helper_spec.rb +4 -4
  180. data/spec/unit/node/immutable_collections_spec.rb +6 -2
  181. data/spec/unit/node_spec.rb +5 -5
  182. data/spec/unit/provider/powershell_script_spec.rb +11 -4
  183. data/spec/unit/provider/remote_directory_spec.rb +9 -9
  184. data/spec/unit/provider/service/arch_service_spec.rb +3 -2
  185. data/spec/unit/provider/service/debian_service_spec.rb +1 -1
  186. data/spec/unit/provider/service/gentoo_service_spec.rb +7 -7
  187. data/spec/unit/provider/service/macosx_spec.rb +3 -3
  188. data/spec/unit/provider/service/redhat_spec.rb +2 -2
  189. data/spec/unit/provider/service/upstart_service_spec.rb +3 -3
  190. data/spec/unit/provider_resolver_spec.rb +6 -6
  191. data/spec/unit/resource/batch_spec.rb +6 -6
  192. data/spec/unit/resource/execute_spec.rb +113 -118
  193. data/spec/unit/resource/osx_profile_spec.rb +233 -0
  194. data/spec/unit/resource/powershell_script_spec.rb +11 -29
  195. data/spec/unit/resource/script_spec.rb +6 -1
  196. data/spec/unit/resource/windows_feature_powershell_spec.rb +30 -4
  197. data/spec/unit/role_spec.rb +11 -11
  198. data/tasks/rspec.rb +1 -1
  199. metadata +7 -8
  200. data/lib/chef/provider/osx_profile.rb +0 -255
  201. data/spec/unit/provider/osx_profile_spec.rb +0 -255
@@ -22,6 +22,8 @@ require_relative "../resource"
22
22
  class Chef
23
23
  class Resource
24
24
  class WindowsPrinterPort < Chef::Resource
25
+ unified_mode true
26
+
25
27
  require "resolv"
26
28
 
27
29
  provides(:windows_printer_port) { true }
@@ -82,30 +84,19 @@ class Chef
82
84
  validation_message: "port_protocol must be either 1 for RAW or 2 for LPR!",
83
85
  default: 1, equal_to: [1, 2]
84
86
 
85
- property :exists, [TrueClass, FalseClass],
86
- skip_docs: true
87
-
88
87
  PORTS_REG_KEY = 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports\\'.freeze unless defined?(PORTS_REG_KEY)
89
88
 
90
- def port_exists?(name)
91
- port_reg_key = PORTS_REG_KEY + name
92
-
93
- logger.trace "Checking to see if this reg key exists: '#{port_reg_key}'"
94
- registry_key_exists?(port_reg_key)
95
- end
96
-
97
89
  # @todo Set @current_resource port properties from registry
98
90
  load_current_value do |desired|
99
91
  name desired.name
100
92
  ipv4_address desired.ipv4_address
101
93
  port_name desired.port_name || "IP_#{desired.ipv4_address}"
102
- exists port_exists?(desired.port_name || "IP_#{desired.ipv4_address}")
103
94
  end
104
95
 
105
96
  action :create do
106
97
  description "Create the new printer port if it does not already exist."
107
98
 
108
- if current_resource.exists
99
+ if port_exists?
109
100
  Chef::Log.info "#{@new_resource} already exists - nothing to do."
110
101
  else
111
102
  converge_by("Create #{@new_resource}") do
@@ -117,7 +108,7 @@ class Chef
117
108
  action :delete do
118
109
  description "Delete an existing printer port."
119
110
 
120
- if current_resource.exists
111
+ if port_exists?
121
112
  converge_by("Delete #{@new_resource}") do
122
113
  delete_printer_port
123
114
  end
@@ -127,6 +118,16 @@ class Chef
127
118
  end
128
119
 
129
120
  action_class do
121
+ private
122
+
123
+ def port_exists?
124
+ name = new_resource.port_name || "IP_#{new_resource.ipv4_address}"
125
+ port_reg_key = PORTS_REG_KEY + name
126
+
127
+ logger.trace "Checking to see if this reg key exists: '#{port_reg_key}'"
128
+ registry_key_exists?(port_reg_key)
129
+ end
130
+
130
131
  def create_printer_port
131
132
  port_name = new_resource.port_name || "IP_#{new_resource.ipv4_address}"
132
133
 
@@ -21,6 +21,8 @@ require_relative "../resource"
21
21
  class Chef
22
22
  class Resource
23
23
  class WindowsSecurityPolicy < Chef::Resource
24
+ unified_mode true
25
+
24
26
  provides :windows_security_policy
25
27
 
26
28
  # The valid policy_names options found here
@@ -26,6 +26,8 @@ require_relative "../util/path_helper"
26
26
  class Chef
27
27
  class Resource
28
28
  class WindowsShare < Chef::Resource
29
+ unified_mode true
30
+
29
31
  provides :windows_share
30
32
 
31
33
  description "Use the **windows_share** resource to create, modify and remove Windows shares."
@@ -59,7 +61,7 @@ class Chef
59
61
  # Specifies the path of the location of the folder to share. The path must be fully qualified. Relative paths or paths that contain wildcard characters are not permitted.
60
62
  property :path, String,
61
63
  description: "The path of the folder to share. Required when creating. If the share already exists on a different path then it is deleted and re-created.",
62
- coerce: proc { |p| p.gsub(%r{/}, "\\") || p }
64
+ coerce: proc { |p| p.tr("/", "\\") || p }
63
65
 
64
66
  # Specifies an optional description of the SMB share. A description of the share is displayed by running the Get-SmbShare cmdlet. The description may not contain more than 256 characters.
65
67
  property :description, String,
@@ -117,8 +119,6 @@ class Chef
117
119
  # Specifies which files and folders in the SMB share are visible to users. AccessBased: SMB does not the display the files and folders for a share to a user unless that user has rights to access the files and folders. By default, access-based enumeration is disabled for new SMB shares. Unrestricted: SMB displays files and folders to a user even when the user does not have permission to access the items.
118
120
  # property :folder_enumeration_mode, String, equal_to: %(AccessBased Unrestricted)
119
121
 
120
- include Chef::Mixin::PowershellOut
121
-
122
122
  load_current_value do |desired|
123
123
  # this command selects individual objects because EncryptData & CachingMode have underlying
124
124
  # types that get converted to their Integer values by ConvertTo-Json & we need to make sure
@@ -233,6 +233,8 @@ class Chef
233
233
  end
234
234
 
235
235
  action_class do
236
+ private
237
+
236
238
  def different_path?
237
239
  return false if current_resource.nil? # going from nil to something isn't different for our concerns
238
240
  return false if current_resource.path == Chef::Util::PathHelper.cleanpath(new_resource.path)
@@ -21,6 +21,8 @@ require_relative "../resource"
21
21
  class Chef
22
22
  class Resource
23
23
  class WindowsShortcut < Chef::Resource
24
+ unified_mode true
25
+
24
26
  provides(:windows_shortcut) { true }
25
27
 
26
28
  description "Use the **windows_shortcut** resource to create shortcut files on Windows."
@@ -20,6 +20,8 @@ require_relative "../resource"
20
20
  class Chef
21
21
  class Resource
22
22
  class WindowsUac < Chef::Resource
23
+ unified_mode true
24
+
23
25
  provides :windows_uac
24
26
 
25
27
  description 'The *windows_uac* resource configures UAC on Windows hosts by setting registry keys at `HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System`'
@@ -21,6 +21,8 @@ require_relative "../resource"
21
21
  class Chef
22
22
  class Resource
23
23
  class WindowsUserPrivilege < Chef::Resource
24
+ unified_mode true
25
+
24
26
  privilege_opts = %w{SeTrustedCredManAccessPrivilege
25
27
  SeNetworkLogonRight
26
28
  SeTcbPrivilege
@@ -16,7 +16,6 @@
16
16
  #
17
17
 
18
18
  require_relative "../resource"
19
- require_relative "../mixin/powershell_out"
20
19
  require_relative "../dist"
21
20
 
22
21
  class Chef
@@ -24,8 +23,6 @@ class Chef
24
23
  class WindowsWorkgroup < Chef::Resource
25
24
  provides :windows_workgroup
26
25
 
27
- include Chef::Mixin::PowershellOut
28
-
29
26
  description "Use the **windows_workgroup** resource to join or change the workgroup of a Windows host."
30
27
  introduced "14.5"
31
28
  examples <<~DOC
@@ -57,6 +54,7 @@ class Chef
57
54
 
58
55
  property :password, String,
59
56
  description: "The password for the local administrator user. Required if using the `user` property.",
57
+ sensitive: true,
60
58
  desired_state: false
61
59
 
62
60
  property :reboot, Symbol,
@@ -83,6 +81,7 @@ class Chef
83
81
  end
84
82
 
85
83
  # define this again so we can default it to true. Otherwise failures print the password
84
+ # FIXME: this should now be unnecessary with the password property itself marked sensitive?
86
85
  property :sensitive, [TrueClass, FalseClass],
87
86
  default: true, desired_state: false
88
87
 
@@ -20,8 +20,7 @@ class Chef
20
20
  class StepableIterator
21
21
 
22
22
  def self.for_collection(new_collection)
23
- instance = new(new_collection)
24
- instance
23
+ new(new_collection)
25
24
  end
26
25
 
27
26
  attr_accessor :collection
@@ -256,11 +256,11 @@ class Chef
256
256
 
257
257
  js_path, rb_path = js_files.first, rb_files.first
258
258
 
259
- if js_path && File.exists?(js_path)
259
+ if js_path && File.exist?(js_path)
260
260
  # from_json returns object.class => json_class in the JSON.
261
261
  hsh = Chef::JSONCompat.parse(IO.read(js_path))
262
262
  return from_hash(hsh)
263
- elsif rb_path && File.exists?(rb_path)
263
+ elsif rb_path && File.exist?(rb_path)
264
264
  role = Chef::Role.new
265
265
  role.name(name)
266
266
  role.from_file(rb_path)
@@ -169,17 +169,17 @@ class Chef
169
169
  def compile_recipes
170
170
  @events.recipe_load_start(run_list_expansion.recipes.size)
171
171
  run_list_expansion.recipes.each do |recipe|
172
- begin
173
- path = resolve_recipe(recipe)
174
- @run_context.load_recipe(recipe)
175
- @events.recipe_file_loaded(path, recipe)
176
- rescue Chef::Exceptions::RecipeNotFound => e
177
- @events.recipe_not_found(e)
178
- raise
179
- rescue Exception => e
180
- @events.recipe_file_load_failed(path, e, recipe)
181
- raise
182
- end
172
+
173
+ path = resolve_recipe(recipe)
174
+ @run_context.load_recipe(recipe)
175
+ @events.recipe_file_loaded(path, recipe)
176
+ rescue Chef::Exceptions::RecipeNotFound => e
177
+ @events.recipe_not_found(e)
178
+ raise
179
+ rescue Exception => e
180
+ @events.recipe_file_load_failed(path, e, recipe)
181
+ raise
182
+
183
183
  end
184
184
  @events.recipe_load_complete
185
185
  end
@@ -231,14 +231,14 @@ class Chef
231
231
 
232
232
  def load_libraries_from_cookbook(cookbook_name, globs = "**/*.rb")
233
233
  each_file_in_cookbook_by_segment(cookbook_name, :libraries, globs) do |filename|
234
- begin
235
- logger.trace("Loading cookbook #{cookbook_name}'s library file: #{filename}")
236
- Kernel.require(filename)
237
- @events.library_file_loaded(filename)
238
- rescue Exception => e
239
- @events.library_file_load_failed(filename, e)
240
- raise
241
- end
234
+
235
+ logger.trace("Loading cookbook #{cookbook_name}'s library file: #{filename}")
236
+ Kernel.require(filename)
237
+ @events.library_file_loaded(filename)
238
+ rescue Exception => e
239
+ @events.library_file_load_failed(filename, e)
240
+ raise
241
+
242
242
  end
243
243
  end
244
244
 
@@ -325,7 +325,7 @@ class Chef
325
325
 
326
326
  def count_files_by_segment(segment, root_alias = nil)
327
327
  cookbook_collection.inject(0) do |count, cookbook_by_name|
328
- count + cookbook_by_name[1].segment_filenames(segment).size + (root_alias ? cookbook_by_name[1].files_for(:root_files).select { |record| record[:name] == root_alias }.size : 0)
328
+ count + cookbook_by_name[1].segment_filenames(segment).size + (root_alias ? cookbook_by_name[1].files_for(:root_files).count { |record| record[:name] == root_alias } : 0)
329
329
  end
330
330
  end
331
331
 
@@ -25,17 +25,13 @@ class Chef::RunStatus
25
25
 
26
26
  attr_reader :events
27
27
 
28
- attr_reader :run_context
29
-
30
- attr_writer :run_context
28
+ attr_accessor :run_context
31
29
 
32
30
  attr_reader :start_time
33
31
 
34
32
  attr_reader :end_time
35
33
 
36
- attr_reader :exception
37
-
38
- attr_writer :exception
34
+ attr_accessor :exception
39
35
 
40
36
  attr_accessor :run_id
41
37
 
@@ -339,7 +339,7 @@ module Shell
339
339
  config[:config_file] = config_file_for_shell_mode(environment)
340
340
  config_msg = config[:config_file] || "none (standalone session)"
341
341
  puts "loading configuration: #{config_msg}"
342
- Chef::Config.from_file(config[:config_file]) if !config[:config_file].nil? && File.exists?(config[:config_file]) && File.readable?(config[:config_file])
342
+ Chef::Config.from_file(config[:config_file]) if !config[:config_file].nil? && File.exist?(config[:config_file]) && File.readable?(config[:config_file])
343
343
  Chef::Config.merge!(config)
344
344
  end
345
345
 
@@ -87,7 +87,7 @@ class Chef
87
87
  end
88
88
 
89
89
  def sorted_backup_files
90
- unsorted_backup_files.sort { |a, b| b <=> a }
90
+ unsorted_backup_files.sort.reverse # faster than sort { |a, b| b <=> a }
91
91
  end
92
92
  end
93
93
  end
@@ -63,7 +63,7 @@ class Chef
63
63
 
64
64
  def use_tempfile_if_missing(file)
65
65
  tempfile = nil
66
- unless File.exists?(file)
66
+ unless File.exist?(file)
67
67
  Chef::Log.trace("File #{file} does not exist to diff against, using empty tempfile")
68
68
  tempfile = Tempfile.new("chef-diff")
69
69
  file = tempfile.path
@@ -106,16 +106,16 @@ class Chef
106
106
  # join them. otherwise, print out the old one.
107
107
  old_hunk = hunk = nil
108
108
  diff_data.each do |piece|
109
- begin
110
- hunk = ::Diff::LCS::Hunk.new(old_data, new_data, piece, 3, file_length_difference)
111
- file_length_difference = hunk.file_length_difference
112
- next unless old_hunk
113
- next if hunk.merge(old_hunk)
114
-
115
- diff_str << old_hunk.diff(:unified) << "\n"
116
- ensure
117
- old_hunk = hunk
118
- end
109
+
110
+ hunk = ::Diff::LCS::Hunk.new(old_data, new_data, piece, 3, file_length_difference)
111
+ file_length_difference = hunk.file_length_difference
112
+ next unless old_hunk
113
+ next if hunk.merge(old_hunk)
114
+
115
+ diff_str << old_hunk.diff(:unified) << "\n"
116
+ ensure
117
+ old_hunk = hunk
118
+
119
119
  end
120
120
  diff_str << old_hunk.diff(:unified) << "\n"
121
121
  diff_str
@@ -164,7 +164,7 @@ class Chef
164
164
  end
165
165
 
166
166
  def self.destroy(name)
167
- proc { File.delete(name) if File.exists? name }
167
+ proc { File.delete(name) if File.exist? name }
168
168
  end
169
169
  end
170
170
  end
@@ -23,7 +23,7 @@ require_relative "version_string"
23
23
 
24
24
  class Chef
25
25
  CHEF_ROOT = File.expand_path("..", __dir__)
26
- VERSION = Chef::VersionString.new("16.3.45")
26
+ VERSION = Chef::VersionString.new("16.4.35")
27
27
  end
28
28
 
29
29
  #
@@ -78,7 +78,7 @@ class Chef
78
78
  def self.symlink?(file_name)
79
79
  is_symlink = false
80
80
  path = encode_path(file_name)
81
- if ::File.exists?(file_name) || ::File.symlink?(file_name)
81
+ if ::File.exist?(file_name) || ::File.symlink?(file_name)
82
82
  if (GetFileAttributesW(path) & FILE_ATTRIBUTE_REPARSE_POINT) > 0
83
83
  file_search_handle(file_name) do |handle, find_data|
84
84
  if find_data[:dw_reserved_0] == IO_REPARSE_TAG_SYMLINK
@@ -104,7 +104,7 @@ class Chef
104
104
  # will raise a NotImplementedError, as per MRI.
105
105
  #
106
106
  def self.readlink(link_name)
107
- raise Errno::ENOENT, link_name unless ::File.exists?(link_name) || ::File.symlink?(link_name)
107
+ raise Errno::ENOENT, link_name unless ::File.exist?(link_name) || ::File.symlink?(link_name)
108
108
 
109
109
  symlink_file_handle(link_name) do |handle|
110
110
  # Go to DeviceIoControl to get the symlink information
@@ -49,11 +49,11 @@ class Chef
49
49
  SpecialBuild
50
50
  }.each do |method|
51
51
  define_method method do
52
- begin
53
- get_version_info_string(method.to_s)
54
- rescue Chef::Exceptions::Win32APIError
55
- return nil
56
- end
52
+
53
+ get_version_info_string(method.to_s)
54
+ rescue Chef::Exceptions::Win32APIError
55
+ return nil
56
+
57
57
  end
58
58
  end
59
59
 
@@ -1,9 +1,9 @@
1
1
  -----BEGIN CERTIFICATE-----
2
- MIIEkjCCA3qgAwIBAgIJAKBJr4wSRUVvMA0GCSqGSIb3DQEBBQUAMIGMMQswCQYD
2
+ MIIEkjCCA3qgAwIBAgIJAOEDC5RFoEUZMA0GCSqGSIb3DQEBCwUAMIGMMQswCQYD
3
3
  VQQGEwJVUzETMBEGA1UECBMKV2FzaGluZ3RvbjEQMA4GA1UEBxMHU2VhdHRsZTEN
4
4
  MAsGA1UEChMEQ2hlZjETMBEGA1UECxMKZGV2ZWxvcGVyczESMBAGA1UEAxMJa2Fs
5
- bGlzdGVjMR4wHAYJKoZIhvcNAQkBFg9kYW5Ab3BzY29kZS5jb20wHhcNMTAwNDEw
6
- MTkxMTMxWhcNMjAwNDA3MTkxMTMxWjCBjDELMAkGA1UEBhMCVVMxEzARBgNVBAgT
5
+ bGlzdGVjMR4wHAYJKoZIhvcNAQkBFg9kYW5Ab3BzY29kZS5jb20wHhcNMjAwODEy
6
+ MTEyOTUxWhcNMzAwODEwMTEyOTUxWjCBjDELMAkGA1UEBhMCVVMxEzARBgNVBAgT
7
7
  Cldhc2hpbmd0b24xEDAOBgNVBAcTB1NlYXR0bGUxDTALBgNVBAoTBENoZWYxEzAR
8
8
  BgNVBAsTCmRldmVsb3BlcnMxEjAQBgNVBAMTCWthbGxpc3RlYzEeMBwGCSqGSIb3
9
9
  DQEJARYPZGFuQG9wc2NvZGUuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB
@@ -12,16 +12,16 @@ SxuFR7Fnp2OM8ed7iPIKSrcM0vQ+g7vYKCv5Z8UR3sbLY8UHm9AgZ/bLAHEHS2if
12
12
  1WHPD5DOe1B7HwW0IfEiW4/WakkVn4uoWw5rCZ87f4YCrETomXIo1n/rMFHf+yoY
13
13
  guuEfGQxRcQdlEZM9YMlMByQvXlVR5IVhpiMHBCyV6KzxjZVCgTlvS8nPMiiHpoO
14
14
  pgB6BGEQ/nn4Kapk40baPqpT4EP/DnBnbhhR3kBQ6MQRlh7bl5vjH5xFSFwGUUA9
15
- IcaDTwfliD27bo36aMvcBhrsmbSwqwIDAQABo4H0MIHxMB0GA1UdDgQWBBS88Zxt
16
- vG+FTu1U+VFA47ffzwStbjCBwQYDVR0jBIG5MIG2gBS88ZxtvG+FTu1U+VFA47ff
17
- zwStbqGBkqSBjzCBjDELMAkGA1UEBhMCVVMxEzARBgNVBAgTCldhc2hpbmd0b24x
18
- EDAOBgNVBAcTB1NlYXR0bGUxDTALBgNVBAoTBENoZWYxEzARBgNVBAsTCmRldmVs
19
- b3BlcnMxEjAQBgNVBAMTCWthbGxpc3RlYzEeMBwGCSqGSIb3DQEJARYPZGFuQG9w
20
- c2NvZGUuY29tggkAoEmvjBJFRW8wDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUF
21
- AAOCAQEAwwMrbuJAhP5uawJi5OYEaJKSbJGyahCcOAl4+ONgsdDoCy/9AZKzuFNc
22
- C8vM/Ee6jyugrKMdckvZ883kJ4770HU6nbomCUVKMHMzJBE1Guvsn8wZP3nKyeSZ
23
- eXXbH1b/NfstNyo6XLucaBRQvyvQYDUnk6osrBh+Gekvqsahr0wkVa8VUY2UySyY
24
- 60lYt4O92XJ1jWtYoFjRxeeUgo5E0TfIWj74kXhdMqwMf4Iv9VatfYR87ps5VMdf
25
- Hp+nrCRaquDAs87LdO9e7M8l+W1ryPfP2inuGjIozsN5lLmwBdT+O6NkpmuxGPEG
26
- ArIbYatR7+4MsDn+CjfkYblnmGLuug==
15
+ IcaDTwfliD27bo36aMvcBhrsmbSwqwIDAQABo4H0MIHxMAwGA1UdEwQFMAMBAf8w
16
+ HQYDVR0OBBYEFLzxnG28b4VO7VT5UUDjt9/PBK1uMIHBBgNVHSMEgbkwgbaAFLzx
17
+ nG28b4VO7VT5UUDjt9/PBK1uoYGSpIGPMIGMMQswCQYDVQQGEwJVUzETMBEGA1UE
18
+ CBMKV2FzaGluZ3RvbjEQMA4GA1UEBxMHU2VhdHRsZTENMAsGA1UEChMEQ2hlZjET
19
+ MBEGA1UECxMKZGV2ZWxvcGVyczESMBAGA1UEAxMJa2FsbGlzdGVjMR4wHAYJKoZI
20
+ hvcNAQkBFg9kYW5Ab3BzY29kZS5jb22CCQDhAwuURaBFGTANBgkqhkiG9w0BAQsF
21
+ AAOCAQEAoTCRzUbZOPrJdpd928fQPt/HsYODDmgWQJIPucdLKmlY5wb3zSc1B5H6
22
+ zBUmSFylnDLKhZlO+gojBuQDhr2h9bMXn8RvE0A/Dqq9XcNsblMn0HjoJmjv/x8Q
23
+ wFfrwIWj1wHoGHromkJaedWCRGlVW1oLZa99JmQCNee4bjcwkK2H0xRqX8STbqJV
24
+ z+uEBf5fDc4EioULwfxa6B15XDD09k14uHtlV6JwTmahDjpdKV/ICKBi/WN0aQg1
25
+ 9k7OAkW5cnzmS6uFFjrvWuNy4ey4j1c4U5GogxEgCsattshHNO+icWRCN2gPg2Nx
26
+ SKEXNcUA4jRWGF7PRgY/oyjULObFqw==
27
27
  -----END CERTIFICATE-----
@@ -27,11 +27,11 @@ describe Chef::Resource::Service, :requires_root, :aix_only do
27
27
  # Platform specific validation routines.
28
28
  def service_should_be_started(file_name)
29
29
  # The existence of this file indicates that the service was started.
30
- expect(File.exists?("#{Dir.tmpdir}/#{file_name}")).to be_truthy
30
+ expect(File.exist?("#{Dir.tmpdir}/#{file_name}")).to be_truthy
31
31
  end
32
32
 
33
33
  def service_should_be_stopped(file_name)
34
- expect(File.exists?("#{Dir.tmpdir}/#{file_name}")).to be_falsey
34
+ expect(File.exist?("#{Dir.tmpdir}/#{file_name}")).to be_falsey
35
35
  end
36
36
 
37
37
  def valide_symlinks(expected_output, run_level = nil, status = nil, priority = nil)
@@ -68,12 +68,12 @@ describe Chef::Resource::Service, :requires_root, :aix_only do
68
68
  end
69
69
 
70
70
  before(:all) do
71
- File.delete("/etc/rc.d/init.d/chefinittest") if File.exists?("/etc/rc.d/init.d/chefinittest")
71
+ File.delete("/etc/rc.d/init.d/chefinittest") if File.exist?("/etc/rc.d/init.d/chefinittest")
72
72
  FileUtils.cp((File.join(File.dirname(__FILE__), "/../assets/chefinittest")).to_s, "/etc/rc.d/init.d/chefinittest")
73
73
  end
74
74
 
75
75
  after(:all) do
76
- File.delete("/etc/rc.d/init.d/chefinittest") if File.exists?("/etc/rc.d/init.d/chefinittest")
76
+ File.delete("/etc/rc.d/init.d/chefinittest") if File.exist?("/etc/rc.d/init.d/chefinittest")
77
77
  end
78
78
 
79
79
  before(:each) do
@@ -165,7 +165,7 @@ describe Chef::Resource::Service, :requires_root, :aix_only do
165
165
  end
166
166
 
167
167
  after do
168
- File.delete("/etc/rc.d/rc2.d/Schefinittest") if File.exists?("/etc/rc.d/rc2.d/chefinittest")
168
+ File.delete("/etc/rc.d/rc2.d/Schefinittest") if File.exist?("/etc/rc.d/rc2.d/chefinittest")
169
169
  end
170
170
 
171
171
  it "creates symlink with status K" do
@@ -181,7 +181,7 @@ describe Chef::Resource::Service, :requires_root, :aix_only do
181
181
  end
182
182
 
183
183
  after do
184
- File.delete("/etc/rc.d/rc2.d/Schefinittest") if File.exists?("/etc/rc.d/rc2.d/chefinittest")
184
+ File.delete("/etc/rc.d/rc2.d/Schefinittest") if File.exist?("/etc/rc.d/rc2.d/chefinittest")
185
185
  end
186
186
 
187
187
  it "creates a symlink with status K and a priority" do
@@ -198,7 +198,7 @@ describe Chef::Resource::Service, :requires_root, :aix_only do
198
198
  end
199
199
 
200
200
  after do
201
- File.delete("/etc/rc.d/rc2.d/Schefinittest") if File.exists?("/etc/rc.d/rc2.d/chefinittest")
201
+ File.delete("/etc/rc.d/rc2.d/Schefinittest") if File.exist?("/etc/rc.d/rc2.d/chefinittest")
202
202
  end
203
203
 
204
204
  it "create symlink with status stop (K) and a priority " do