diff options
author | Thom May <thom@chef.io> | 2018-03-09 18:28:47 +0000 |
---|---|---|
committer | Thom May <thom@chef.io> | 2018-03-14 16:29:48 +0000 |
commit | 61e3d4bb382da5a0f6c09dd144ce4c6fc96c3ca9 (patch) | |
tree | c83baedaba2f265ebc85a4be907ad2c0ea0c26a8 /lib/chef/resource | |
parent | f1c97d18f68b01e8f82757bbb1111ca82d4fba99 (diff) | |
download | chef-61e3d4bb382da5a0f6c09dd144ce4c6fc96c3ca9.tar.gz |
update mount to use properties and fix 6851
Signed-off-by: Thom May <thom@chef.io>
Diffstat (limited to 'lib/chef/resource')
-rw-r--r-- | lib/chef/resource/mount.rb | 141 |
1 files changed, 17 insertions, 124 deletions
diff --git a/lib/chef/resource/mount.rb b/lib/chef/resource/mount.rb index f70267fd23..119363aea7 100644 --- a/lib/chef/resource/mount.rb +++ b/lib/chef/resource/mount.rb @@ -24,10 +24,6 @@ class Chef class Mount < Chef::Resource description "Use the mount resource to manage a mounted file system." - identity_attr :device - - state_attrs :mount_point, :device_type, :fstype, :username, :password, :domain - default_action :mount allowed_actions :mount, :umount, :unmount, :remount, :enable, :disable @@ -37,130 +33,27 @@ class Chef property :password, String, sensitive: true - def initialize(name, run_context = nil) - super - @mount_point = name - @device = nil - @device_type = :device - @fsck_device = "-" - @fstype = "auto" - @options = ["defaults"] - @dump = 0 - @pass = 2 - @mounted = false - @enabled = false - @username = nil - @password = nil - @domain = nil - end - - def mount_point(arg = nil) - set_or_return( - :mount_point, - arg, - :kind_of => [ String ] - ) - end - - def device(arg = nil) - set_or_return( - :device, - arg, - :kind_of => [ String ] - ) - end - - 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 => valid_devices - ) - end - - def fsck_device(arg = nil) - set_or_return( - :fsck_device, - arg, - :kind_of => [ String ] - ) - end - - def fstype(arg = nil) - set_or_return( - :fstype, - arg, - :kind_of => [ String ] - ) - end - - def options(arg = nil) - ret = set_or_return( - :options, - arg, - :kind_of => [ Array, String ] - ) - - if ret.is_a? String - ret.tr(",", " ").split(/ /) - else - ret - end - end - - def dump(arg = nil) - set_or_return( - :dump, - arg, - :kind_of => [ Integer, FalseClass ] - ) - end + property :mount_point, String, name_property: true + property :device, String, identity: true - def pass(arg = nil) - set_or_return( - :pass, - arg, - :kind_of => [ Integer, FalseClass ] - ) - end - - def mounted(arg = nil) - set_or_return( - :mounted, - arg, - :kind_of => [ TrueClass, FalseClass ] - ) - end + property :device_type, [String, Symbol], + coerce: proc { |arg| arg.kind_of?(String) ? arg.to_sym : arg }, + default: :device, + equal_to: RUBY_PLATFORM =~ /solaris/i ? %i{ device } : %i{ device label uuid } - def enabled(arg = nil) - set_or_return( - :enabled, - arg, - :kind_of => [ TrueClass, FalseClass ] - ) - end + property :fsck_device, String, default: "-" + property :fstype, String, default: "auto" - def username(arg = nil) - set_or_return( - :username, - arg, - :kind_of => [ String ] - ) - end + property :options, [Array, String], + coerce: proc { |arg| arg.kind_of?(String) ? arg.split(",") : arg }, + default: %w{defaults} - def domain(arg = nil) - set_or_return( - :domain, - arg, - :kind_of => [ String ] - ) - end + property :dump, [Integer, FalseClass], default: 0 + property :pass, [Integer, FalseClass], default: 2 + property :mounted, [TrueClass, FalseClass], default: false + property :enabled, [TrueClass, FalseClass], default: false + property :username, String + property :domain, String private |