diff options
author | Davin Taddeo <davin@chef.io> | 2020-06-03 14:22:01 -0400 |
---|---|---|
committer | Davin Taddeo <davin@chef.io> | 2020-06-03 14:22:01 -0400 |
commit | c5729693d4c1eda74cfe8728893cb43b5c4820a1 (patch) | |
tree | 5cc83e969b2ca3eff5e3d07d2e78eb1bad5ab7d4 /lib | |
parent | 921c1657abca0fa5661f91314b155c8d97ed954a (diff) | |
download | chef-c5729693d4c1eda74cfe8728893cb43b5c4820a1.tar.gz |
put the logic into the default parameter of the property definition, rather than in the code for the action.
Signed-off-by: Davin Taddeo <davin@chef.io>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/chef/resource/chef_client_scheduled_task.rb | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/lib/chef/resource/chef_client_scheduled_task.rb b/lib/chef/resource/chef_client_scheduled_task.rb index 3f1e9dd9d9..cdbf6420ac 100644 --- a/lib/chef/resource/chef_client_scheduled_task.rb +++ b/lib/chef/resource/chef_client_scheduled_task.rb @@ -82,7 +82,8 @@ class Chef coerce: proc { |x| Integer(x) }, callbacks: { "should be a positive number" => proc { |v| v > 0 } }, description: "Numeric value to go with the scheduled task frequency", - default: 30 + default: lazy { frequency == "minute" ? 30 : 1 }, + default_description: "30 if frequency is 'minute', 1 otherwise" property :accept_chef_license, [true, false], description: "Accept the Chef Online Master License and Services Agreement. See <https://www.chef.io/online-master-agreement/>", @@ -140,21 +141,13 @@ class Chef # According to https://docs.microsoft.com/en-us/windows/desktop/taskschd/schtasks, # the :once, :onstart, :onlogon, and :onidle schedules don't accept schedule modifiers - frequency_mod = if new_resource.frequency == "minute" && new_resource.frequency_modifier == 30 - 30 - elsif new_resource.frequency_modifier != 30 - new_resource.frequency_modifier - else - 1 - end - windows_task new_resource.task_name do run_level :highest command full_command user new_resource.user password new_resource.password frequency new_resource.frequency.to_sym - frequency_modifier frequency_mod if frequency_supports_frequency_modifier? + frequency_modifier new_resource.frequency_modifier if frequency_supports_frequency_modifier? start_time new_resource.start_time start_day new_resource.start_date unless new_resource.start_date.nil? random_delay new_resource.splay if frequency_supports_random_delay? |