Puppet Function: cd4peadm::bolt_prompt_required_data
- Defined in:
- lib/puppet/functions/cd4peadm/bolt_prompt_required_data.rb
- Function type:
- Ruby 4.x API
Overview
Prompts the user for input using bolt’s prompt function and checks to make sure the returned value is not empty
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/puppet/functions/cd4peadm/bolt_prompt_required_data.rb', line 9 Puppet::Functions.create_function(:'cd4peadm::bolt_prompt_required_data') do dispatch :bolt_prompt_required_data do param 'String[1]', :prompt_text optional_param 'Boolean', :is_sensitive optional_param 'String', :default return_type 'Variant[String, Sensitive]' end def bolt_prompt_required_data(prompt_text, is_sensitive = false, default = '') params = { 'sensitive' => is_sensitive, 'default' => default, } user_input = call_function('prompt', prompt_text, params) unwrapped = is_sensitive ? user_input.unwrap : user_input while(unwrapped.empty?) user_input = call_function('prompt', "An empty string cannot be used.\n#{prompt_text}", params) unwrapped = is_sensitive ? user_input.unwrap : user_input end return user_input end end |