summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2020-09-16 13:58:57 -0700
committerGitHub <noreply@github.com>2020-09-16 13:58:57 -0700
commitb9db7cf12d3df0f4e820993d5be73bdf218b7a67 (patch)
tree29805a609f6d34467b7a1f2508361be6f54aa001
parent7ee8b83c78bed43add0e74144a27e51e5825dc30 (diff)
parent619feaa1a7c7f1b82b7588005db2af2309a91aff (diff)
downloadchef-b9db7cf12d3df0f4e820993d5be73bdf218b7a67.tar.gz
Merge pull request #10437 from chef/extra_requires
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--lib/chef/chef_fs/parallelizer.rb1
-rw-r--r--lib/chef/cookbook_site_streaming_uploader.rb6
-rw-r--r--lib/chef/knife/bootstrap/chef_vault_handler.rb2
-rw-r--r--lib/chef/provider/launchd.rb2
-rw-r--r--lib/chef/provider/package/zypper.rb2
-rw-r--r--lib/chef/provider/route.rb6
-rw-r--r--lib/chef/provider/service/macosx.rb2
-rw-r--r--lib/chef/provider/template_finder.rb12
-rw-r--r--lib/chef/provider_resolver.rb2
-rw-r--r--lib/chef/recipe.rb2
-rw-r--r--lib/chef/resource/execute.rb2
-rw-r--r--lib/chef/util/threaded_job_queue.rb2
-rw-r--r--spec/tiny_server.rb1
-rw-r--r--spec/unit/runner_spec.rb3
14 files changed, 12 insertions, 33 deletions
diff --git a/lib/chef/chef_fs/parallelizer.rb b/lib/chef/chef_fs/parallelizer.rb
index be7d93c669..c4d17a842d 100644
--- a/lib/chef/chef_fs/parallelizer.rb
+++ b/lib/chef/chef_fs/parallelizer.rb
@@ -1,4 +1,3 @@
-require "thread"
require_relative "parallelizer/parallel_enumerable"
class Chef
diff --git a/lib/chef/cookbook_site_streaming_uploader.rb b/lib/chef/cookbook_site_streaming_uploader.rb
index 9f2efd3d8a..65b27fed1d 100644
--- a/lib/chef/cookbook_site_streaming_uploader.rb
+++ b/lib/chef/cookbook_site_streaming_uploader.rb
@@ -231,11 +231,7 @@ class Chef
@part_no += 1
@part_offset = 0
next_part = read(how_much_next_part)
- result = current_part + if next_part
- next_part
- else
- ""
- end
+ result = current_part + (next_part || "")
else
@part_offset += how_much_current_part
result = current_part
diff --git a/lib/chef/knife/bootstrap/chef_vault_handler.rb b/lib/chef/knife/bootstrap/chef_vault_handler.rb
index b36c178d8e..20759d6fdf 100644
--- a/lib/chef/knife/bootstrap/chef_vault_handler.rb
+++ b/lib/chef/knife/bootstrap/chef_vault_handler.rb
@@ -112,7 +112,7 @@ class Chef
if bootstrap_vault_item
bootstrap_vault_item
else
- json = bootstrap_vault_json ? bootstrap_vault_json : File.read(bootstrap_vault_file)
+ json = bootstrap_vault_json || File.read(bootstrap_vault_file)
Chef::JSONCompat.from_json(json)
end
end
diff --git a/lib/chef/provider/launchd.rb b/lib/chef/provider/launchd.rb
index 37c73924f8..1045d4294f 100644
--- a/lib/chef/provider/launchd.rb
+++ b/lib/chef/provider/launchd.rb
@@ -209,7 +209,7 @@ class Chef
# @api private
def path
- @path ||= new_resource.path ? new_resource.path : gen_path_from_type
+ @path ||= new_resource.path || gen_path_from_type
end
end
end
diff --git a/lib/chef/provider/package/zypper.rb b/lib/chef/provider/package/zypper.rb
index 1096dcd044..da6bf0efbf 100644
--- a/lib/chef/provider/package/zypper.rb
+++ b/lib/chef/provider/package/zypper.rb
@@ -158,7 +158,7 @@ class Chef
end
def global_options
- new_resource.global_options if new_resource.global_options
+ new_resource.global_options
end
end
end
diff --git a/lib/chef/provider/route.rb b/lib/chef/provider/route.rb
index 3eac41aef0..8a304a7e45 100644
--- a/lib/chef/provider/route.rb
+++ b/lib/chef/provider/route.rb
@@ -169,11 +169,7 @@ class Chef
next unless resource.is_a? Chef::Resource::Route
# default to eth0
- dev = if resource.device
- resource.device
- else
- "eth0"
- end
+ dev = resource.device || "eth0"
conf[dev] = "" if conf[dev].nil?
case @action
diff --git a/lib/chef/provider/service/macosx.rb b/lib/chef/provider/service/macosx.rb
index ae04c7bfdd..2152789a6e 100644
--- a/lib/chef/provider/service/macosx.rb
+++ b/lib/chef/provider/service/macosx.rb
@@ -47,7 +47,7 @@ class Chef
@current_resource = Chef::Resource::MacosxService.new(@new_resource.name)
@current_resource.service_name(@new_resource.service_name)
@plist_size = 0
- @plist = @new_resource.plist ? @new_resource.plist : find_service_plist
+ @plist = @new_resource.plist || find_service_plist
@service_label = find_service_label
# LaunchAgents should be loaded as the console user.
@console_user = @plist ? @plist.include?("LaunchAgents") : false
diff --git a/lib/chef/provider/template_finder.rb b/lib/chef/provider/template_finder.rb
index fdc5eaeda9..fa120a1624 100644
--- a/lib/chef/provider/template_finder.rb
+++ b/lib/chef/provider/template_finder.rb
@@ -43,19 +43,11 @@ class Chef
protected
def template_source_name(name, options)
- if options[:source]
- options[:source]
- else
- name
- end
+ options[:source] || name
end
def find_cookbook_name(options)
- if options[:cookbook]
- options[:cookbook]
- else
- @cookbook_name
- end
+ options[:cookbook] || @cookbook_name
end
end
end
diff --git a/lib/chef/provider_resolver.rb b/lib/chef/provider_resolver.rb
index b0dd0d9376..94727a1043 100644
--- a/lib/chef/provider_resolver.rb
+++ b/lib/chef/provider_resolver.rb
@@ -113,7 +113,7 @@ class Chef
# if resource.provider is set, just return one of those objects
def maybe_explicit_provider(resource)
- resource.provider if resource.provider
+ resource.provider
end
# try dynamically finding a provider based on querying the providers to see what they support
diff --git a/lib/chef/recipe.rb b/lib/chef/recipe.rb
index 4009677936..972edf9649 100644
--- a/lib/chef/recipe.rb
+++ b/lib/chef/recipe.rb
@@ -122,7 +122,7 @@ class Chef
end
def to_s
- "cookbook: #{cookbook_name ? cookbook_name : "(none)"}, recipe: #{recipe_name ? recipe_name : "(none)"} "
+ "cookbook: #{cookbook_name || "(none)"}, recipe: #{recipe_name || "(none)"} "
end
def inspect
diff --git a/lib/chef/resource/execute.rb b/lib/chef/resource/execute.rb
index 93bf689dd9..11d1c2fc40 100644
--- a/lib/chef/resource/execute.rb
+++ b/lib/chef/resource/execute.rb
@@ -587,7 +587,7 @@ class Chef
ancestor_attributes = superclass.guard_inherited_attributes
end
- ancestor_attributes.concat(@class_inherited_attributes ? @class_inherited_attributes : []).uniq
+ ancestor_attributes.concat(@class_inherited_attributes || []).uniq
end
# post resource creation validation
diff --git a/lib/chef/util/threaded_job_queue.rb b/lib/chef/util/threaded_job_queue.rb
index efbb67216f..bce25e9225 100644
--- a/lib/chef/util/threaded_job_queue.rb
+++ b/lib/chef/util/threaded_job_queue.rb
@@ -13,8 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require "thread"
-
class Chef
class Util
# A simple threaded job queue
diff --git a/spec/tiny_server.rb b/spec/tiny_server.rb
index 868933b042..786130d0d5 100644
--- a/spec/tiny_server.rb
+++ b/spec/tiny_server.rb
@@ -19,7 +19,6 @@
require "webrick"
require "webrick/https"
require "rack"
-require "thread"
require "singleton"
require "open-uri"
require "chef/config"
diff --git a/spec/unit/runner_spec.rb b/spec/unit/runner_spec.rb
index 0dd8d43136..500ec13f7b 100644
--- a/spec/unit/runner_spec.rb
+++ b/spec/unit/runner_spec.rb
@@ -111,8 +111,7 @@ describe Chef::Runner do
it "should use the provider specified by the resource (if it has one)" do
provider = Chef::Provider::Easy.new(run_context.resource_collection[0], run_context)
- # Expect provider to be called twice, because will fall back to old provider lookup
- expect(run_context.resource_collection[0]).to receive(:provider).twice.and_return(Chef::Provider::Easy)
+ expect(run_context.resource_collection[0]).to receive(:provider).once.and_return(Chef::Provider::Easy)
expect(Chef::Provider::Easy).to receive(:new).once.and_return(provider)
runner.converge
end