diff options
author | Tim Smith <tsmith@chef.io> | 2018-02-22 20:53:17 -0800 |
---|---|---|
committer | Tim Smith <tsmith@chef.io> | 2018-02-22 20:53:17 -0800 |
commit | 72f3eb3153f51d3102fa9e400e3cbf2127beb3c0 (patch) | |
tree | c51e2c0b8876e11a7ef80d931b725ccfbfac673e /lib/chef/resource/cron.rb | |
parent | b3a3fbaab35da9e7927a0cb1ae5e379f28ecc000 (diff) | |
download | chef-72f3eb3153f51d3102fa9e400e3cbf2127beb3c0.tar.gz |
Convert parts of cron resource to use propertiescron
Modernize this resource a bit.
Signed-off-by: Tim Smith <tsmith@chef.io>
Diffstat (limited to 'lib/chef/resource/cron.rb')
-rw-r--r-- | lib/chef/resource/cron.rb | 76 |
1 files changed, 10 insertions, 66 deletions
diff --git a/lib/chef/resource/cron.rb b/lib/chef/resource/cron.rb index 72023c31ed..f6c009058c 100644 --- a/lib/chef/resource/cron.rb +++ b/lib/chef/resource/cron.rb @@ -22,12 +22,13 @@ require "chef/resource" class Chef class Resource class Cron < Chef::Resource + resource_name :cron + provides :cron + description "Use the cron resource to manage cron entries for time-based job scheduling."\ " Properties for a schedule will default to * if not provided. The cron resource"\ " requires access to a crontab program, typically cron." - identity_attr :command - state_attrs :minute, :hour, :day, :month, :weekday, :user default_action :create @@ -40,14 +41,6 @@ class Chef @day = "*" @month = "*" @weekday = "*" - @command = nil - @user = "root" - @mailto = nil - @path = nil - @shell = nil - @home = nil - @time = nil - @environment = {} end def minute(arg = nil) @@ -150,65 +143,16 @@ class Chef ) end - def mailto(arg = nil) - set_or_return( - :mailto, - arg, - :kind_of => String - ) - end - - def path(arg = nil) - set_or_return( - :path, - arg, - :kind_of => String - ) - end - - def home(arg = nil) - set_or_return( - :home, - arg, - :kind_of => String - ) - end - - def shell(arg = nil) - set_or_return( - :shell, - arg, - :kind_of => String - ) - end - - def command(arg = nil) - set_or_return( - :command, - arg, - :kind_of => String - ) - end - - def user(arg = nil) - set_or_return( - :user, - arg, - :kind_of => String - ) - end - - def environment(arg = nil) - set_or_return( - :environment, - arg, - :kind_of => Hash - ) - end + property :mailto, String + property :path, String + property :home, String + property :shell, String + property :command, String, identity: true + property :user, String, default: "root" + property :environment, Hash, default: {} private - # On Ruby 1.8, Kernel#Integer will happily do this for you. On 1.9, no. def integerize(integerish) Integer(integerish) rescue TypeError |