ncsa / puppet-profile_update_os

NCSA Common Puppet Profiles - configure functionality for upgrading OS packages
0 stars 0 forks source link

Replace empty check with selector expression, and add comments #4

Closed andylytical closed 3 years ago

andylytical commented 3 years ago

Selector expression will simplify this code and ease future maintenance efforts.

$day_of_week = $update_day_of_week ? {
  String[1] => $update_day_of_week,
  default   => profile_update_os::calculate_day_of_week($facts['hostname']),
}

A comment such as, # Use default values for empty parameters, could also be very helpful. https://github.com/ncsa/puppet-profile_update_os/blob/1ddf82231503dd7ad829264925a8b05ac1279201/manifests/yum_upgrade.pp#L120-L133

billglick commented 3 years ago

Selector expressions cannot seem to check if a string or array of strings is empty. So, instead I cleaned up the if/else logic to be a bit easier to read.