Puppet Function: parse_auto_update_option
- Defined in:
- lib/puppet/parser/functions/parse_auto_update_option.rb
- Function type:
- Ruby 3.x API
Summary
Parse the incoming value to the corresponding integer, if integer is supplied simply return valueOverview
> Note: Valid options for auto_update_option are NotifyOnly|AutoNotify|Scheduled|AutoInstall|2|3|4|5
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/puppet/parser/functions/parse_auto_update_option.rb', line 6 newfunction(:parse_auto_update_option, type: :rvalue, arity: 1, doc: <<-EOS @summary Parse the incoming value to the corresponding integer, if integer is supplied simply return value @return [Integer] option auto_update_option as an integer > *Note:* Valid options for auto_update_option are NotifyOnly|AutoNotify|Scheduled|AutoInstall|2|3|4|5 EOS ) do |args| autoupdate_hash = { 'notifyonly' => 2, 'autonotify' => 3, 'scheduled' => 4, 'autoinstall' => 5 } option = args[0] error_msg = "Valid options for auto_update_option are NotifyOnly|AutoNotify|Scheduled|AutoInstall|2|3|4|5, provided '#{option}'" if option.is_a?(Numeric) || option =~ %r{^\d$} if option.is_a?(String) option = Integer(option) end if option < 2 || option > 5 raise Puppet::ParseError, error_msg end return option end if autoupdate_hash.key?(option.downcase) return autoupdate_hash[option.downcase] end raise Puppet::ParseError, error_msg end |