summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Dodge <mikedodge04@fb.com>2015-03-26 15:09:19 -0700
committerMike Dodge <mikedodge04@fb.com>2015-03-26 15:09:19 -0700
commit0d1bc71edebcf4b7e11b5640c9331bc13030bf91 (patch)
treec1bf53dae6701bc73165dc8cf60bd8452b7b9d13
parent5b8fcf1e8285643e797090de505f33d5aab2a89f (diff)
downloadchef-0d1bc71edebcf4b7e11b5640c9331bc13030bf91.tar.gz
added requsted chagnes
-rw-r--r--lib/chef/provider/service/macosx.rb13
-rw-r--r--lib/chef/resource/macosx_service.rb1
-rw-r--r--spec/unit/provider/service/macosx_spec.rb1
3 files changed, 10 insertions, 5 deletions
diff --git a/lib/chef/provider/service/macosx.rb b/lib/chef/provider/service/macosx.rb
index 82c66c3199..38ea6124bf 100644
--- a/lib/chef/provider/service/macosx.rb
+++ b/lib/chef/provider/service/macosx.rb
@@ -96,6 +96,11 @@ 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
@@ -156,15 +161,15 @@ class Chef
def load_service
session = @session_type ? "-S #{@session_type} " : ''
cmd = 'launchctl load -w ' + session + @plist
- shell_out_with_su?(cmd)
+ shell_out_as_user(cmd)
end
def unload_service
cmd = 'launchctl unload -w ' + @plist
- shell_out_with_su?(cmd)
+ shell_out_as_user(cmd)
end
- def shell_out_with_su?(cmd)
+ def shell_out_as_user(cmd)
if @console_user
shell_out_with_systems_locale("#{@base_user_cmd} '#{cmd}'")
else
@@ -177,7 +182,7 @@ class Chef
return if @plist == nil or @service_label.to_s.empty?
cmd = "launchctl list #{@service_label}"
- res = shell_out_with_su?(cmd)
+ res = shell_out_as_user(cmd)
if res.exitstatus == 0
@current_resource.enabled(true)
diff --git a/lib/chef/resource/macosx_service.rb b/lib/chef/resource/macosx_service.rb
index be58dc6676..879ea99cf8 100644
--- a/lib/chef/resource/macosx_service.rb
+++ b/lib/chef/resource/macosx_service.rb
@@ -39,7 +39,6 @@ class Chef
# This will enable user to pass a plist in the case
# that the filename and label for the service dont match
def plist(arg=nil)
- assert_path_exists(arg) unless arg.nil?
set_or_return(
:plist,
arg,
diff --git a/spec/unit/provider/service/macosx_spec.rb b/spec/unit/provider/service/macosx_spec.rb
index 4337ee2cee..76301a8129 100644
--- a/spec/unit/provider/service/macosx_spec.rb
+++ b/spec/unit/provider/service/macosx_spec.rb
@@ -161,6 +161,7 @@ SVC_LIST
describe "running unsupported actions" do
before do
allow(Dir).to receive(:glob).and_return(["#{plist}"], [])
+ allow(File).to receive(:exists?).and_return([true], [])
end
it "should throw an exception when reload action is attempted" do
expect {provider.run_action(:reload)}.to raise_error(Chef::Exceptions::UnsupportedAction)