summaryrefslogtreecommitdiff
path: root/lib/chef/provider
diff options
context:
space:
mode:
authorMike Dodge <mikedodge04@fb.com>2015-04-01 13:35:03 -0700
committerMike Dodge <mikedodge04@fb.com>2015-04-01 13:35:03 -0700
commit455aaf2b879f341eea406b2004ff9524544da96e (patch)
tree8733dcdc986e8b0dcffcc4deb7c05e92e7ed542b /lib/chef/provider
parent04bd76a051270d529333c943e27fc2154378954f (diff)
downloadchef-455aaf2b879f341eea406b2004ff9524544da96e.tar.gz
adding assert for plist
Diffstat (limited to 'lib/chef/provider')
-rw-r--r--lib/chef/provider/service/macosx.rb14
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/chef/provider/service/macosx.rb b/lib/chef/provider/service/macosx.rb
index 4c40c5c865..f6a4c1a9c3 100644
--- a/lib/chef/provider/service/macosx.rb
+++ b/lib/chef/provider/service/macosx.rb
@@ -79,6 +79,12 @@ class Chef
a.failure_message Chef::Exceptions::Service, "Several plist files match service name. Please use full service name."
end
+ requirements.assert(:all_actions) do |a|
+ a.assertion {::File.exists?(@plist.to_s) }
+ a.failure_message Chef::Exceptions::Service,
+ "Could not find plist for #{@new_resource}"
+ end
+
requirements.assert(:enable, :disable) do |a|
a.assertion { !@service_label.to_s.empty? }
a.failure_message Chef::Exceptions::Service,
@@ -94,11 +100,6 @@ class Chef
@current_resource.running(false)
end
end
-
- requirements.assert(:all_actions) do |a|
- a.assertion { @plist.nil? ? true : ::File.exists?(@plist) }
- a.failure_message Chef::Exceptions::Service, "#{@plist} does not exist"
- end
end
def start_service
@@ -209,6 +210,9 @@ class Chef
# onto the node yet."
return nil if @plist.nil?
+ # Plist must exist by this point
+ raise Chef::Exceptions::FileNotFound, "Cannot find #{@plist}!" unless ::File.exists?(@plist)
+
# Most services have the same internal label as the name of the
# plist file. However, there is no rule saying that *has* to be
# the case, and some core services (notably, ssh) do not follow