chef 16.6.14 → 16.7.61

Sign up to get free protection for your applications and to get access to all the features.
Files changed (205) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +4 -11
  3. data/Rakefile +21 -14
  4. data/chef-universal-mingw32.gemspec +1 -1
  5. data/lib/chef/application/knife.rb +1 -1
  6. data/lib/chef/chef_fs/data_handler/cookbook_data_handler.rb +1 -1
  7. data/lib/chef/chef_fs/file_pattern.rb +1 -1
  8. data/lib/chef/client.rb +1 -1
  9. data/lib/chef/cookbook_manifest.rb +1 -1
  10. data/lib/chef/cookbook_site_streaming_uploader.rb +1 -1
  11. data/lib/chef/cookbook_version.rb +2 -5
  12. data/lib/chef/environment.rb +1 -1
  13. data/lib/chef/exceptions.rb +1 -1
  14. data/lib/chef/file_access_control/windows.rb +1 -4
  15. data/lib/chef/formatters/error_inspectors/compile_error_inspector.rb +2 -2
  16. data/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb +4 -4
  17. data/lib/chef/guard_interpreter/resource_guard_interpreter.rb +28 -39
  18. data/lib/chef/http.rb +2 -12
  19. data/lib/chef/http/basic_client.rb +1 -1
  20. data/lib/chef/http/http_request.rb +1 -1
  21. data/lib/chef/http/socketless_chef_zero_client.rb +1 -1
  22. data/lib/chef/json_compat.rb +2 -7
  23. data/lib/chef/key.rb +1 -1
  24. data/lib/chef/knife/bootstrap.rb +2 -1
  25. data/lib/chef/knife/bootstrap/templates/windows-chef-client-msi.erb +2 -2
  26. data/lib/chef/knife/config_show.rb +1 -1
  27. data/lib/chef/knife/core/cookbook_scm_repo.rb +1 -1
  28. data/lib/chef/knife/core/gem_glob_loader.rb +1 -1
  29. data/lib/chef/knife/core/windows_bootstrap_context.rb +7 -4
  30. data/lib/chef/mixin/convert_to_class_name.rb +0 -56
  31. data/lib/chef/mixin/openssl_helper.rb +1 -1
  32. data/lib/chef/mixin/properties.rb +2 -0
  33. data/lib/chef/mixin/unformatter.rb +1 -1
  34. data/lib/chef/node/attribute_collections.rb +2 -6
  35. data/lib/chef/powershell.rb +5 -2
  36. data/lib/chef/property.rb +1 -1
  37. data/lib/chef/provider/cron.rb +2 -13
  38. data/lib/chef/provider/group.rb +14 -6
  39. data/lib/chef/provider/group/windows.rb +12 -1
  40. data/lib/chef/provider/ifconfig.rb +7 -7
  41. data/lib/chef/provider/ifconfig/debian.rb +5 -7
  42. data/lib/chef/provider/ifconfig/redhat.rb +3 -1
  43. data/lib/chef/provider/launchd.rb +1 -11
  44. data/lib/chef/provider/mount.rb +18 -1
  45. data/lib/chef/provider/mount/linux.rb +4 -0
  46. data/lib/chef/provider/mount/mount.rb +41 -43
  47. data/lib/chef/provider/package.rb +3 -0
  48. data/lib/chef/provider/package/apt.rb +1 -1
  49. data/lib/chef/provider/package/chocolatey.rb +6 -6
  50. data/lib/chef/provider/package/freebsd/base.rb +3 -2
  51. data/lib/chef/provider/package/freebsd/pkgng.rb +1 -1
  52. data/lib/chef/provider/package/ips.rb +1 -1
  53. data/lib/chef/provider/package/powershell.rb +2 -3
  54. data/lib/chef/provider/package/rubygems.rb +1 -1
  55. data/lib/chef/provider/package/snap.rb +1 -3
  56. data/lib/chef/provider/package/solaris.rb +0 -2
  57. data/lib/chef/provider/package/yum/rpm_utils.rb +1 -1
  58. data/lib/chef/provider/package/zypper.rb +98 -71
  59. data/lib/chef/provider/registry_key.rb +4 -3
  60. data/lib/chef/provider/route.rb +2 -2
  61. data/lib/chef/provider/service/debian.rb +2 -1
  62. data/lib/chef/provider/user.rb +17 -9
  63. data/lib/chef/provider/user/aix.rb +1 -1
  64. data/lib/chef/provider/user/mac.rb +12 -4
  65. data/lib/chef/provider/user/solaris.rb +1 -1
  66. data/lib/chef/provider/user/windows.rb +10 -3
  67. data/lib/chef/providers.rb +0 -3
  68. data/lib/chef/pwsh.rb +7 -0
  69. data/lib/chef/resource/bash.rb +119 -1
  70. data/lib/chef/resource/batch.rb +1 -1
  71. data/lib/chef/resource/breakpoint.rb +3 -1
  72. data/lib/chef/resource/build_essential.rb +5 -8
  73. data/lib/chef/resource/csh.rb +2 -2
  74. data/lib/chef/resource/execute.rb +6 -4
  75. data/lib/chef/resource/file.rb +1 -1
  76. data/lib/chef/resource/homebrew_update.rb +4 -1
  77. data/lib/chef/resource/hostname.rb +2 -2
  78. data/lib/chef/resource/ifconfig.rb +52 -5
  79. data/lib/chef/resource/ksh.rb +3 -3
  80. data/lib/chef/resource/lwrp_base.rb +3 -5
  81. data/lib/chef/resource/mount.rb +7 -1
  82. data/lib/chef/resource/perl.rb +2 -2
  83. data/lib/chef/resource/plist.rb +2 -6
  84. data/lib/chef/resource/powershell_package_source.rb +19 -18
  85. data/lib/chef/resource/powershell_script.rb +7 -10
  86. data/lib/chef/resource/python.rb +2 -2
  87. data/lib/chef/resource/registry_key.rb +93 -2
  88. data/lib/chef/resource/route.rb +1 -1
  89. data/lib/chef/resource/ruby.rb +2 -2
  90. data/lib/chef/resource/scm/_scm.rb +2 -1
  91. data/lib/chef/resource/scm/git.rb +82 -1
  92. data/lib/chef/resource/scm/subversion.rb +12 -0
  93. data/lib/chef/resource/script.rb +2 -2
  94. data/lib/chef/resource/solaris_package.rb +0 -2
  95. data/lib/chef/resource/sudo.rb +1 -1
  96. data/lib/chef/resource/support/client.erb +4 -5
  97. data/lib/chef/resource/systemd_unit.rb +42 -1
  98. data/lib/chef/resource/windows_ad_join.rb +9 -9
  99. data/lib/chef/resource/windows_certificate.rb +6 -6
  100. data/lib/chef/resource/windows_dfs_server.rb +7 -4
  101. data/lib/chef/resource/windows_env.rb +173 -0
  102. data/lib/chef/resource/windows_feature.rb +2 -0
  103. data/lib/chef/resource/windows_firewall_profile.rb +7 -12
  104. data/lib/chef/resource/windows_firewall_rule.rb +9 -11
  105. data/lib/chef/resource/windows_font.rb +1 -1
  106. data/lib/chef/resource/windows_package.rb +1 -0
  107. data/lib/chef/resource/windows_path.rb +38 -0
  108. data/lib/chef/resource/windows_security_policy.rb +5 -5
  109. data/lib/chef/resource/windows_service.rb +108 -0
  110. data/lib/chef/resource/windows_share.rb +18 -18
  111. data/lib/chef/resource/windows_task.rb +629 -28
  112. data/lib/chef/resource/windows_workgroup.rb +6 -4
  113. data/lib/chef/resource/yum_repository.rb +1 -1
  114. data/lib/chef/resource_collection/resource_set.rb +1 -5
  115. data/lib/chef/resource_inspector.rb +77 -75
  116. data/lib/chef/run_lock.rb +1 -1
  117. data/lib/chef/server_api.rb +0 -4
  118. data/lib/chef/shell/ext.rb +1 -1
  119. data/lib/chef/util/dsc/lcm_output_parser.rb +1 -3
  120. data/lib/chef/util/dsc/local_configuration_manager.rb +1 -1
  121. data/lib/chef/util/powershell/cmdlet.rb +3 -9
  122. data/lib/chef/version.rb +1 -1
  123. data/lib/chef/win32/security/sid.rb +1 -1
  124. data/spec/functional/mixin/powershell_out_spec.rb +4 -4
  125. data/spec/functional/resource/apt_package_spec.rb +4 -6
  126. data/spec/functional/resource/chocolatey_package_spec.rb +3 -3
  127. data/spec/functional/resource/cron_spec.rb +3 -3
  128. data/spec/functional/resource/dsc_script_spec.rb +3 -3
  129. data/spec/functional/resource/mount_spec.rb +10 -2
  130. data/spec/functional/resource/powershell_package_source_spec.rb +107 -0
  131. data/spec/functional/resource/windows_certificate_spec.rb +10 -6
  132. data/spec/functional/resource/windows_firewall_rule_spec.rb +93 -0
  133. data/spec/functional/resource/windows_package_spec.rb +36 -10
  134. data/spec/functional/resource/windows_share_spec.rb +103 -0
  135. data/spec/functional/resource/windows_task_spec.rb +2 -3
  136. data/spec/functional/resource/zypper_package_spec.rb +11 -0
  137. data/spec/integration/knife/client_key_create_spec.rb +1 -1
  138. data/spec/integration/knife/node_create_spec.rb +1 -1
  139. data/spec/integration/knife/node_environment_set_spec.rb +1 -1
  140. data/spec/integration/knife/node_run_list_add_spec.rb +4 -4
  141. data/spec/integration/knife/node_run_list_remove_spec.rb +1 -1
  142. data/spec/integration/knife/node_run_list_set_spec.rb +1 -1
  143. data/spec/integration/knife/node_show_spec.rb +1 -1
  144. data/spec/integration/recipes/notifies_spec.rb +1 -1
  145. data/spec/integration/recipes/provider_choice.rb +2 -2
  146. data/spec/support/lib/chef/resource/cat.rb +1 -1
  147. data/spec/support/lib/chef/resource/one_two_three_four.rb +1 -1
  148. data/spec/support/mock/platform.rb +24 -16
  149. data/spec/support/platform_helpers.rb +6 -4
  150. data/spec/support/shared/unit/knife_shared.rb +1 -1
  151. data/spec/support/shared/unit/script_resource.rb +4 -4
  152. data/spec/support/shared/unit/windows_script_resource.rb +1 -1
  153. data/spec/unit/client_spec.rb +16 -0
  154. data/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb +11 -11
  155. data/spec/unit/knife/client_create_spec.rb +2 -2
  156. data/spec/unit/knife/configure_client_spec.rb +5 -5
  157. data/spec/unit/knife/configure_spec.rb +3 -3
  158. data/spec/unit/knife/cookbook_delete_spec.rb +2 -2
  159. data/spec/unit/knife/cookbook_download_spec.rb +2 -2
  160. data/spec/unit/knife/cookbook_list_spec.rb +2 -2
  161. data/spec/unit/knife/cookbook_metadata_spec.rb +3 -3
  162. data/spec/unit/knife/environment_compare_spec.rb +3 -3
  163. data/spec/unit/knife/supermarket_download_spec.rb +8 -8
  164. data/spec/unit/knife/supermarket_list_spec.rb +3 -3
  165. data/spec/unit/knife/supermarket_search_spec.rb +1 -1
  166. data/spec/unit/knife/tag_create_spec.rb +1 -1
  167. data/spec/unit/knife/tag_delete_spec.rb +1 -1
  168. data/spec/unit/knife/user_create_spec.rb +1 -1
  169. data/spec/unit/mixin/which.rb +1 -1
  170. data/spec/unit/provider/group/windows_spec.rb +6 -0
  171. data/spec/unit/provider/group_spec.rb +1 -1
  172. data/spec/unit/provider/mount/linux_spec.rb +10 -0
  173. data/spec/unit/provider/mount/mount_spec.rb +21 -10
  174. data/spec/unit/provider/mount/solaris_spec.rb +1 -1
  175. data/spec/unit/provider/mount_spec.rb +31 -0
  176. data/spec/unit/provider/package/chocolatey_spec.rb +1 -2
  177. data/spec/unit/provider/package/powershell_spec.rb +87 -95
  178. data/spec/unit/provider/package/zypper_spec.rb +0 -25
  179. data/spec/unit/provider/package_spec.rb +2 -2
  180. data/spec/unit/provider/subversion_spec.rb +0 -3
  181. data/spec/unit/provider/user_spec.rb +7 -1
  182. data/spec/unit/provider/windows_env_spec.rb +18 -34
  183. data/spec/unit/provider/windows_path_spec.rb +6 -11
  184. data/spec/unit/provider/windows_task_spec.rb +7 -6
  185. data/spec/unit/resource/breakpoint_spec.rb +1 -1
  186. data/spec/unit/resource/build_essential_spec.rb +0 -12
  187. data/spec/unit/resource/ifconfig_spec.rb +2 -10
  188. data/spec/unit/resource/mount_spec.rb +18 -5
  189. data/spec/unit/resource/powershell_package_source_spec.rb +20 -20
  190. data/spec/unit/resource/powershell_script_spec.rb +4 -74
  191. data/spec/unit/resource/service_spec.rb +2 -2
  192. data/spec/unit/resource/solaris_package_spec.rb +8 -10
  193. data/spec/unit/resource_inspector_spec.rb +3 -3
  194. data/spec/unit/shell_spec.rb +2 -2
  195. data/tasks/rspec.rb +1 -1
  196. metadata +9 -15
  197. data/lib/chef/monkey_patches/net_http.rb +0 -22
  198. data/lib/chef/provider/windows_env.rb +0 -210
  199. data/lib/chef/provider/windows_path.rb +0 -61
  200. data/lib/chef/provider/windows_task.rb +0 -631
  201. data/spec/support/mock/constant.rb +0 -52
  202. data/spec/unit/monkey_patches/uri_spec.rb +0 -34
  203. data/spec/unit/provider_resolver_spec.rb +0 -885
  204. data/spec/unit/resource/data/InstallHistory_with_CLT.plist +0 -92
  205. data/spec/unit/resource/data/InstallHistory_without_CLT.plist +0 -38
@@ -21,6 +21,8 @@ require "chef-utils/dist" unless defined?(ChefUtils::Dist)
21
21
  class Chef
22
22
  class Resource
23
23
  class WindowsWorkgroup < Chef::Resource
24
+ unified_mode true
25
+
24
26
  provides :windows_workgroup
25
27
 
26
28
  description "Use the **windows_workgroup** resource to join or change the workgroup of a Windows host."
@@ -90,8 +92,8 @@ class Chef
90
92
 
91
93
  unless workgroup_member?
92
94
  converge_by("join workstation workgroup #{new_resource.workgroup_name}") do
93
- ps_run = powershell_out(join_command)
94
- raise "Failed to join the workgroup #{new_resource.workgroup_name}: #{ps_run.stderr}}" if ps_run.error?
95
+ ps_run = powershell_exec(join_command)
96
+ raise "Failed to join the workgroup #{new_resource.workgroup_name}: #{ps_run.errors}}" if ps_run.error?
95
97
 
96
98
  unless new_resource.reboot == :never
97
99
  reboot "Reboot to join workgroup #{new_resource.workgroup_name}" do
@@ -117,10 +119,10 @@ class Chef
117
119
 
118
120
  # @return [Boolean] is the node a member of the workgroup specified in the resource
119
121
  def workgroup_member?
120
- node_workgroup = powershell_out!("(Get-WmiObject -Class Win32_ComputerSystem).Workgroup")
122
+ node_workgroup = powershell_exec!("(Get-WmiObject -Class Win32_ComputerSystem).Workgroup")
121
123
  raise "Failed to determine if system already a member of workgroup #{new_resource.workgroup_name}" if node_workgroup.error?
122
124
 
123
- node_workgroup.stdout.downcase.strip == new_resource.workgroup_name.downcase
125
+ String(node_workgroup.result).downcase.strip == new_resource.workgroup_name.downcase
124
126
  end
125
127
  end
126
128
  end
@@ -37,7 +37,7 @@ class Chef
37
37
  gpgkey 'http://artifacts.ourco.org/pub/yum/RPM-GPG-KEY-OURCO-8'
38
38
  action :create
39
39
  end
40
- ```ruby
40
+ ```
41
41
 
42
42
  **Delete a repository**:
43
43
 
@@ -123,11 +123,7 @@ class Chef
123
123
  # * Chef::Exceptions::InvalidResourceSpecification for all invalid input.
124
124
  def validate_lookup_spec!(query_object)
125
125
  case query_object
126
- when Chef::Resource
127
- true
128
- when SINGLE_RESOURCE_MATCH, MULTIPLE_RESOURCE_MATCH, NAMELESS_RESOURCE_MATCH
129
- true
130
- when Hash
126
+ when Chef::Resource, SINGLE_RESOURCE_MATCH, MULTIPLE_RESOURCE_MATCH, NAMELESS_RESOURCE_MATCH, Hash
131
127
  true
132
128
  when String
133
129
  raise Chef::Exceptions::InvalidResourceSpecification,
@@ -23,94 +23,96 @@ require_relative "node"
23
23
  require_relative "resources"
24
24
  require_relative "json_compat"
25
25
 
26
- module ResourceInspector
27
- def self.get_default(default)
28
- if default.is_a?(Chef::DelayedEvaluator)
29
- # ideally we'd get the block we pass to `lazy`, but the best we can do
30
- # is to get the source location, which then results in reparsing the source
31
- # code for the resource ourselves and just no
32
- "lazy default"
33
- else
34
- default.is_a?(Symbol) ? default.inspect : default # inspect properly returns symbols
26
+ class Chef
27
+ module ResourceInspector
28
+ def self.get_default(default)
29
+ if default.is_a?(Chef::DelayedEvaluator)
30
+ # ideally we'd get the block we pass to `lazy`, but the best we can do
31
+ # is to get the source location, which then results in reparsing the source
32
+ # code for the resource ourselves and just no
33
+ "lazy default"
34
+ else
35
+ default.is_a?(Symbol) ? default.inspect : default # inspect properly returns symbols
36
+ end
35
37
  end
36
- end
37
38
 
38
- def self.extract_resource(resource, complete = false)
39
- data = {}
40
- data[:description] = resource.description
41
- # data[:deprecated] = resource.deprecated || false
42
- data[:default_action] = resource.default_action
43
- data[:actions] = resource.allowed_actions
44
- data[:examples] = resource.examples
45
- data[:introduced] = resource.introduced
46
- data[:preview] = resource.preview_resource
39
+ def self.extract_resource(resource, complete = false)
40
+ data = {}
41
+ data[:description] = resource.description
42
+ # data[:deprecated] = resource.deprecated || false
43
+ data[:default_action] = resource.default_action
44
+ data[:actions] = resource.allowed_actions
45
+ data[:examples] = resource.examples
46
+ data[:introduced] = resource.introduced
47
+ data[:preview] = resource.preview_resource
47
48
 
48
- properties = unless complete
49
- resource.properties.reject { |_, k| k.options[:declared_in] == Chef::Resource || k.options[:skip_docs] }
50
- else
51
- resource.properties.reject { |_, k| k.options[:skip_docs] }
52
- end
49
+ properties = unless complete
50
+ resource.properties.reject { |_, k| k.options[:declared_in] == Chef::Resource || k.options[:skip_docs] }
51
+ else
52
+ resource.properties.reject { |_, k| k.options[:skip_docs] }
53
+ end
53
54
 
54
- data[:properties] = properties.each_with_object([]) do |(n, k), acc|
55
- opts = k.options
56
- acc << { name: n, description: opts[:description],
57
- introduced: opts[:introduced], is: opts[:is],
58
- deprecated: opts[:deprecated] || false,
59
- required: opts[:required] || false,
60
- default: opts[:default_description] || get_default(opts[:default]),
61
- name_property: opts[:name_property] || false,
62
- equal_to: sort_equal_to(opts[:equal_to]) }
55
+ data[:properties] = properties.each_with_object([]) do |(n, k), acc|
56
+ opts = k.options
57
+ acc << { name: n, description: opts[:description],
58
+ introduced: opts[:introduced], is: opts[:is],
59
+ deprecated: opts[:deprecated] || false,
60
+ required: opts[:required] || false,
61
+ default: opts[:default_description] || get_default(opts[:default]),
62
+ name_property: opts[:name_property] || false,
63
+ equal_to: sort_equal_to(opts[:equal_to]) }
64
+ end
65
+ data
63
66
  end
64
- data
65
- end
66
67
 
67
- def self.sort_equal_to(equal_to)
68
- Array(equal_to).sort.map(&:inspect)
69
- rescue ArgumentError
70
- Array(equal_to).map(&:inspect)
71
- end
68
+ def self.sort_equal_to(equal_to)
69
+ Array(equal_to).sort.map(&:inspect)
70
+ rescue ArgumentError
71
+ Array(equal_to).map(&:inspect)
72
+ end
72
73
 
73
- def self.extract_cookbook(path, complete)
74
- path = File.expand_path(path)
75
- dir, name = File.split(path)
76
- Chef::Cookbook::FileVendor.fetch_from_disk(path)
77
- loader = Chef::CookbookLoader.new(dir)
78
- cookbook = loader.load_cookbook(name)
79
- resources = cookbook.files_for(:resources)
74
+ def self.extract_cookbook(path, complete)
75
+ path = File.expand_path(path)
76
+ dir, name = File.split(path)
77
+ Chef::Cookbook::FileVendor.fetch_from_disk(path)
78
+ loader = Chef::CookbookLoader.new(dir)
79
+ cookbook = loader.load_cookbook(name)
80
+ resources = cookbook.files_for(:resources)
80
81
 
81
- resources.each_with_object({}) do |r, res|
82
- pth = r["full_path"]
83
- cur = Chef::Resource::LWRPBase.build_from_file(name, pth, Chef::RunContext.new(Chef::Node.new, nil, nil))
84
- res[cur.resource_name] = extract_resource(cur, complete)
82
+ resources.each_with_object({}) do |r, res|
83
+ pth = r["full_path"]
84
+ cur = Chef::Resource::LWRPBase.build_from_file(name, pth, Chef::RunContext.new(Chef::Node.new, nil, nil))
85
+ res[cur.resource_name] = extract_resource(cur, complete)
86
+ end
85
87
  end
86
- end
87
88
 
88
- # If we're given no resources, dump all of Chef's built ins
89
- # otherwise, if we have a path then extract all the resources from the cookbook
90
- # or else do a list of built in resources
91
- #
92
- # @param arguments [Array, String] One of more paths to a cookbook or a resource file to inspect
93
- # @param complete [TrueClass, FalseClass] Whether to show properties defined in the base Resource class
94
- # @return [String] JSON formatting of all resources
95
- def self.inspect(arguments = [], complete: false)
96
- output = if arguments.empty?
97
- ObjectSpace.each_object(Class).select { |k| k < Chef::Resource }.each_with_object({}) { |klass, acc| acc[klass.resource_name] = extract_resource(klass) }
98
- else
99
- Array(arguments).each_with_object({}) do |arg, acc|
100
- if File.directory?(arg)
101
- extract_cookbook(arg, complete).each { |k, v| acc[k] = v }
102
- else
103
- r = Chef::ResourceResolver.resolve(arg.to_sym)
104
- acc[r.resource_name] = extract_resource(r, complete)
89
+ # If we're given no resources, dump all of Chef's built ins
90
+ # otherwise, if we have a path then extract all the resources from the cookbook
91
+ # or else do a list of built in resources
92
+ #
93
+ # @param arguments [Array, String] One of more paths to a cookbook or a resource file to inspect
94
+ # @param complete [TrueClass, FalseClass] Whether to show properties defined in the base Resource class
95
+ # @return [String] JSON formatting of all resources
96
+ def self.inspect(arguments = [], complete: false)
97
+ output = if arguments.empty?
98
+ ObjectSpace.each_object(Class).select { |k| k < Chef::Resource }.each_with_object({}) { |klass, acc| acc[klass.resource_name] = extract_resource(klass) }
99
+ else
100
+ Array(arguments).each_with_object({}) do |arg, acc|
101
+ if File.directory?(arg)
102
+ extract_cookbook(arg, complete).each { |k, v| acc[k] = v }
103
+ else
104
+ r = Chef::ResourceResolver.resolve(arg.to_sym)
105
+ acc[r.resource_name] = extract_resource(r, complete)
106
+ end
105
107
  end
106
108
  end
107
- end
108
109
 
109
- Chef::JSONCompat.to_json_pretty(output)
110
- end
110
+ Chef::JSONCompat.to_json_pretty(output)
111
+ end
111
112
 
112
- def self.start
113
- puts inspect(ARGV, complete: true)
114
- end
113
+ def self.start
114
+ puts inspect(ARGV, complete: true)
115
+ end
115
116
 
117
+ end
116
118
  end
@@ -173,7 +173,7 @@ class Chef
173
173
  # Mutex name is case-sensitive contrary to other things in
174
174
  # windows. "\" is the only invalid character.
175
175
  def acquire_win32_mutex
176
- @mutex = Chef::ReservedNames::Win32::Mutex.new("Global\\#{runlock_file.gsub(/[\\]/, "/").downcase}")
176
+ @mutex = Chef::ReservedNames::Win32::Mutex.new("Global\\#{runlock_file.tr('\\', "/").downcase}")
177
177
  mutex.test
178
178
  end
179
179
 
@@ -71,10 +71,6 @@ class Chef
71
71
  return_value
72
72
  rescue Exception => exception
73
73
  log_failed_request(response, return_value) unless response.nil?
74
-
75
- if exception.respond_to?(:chef_rest_request=)
76
- exception.chef_rest_request = rest_request
77
- end
78
74
  raise
79
75
  end
80
76
  end
@@ -62,7 +62,7 @@ module Shell
62
62
  if subsession = jobs.select_shell_session(context_obj)
63
63
  jobs.switch(subsession)
64
64
  else
65
- irb(context_obj)
65
+ irb(context_obj) # rubocop: disable Lint/Debugger
66
66
  end
67
67
  end
68
68
 
@@ -89,9 +89,7 @@ class Chef
89
89
  case op_action
90
90
  when "InDesiredState"
91
91
  current_resource[:skipped] = op_value.strip == "True" ? true : false
92
- when "ResourcesInDesiredState"
93
- current_resource[:name] = op_value.strip if op_value
94
- when "ResourcesNotInDesiredState"
92
+ when "ResourcesInDesiredState", "ResourcesNotInDesiredState"
95
93
  current_resource[:name] = op_value.strip if op_value
96
94
  when "ReturnValue"
97
95
  current_resource[:context] = nil
@@ -105,7 +105,7 @@ class Chef::Util::DSC
105
105
 
106
106
  def dsc_module_import_failure?(command_output)
107
107
  !! (command_output =~ /\sCimException/ &&
108
- command_output =~ /ProviderOperationExecutionFailure/ &&
108
+ command_output.include?("ProviderOperationExecutionFailure") &&
109
109
  command_output =~ /\smodule\s+is\s+installed/)
110
110
  end
111
111
 
@@ -31,13 +31,9 @@ class Chef
31
31
  @node = node
32
32
 
33
33
  case output_format
34
- when nil
34
+ when nil, :text
35
35
  @json_format = false
36
- when :json
37
- @json_format = true
38
- when :text
39
- @json_format = false
40
- when :object
36
+ when :json, :object
41
37
  @json_format = true
42
38
  else
43
39
  raise ArgumentError, "Invalid output format #{output_format} specified"
@@ -128,9 +124,7 @@ class Chef
128
124
  switch_present = true
129
125
 
130
126
  case switch_value
131
- when Numeric
132
- switch_argument = switch_value.to_s
133
- when Float
127
+ when Numeric, Float
134
128
  switch_argument = switch_value.to_s
135
129
  when FalseClass
136
130
  switch_present = false
@@ -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.6.14")
26
+ VERSION = Chef::VersionString.new("16.7.61")
27
27
  end
28
28
 
29
29
  #
@@ -321,7 +321,7 @@ class Chef
321
321
  while status == ERROR_MORE_DATA
322
322
  status = NetUserEnum(servername, level, filter, bufptr, prefmaxlen, entriesread, totalentries, resume_handle)
323
323
 
324
- if status == NERR_Success || status == ERROR_MORE_DATA
324
+ if [NERR_Success, ERROR_MORE_DATA].include?(status)
325
325
  Array.new(entriesread.read_long) do |i|
326
326
  user_info = USER_INFO_3.new(bufptr.read_pointer + i * USER_INFO_3.size)
327
327
  # Check if the account is the Administrator account
@@ -23,15 +23,15 @@ describe Chef::Mixin::PowershellOut, :windows_only do
23
23
 
24
24
  describe "#powershell_out" do
25
25
  it "runs a powershell command and collects stdout" do
26
- expect(powershell_out("get-process").run_command.stdout).to match /Handles/
26
+ expect(powershell_out("get-process").run_command.stdout).to match(/Handles/)
27
27
  end
28
28
 
29
29
  it "uses :powershell by default" do
30
- expect(powershell_out("$PSVersionTable").run_command.stdout).to match /CLRVersion/
30
+ expect(powershell_out("$PSVersionTable").run_command.stdout).to match(/CLRVersion/)
31
31
  end
32
32
 
33
33
  it ":pwsh interpreter uses core edition", :pwsh_installed do
34
- expect(powershell_out("$PSVersionTable", :pwsh).run_command.stdout).to match /Core/
34
+ expect(powershell_out("$PSVersionTable", :pwsh).run_command.stdout).to match(/Core/)
35
35
  end
36
36
 
37
37
  it "does not raise exceptions when the command is invalid" do
@@ -41,7 +41,7 @@ describe Chef::Mixin::PowershellOut, :windows_only do
41
41
 
42
42
  describe "#powershell_out!" do
43
43
  it "runs a powershell command and collects stdout" do
44
- expect(powershell_out!("get-process").run_command.stdout).to match /Handles/
44
+ expect(powershell_out!("get-process").run_command.stdout).to match(/Handles/)
45
45
  end
46
46
 
47
47
  it "raises exceptions when the command is invalid" do
@@ -39,9 +39,7 @@ module AptServer
39
39
  def tcp_test_port(hostname, port)
40
40
  tcp_socket = TCPSocket.new(hostname, port)
41
41
  true
42
- rescue Errno::ETIMEDOUT
43
- false
44
- rescue Errno::ECONNREFUSED
42
+ rescue Errno::ETIMEDOUT, Errno::ECONNREFUSED
45
43
  false
46
44
  ensure
47
45
  tcp_socket && tcp_socket.close
@@ -326,7 +324,7 @@ describe Chef::Resource::AptPackage, metadata do
326
324
  pkg_check = shell_out!("dpkg -l chef-integration-test", returns: [0, 1])
327
325
 
328
326
  if pkg_check.exitstatus == 0
329
- expect(pkg_check.stdout).to match(/un[\s]+chef-integration-test/)
327
+ expect(pkg_check.stdout).to match(/un\s+chef-integration-test/)
330
328
  end
331
329
  end
332
330
 
@@ -359,7 +357,7 @@ describe Chef::Resource::AptPackage, metadata do
359
357
  it "upgrades the package for action :upgrade" do
360
358
  package_resource.run_action(:upgrade)
361
359
  dpkg_l = shell_out!("dpkg -l chef-integration-test", returns: [0])
362
- expect(dpkg_l.stdout).to match(/chef\-integration\-test[\s]+1\.1\-1/)
360
+ expect(dpkg_l.stdout).to match(/chef\-integration\-test\s+1\.1\-1/)
363
361
  expect(package_resource).to be_updated_by_last_action
364
362
  end
365
363
 
@@ -373,7 +371,7 @@ describe Chef::Resource::AptPackage, metadata do
373
371
  it "upgrades the package for action :install" do
374
372
  package_resource.run_action(:install)
375
373
  dpkg_l = shell_out!("dpkg -l chef-integration-test", returns: [0])
376
- expect(dpkg_l.stdout).to match(/chef\-integration\-test[\s]+1\.1\-1/)
374
+ expect(dpkg_l.stdout).to match(/chef\-integration\-test\s+1\.1\-1/)
377
375
  expect(package_resource).to be_updated_by_last_action
378
376
  end
379
377
  end
@@ -16,13 +16,13 @@
16
16
  # limitations under the License.
17
17
  #
18
18
  require "spec_helper"
19
- require "chef/mixin/powershell_out"
19
+ require "chef/mixin/shell_out"
20
20
 
21
21
  describe Chef::Resource::ChocolateyPackage, :windows_only, :choco_installed do
22
- include Chef::Mixin::PowershellOut
22
+ include Chef::Mixin::ShellOut
23
23
 
24
24
  let(:package_name) { "test-A" }
25
- let(:package_list) { proc { powershell_out!("choco list -lo -r #{Array(package_name).join(" ")}").stdout.chomp } }
25
+ let(:package_list) { proc { shell_out!("choco list -lo -r #{Array(package_name).join(" ")}").stdout.chomp } }
26
26
  let(:package_source) { File.join(CHEF_SPEC_ASSETS, "chocolatey_feed") }
27
27
 
28
28
  let(:run_context) do
@@ -26,7 +26,7 @@ describe Chef::Resource::Cron, :requires_root, :unix_only do
26
26
  # Platform specific validation routines.
27
27
  def cron_should_exists(cron_name, command)
28
28
  case ohai[:platform]
29
- when "aix", "opensolaris", "solaris2", "omnios"
29
+ when "aix", "solaris2", "omnios"
30
30
  expect(shell_out("crontab -l #{new_resource.user} | grep \"#{cron_name}\"").exitstatus).to eq(0)
31
31
  expect(shell_out("crontab -l #{new_resource.user} | grep \"#{cron_name}\"").stdout.lines.to_a.size).to eq(1)
32
32
  expect(shell_out("crontab -l #{new_resource.user} | grep \"#{command}\"").exitstatus).to eq(0)
@@ -41,7 +41,7 @@ describe Chef::Resource::Cron, :requires_root, :unix_only do
41
41
 
42
42
  def cron_should_not_exists(cron_name)
43
43
  case ohai[:platform]
44
- when "aix", "opensolaris", "solaris2", "omnios"
44
+ when "aix", "solaris2", "omnios"
45
45
  expect(shell_out("crontab -l #{new_resource.user} | grep \"#{cron_name}\"").exitstatus).to eq(1)
46
46
  expect(shell_out("crontab -l #{new_resource.user} | grep \"#{new_resource.command}\"").stdout.lines.to_a.size).to eq(0)
47
47
  else
@@ -113,7 +113,7 @@ describe Chef::Resource::Cron, :requires_root, :unix_only do
113
113
  end
114
114
  end
115
115
 
116
- exclude_solaris = %w{solaris opensolaris solaris2 omnios}.include?(ohai[:platform])
116
+ exclude_solaris = %w{solaris solaris2 omnios}.include?(ohai[:platform])
117
117
  describe "create action with various attributes", external: exclude_solaris do
118
118
  def create_and_validate_with_property(resource, attribute, value)
119
119
  if ohai[:platform] == "aix"
@@ -17,13 +17,13 @@
17
17
  #
18
18
 
19
19
  require "spec_helper"
20
- require "chef/mixin/powershell_out"
20
+ require "chef/mixin/powershell_exec"
21
21
  require "chef/mixin/windows_architecture_helper"
22
22
  require "support/shared/integration/integration_helper"
23
23
 
24
24
  describe Chef::Resource::DscScript, :windows_powershell_dsc_only do
25
25
  include Chef::Mixin::WindowsArchitectureHelper
26
- include Chef::Mixin::PowershellOut
26
+ include Chef::Mixin::PowershellExec
27
27
  before(:all) do
28
28
  @temp_dir = ::Dir.mktmpdir("dsc-functional-test")
29
29
  # enable the HTTP listener if it is not already enabled needed by underlying DSC engine
@@ -33,7 +33,7 @@ describe Chef::Resource::DscScript, :windows_powershell_dsc_only do
33
33
  winrm create winrm/config/Listener?Address=*+Transport=HTTP
34
34
  }
35
35
  CODE
36
- powershell_out!(winrm_code)
36
+ powershell_exec!(winrm_code)
37
37
  end
38
38
 
39
39
  after(:all) do