summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThom May <thom@may.lt>2018-02-26 18:01:28 +0000
committerGitHub <noreply@github.com>2018-02-26 18:01:28 +0000
commit370aaa0406d85f11da4908f8ea405ea544a2e574 (patch)
tree6fe44031301bba7391d052b6d6eb3e7279dc0e59
parentb3a9add86336ebc4101fdecb52caa99bc219466b (diff)
parent72f3eb3153f51d3102fa9e400e3cbf2127beb3c0 (diff)
downloadchef-370aaa0406d85f11da4908f8ea405ea544a2e574.tar.gz
Merge pull request #6904 from chef/cron
Convert parts of cron resource to use properties
-rw-r--r--lib/chef/resource/cron.rb76
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