From c62209b8e7439431834dacd1f2a0d58599ecf623 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Thu, 22 Jun 2023 16:22:09 +0900 Subject: [PATCH] Validate status of cron resource This makes sure that the supported value is used for the parameters which determine the ensure property of a cron resource type. This also re-implements the validation of age_type parameter using the native data type. Change-Id: Ie3d9c4d3dac3484051be3b9418e833454c0fbd2a --- manifests/cron/purge_deleted.pp | 28 +++++++++----------- spec/classes/heat_cron_purge_deleted_spec.rb | 10 ------- 2 files changed, 12 insertions(+), 26 deletions(-) diff --git a/manifests/cron/purge_deleted.pp b/manifests/cron/purge_deleted.pp index 36253245..a06a4db1 100644 --- a/manifests/cron/purge_deleted.pp +++ b/manifests/cron/purge_deleted.pp @@ -51,24 +51,20 @@ # Defaults to undef. # class heat::cron::purge_deleted ( - $ensure = present, - $minute = 1, - $hour = 0, - $monthday = '*', - $month = '*', - $weekday = '*', - $maxdelay = 0, - $user = $::heat::params::user, - $age = 1, - $age_type = 'days', - $destination = '/var/log/heat/heat-purge_deleted.log', - $batch_size = undef, + Enum['present', 'absent'] $ensure = present, + $minute = 1, + $hour = 0, + $monthday = '*', + $month = '*', + $weekday = '*', + $maxdelay = 0, + $user = $::heat::params::user, + $age = 1, + Enum['days', 'hours', 'minutes', 'seconds'] $age_type = 'days', + $destination = '/var/log/heat/heat-purge_deleted.log', + $batch_size = undef, ) inherits heat::params { - if ! member(['days', 'hours', 'minutes', 'seconds'], $age_type) { - fail('age_type possible values are only days, hours, minutes, or seconds.') - } - if $maxdelay == 0 { $sleep = '' } else { diff --git a/spec/classes/heat_cron_purge_deleted_spec.rb b/spec/classes/heat_cron_purge_deleted_spec.rb index b1561f21..bcdbd6d5 100644 --- a/spec/classes/heat_cron_purge_deleted_spec.rb +++ b/spec/classes/heat_cron_purge_deleted_spec.rb @@ -109,16 +109,6 @@ describe 'heat::cron::purge_deleted' do ) end end - - describe 'when setting a wrong age_type' do - before :each do - params.merge!( - :age_type => 'foobar' - ) - end - - it_raises 'a Puppet::Error', /age_type possible values are only days, hours, minutes, or seconds./ - end end on_supported_os({