From c007919ab4c8717eb749e16a016b94e60d879598 Mon Sep 17 00:00:00 2001 From: Lamont Granquist Date: Mon, 2 Jun 2014 14:51:28 -0700 Subject: move validation to resource code --- lib/chef/provider/mount/solaris.rb | 4 ---- lib/chef/resource/mount.rb | 10 ++++++++-- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'lib') diff --git a/lib/chef/provider/mount/solaris.rb b/lib/chef/provider/mount/solaris.rb index bb76831559..fb4150e810 100644 --- a/lib/chef/provider/mount/solaris.rb +++ b/lib/chef/provider/mount/solaris.rb @@ -48,10 +48,6 @@ class Chef end def define_resource_requirements - if device_type != :device - raise Chef::Exceptions::Mount, "Mount resource can only be of device_type ':device' on Solaris" - end - requirements.assert(:mount, :remount) do |a| a.assertion { !device_should_exist? || ::File.exist?(device) } a.failure_message(Chef::Exceptions::Mount, "Device #{device} does not exist") diff --git a/lib/chef/resource/mount.rb b/lib/chef/resource/mount.rb index 507c5329e3..4b6a8461e9 100644 --- a/lib/chef/resource/mount.rb +++ b/lib/chef/resource/mount.rb @@ -42,6 +42,7 @@ class Chef @action = :mount @supports = { :remount => false } @allowed_actions.push(:mount, :umount, :remount, :enable, :disable) + @allowed_actions.push(:mount, :umount, :remount, :enable, :disable) @username = nil @password = nil @domain = nil @@ -65,10 +66,15 @@ class Chef def device_type(arg=nil) real_arg = arg.kind_of?(String) ? arg.to_sym : arg + valid_devices = if RUBY_PLATFORM =~ /solaris/i + [ :device ] + else + [ :device, :label, :uuid ] + end set_or_return( :device_type, real_arg, - :equal_to => [ :device, :label, :uuid ] + :equal_to => valid_devices, ) end @@ -76,7 +82,7 @@ class Chef set_or_return( :fstype, arg, - :kind_of => [ String ] + :kind_of => [ String ], ) end -- cgit v1.2.1