summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Cowie <jonlives@gmail.com>2018-03-06 11:33:19 +0000
committerJon Cowie <jonlives@gmail.com>2018-03-06 11:33:19 +0000
commit06a4739692644a36a9199770f445145f1c3e4eb3 (patch)
treebf6e56a48c363473b3bbc44eafd0eb4cfc75a726
parent5f8b2df08cdce06533f050654598f0ec7308a69d (diff)
downloadchef-06a4739692644a36a9199770f445145f1c3e4eb3.tar.gz
Make location verification more idiomatic
Signed-off-by: Jon Cowie <jonlives@gmail.com>
-rw-r--r--lib/chef/data_collector.rb13
1 files changed, 5 insertions, 8 deletions
diff --git a/lib/chef/data_collector.rb b/lib/chef/data_collector.rb
index 1daf3b2456..65614e88ae 100644
--- a/lib/chef/data_collector.rb
+++ b/lib/chef/data_collector.rb
@@ -543,6 +543,10 @@ class Chef
end
end
+ def handle_type(type, loc)
+ type == :urls ? validate_and_return_uri(loc) : validate_and_create_file(loc)
+ end
+
def validate_data_collector_output_locations!
if data_collector_output_locations.empty?
raise Chef::Exceptions::ConfigurationError,
@@ -550,15 +554,8 @@ class Chef
end
data_collector_output_locations.each do |type, locations|
-
- method = if type == :urls
- method(:validate_and_return_uri)
- elsif type == :files
- method(:validate_and_create_file)
- end
-
locations.each do |l|
- unless method.call(l)
+ unless handle_type(type,l)
raise Chef::Exceptions::ConfigurationError,
"Chef::Config[:data_collector][:output_locations] contains the location #{l} which is not valid."
end