diff options
author | Tim Smith <tsmith@chef.io> | 2017-12-14 15:02:16 -0800 |
---|---|---|
committer | Tim Smith <tsmith@chef.io> | 2017-12-15 08:16:28 -0800 |
commit | 3b55abbb30fcb6a8cbb4f58b16023bcfc38a44f3 (patch) | |
tree | 97324b9ef0f8bb39948a0682712da81aade49646 /lib/chef/resource/windows_task.rb | |
parent | 1c487ab5977446746f9b389e429707ec8142b063 (diff) | |
download | chef-3b55abbb30fcb6a8cbb4f58b16023bcfc38a44f3.tar.gz |
Avoid a few initializers in resources by using the DSL we have
Tip of the iceberg here, but it's the low hanging fruit
Signed-off-by: Tim Smith <tsmith@chef.io>
Diffstat (limited to 'lib/chef/resource/windows_task.rb')
-rw-r--r-- | lib/chef/resource/windows_task.rb | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/lib/chef/resource/windows_task.rb b/lib/chef/resource/windows_task.rb index 78076e08e5..a5fead7b13 100644 --- a/lib/chef/resource/windows_task.rb +++ b/lib/chef/resource/windows_task.rb @@ -22,19 +22,13 @@ class Chef class Resource class WindowsTask < Chef::Resource + resource_name: :windows_task provides :windows_task, os: "windows" allowed_actions :create, :delete, :run, :end, :enable, :disable default_action :create - def initialize(name, run_context = nil) - super - @resource_name = :windows_task - @task_name = name - @action = :create - end - - property :task_name, String, regex: [/\A[^\/\:\*\?\<\>\|]+\z/] + property :task_name, String, regex: [/\A[^\/\:\*\?\<\>\|]+\z/], name_property: true property :command, String property :cwd, String property :user, String, default: "SYSTEM" @@ -59,7 +53,7 @@ class Chef property :months, String property :idle_time, Integer property :random_delay, [String, Integer] - property :execution_time_limit, [String, Integer], default: "PT72H" # 72 hours in ISO08601 duration format + property :execution_time_limit, [String, Integer], default: "PT72H" # 72 hours in ISO8601 duration format attr_accessor :exists, :status, :enabled @@ -71,7 +65,7 @@ class Chef end if execution_time_limit - unless execution_time_limit == "PT72H" # don't double convert an iso08601 format duration + unless execution_time_limit == "PT72H" # don't double convert an ISO8601 format duration raise ArgumentError, "Invalid value passed for `execution_time_limit`. Please pass seconds as an Integer (e.g. 60) or a String with numeric values only (e.g. '60')." unless numeric_value_in_string?(execution_time_limit) duration = sec_to_dur(execution_time_limit) execution_time_limit(duration) |