Class: Puppet::Parameter::PackageOptions

Inherits:
Puppet::Parameter show all
Defined in:
lib/puppet/parameter/package_options.rb

Overview

This specialized Puppet::Parameter handles munging of package options. Package options are passed as an array of key value pairs. Special munging is required as the keys and values needs to be quoted in a safe way.

Constant Summary

Constants included from Util::Docs

Util::Docs::HEADER_LEVELS

Constants included from Util

Util::AbsolutePathPosix, Util::AbsolutePathWindows, Util::DEFAULT_POSIX_MODE, Util::DEFAULT_WINDOWS_MODE

Constants included from Util::POSIX

Util::POSIX::LOCALE_ENV_VARS, Util::POSIX::USER_ENV_VARS

Constants included from Util::SymbolicFileMode

Util::SymbolicFileMode::SetGIDBit, Util::SymbolicFileMode::SetUIDBit, Util::SymbolicFileMode::StickyBit, Util::SymbolicFileMode::SymbolicMode, Util::SymbolicFileMode::SymbolicSpecialToBit

Constants included from Util::Logging

Util::Logging::FILE_AND_LINE, Util::Logging::FILE_NO_LINE, Util::Logging::MM, Util::Logging::NO_FILE_LINE, Util::Logging::SUPPRESS_FILE_LINE

Instance Attribute Summary

Attributes inherited from Puppet::Parameter

#name, #parent, #resource, #sensitive

Attributes included from Util::Docs

#doc, #nodoc

Instance Method Summary collapse

Methods inherited from Puppet::Parameter

aliasvalue, defaultto, desc, doc, #file, #format, format_value_for_display, #initialize, initvars, isnamevar, isnamevar?, #isnamevar?, isrequired, #line, #log, #metaparam?, munge, #munge, newvalues, nodefault, #noop, #path, #pathbuilder, #provider, proxymethods, #remove, #required?, required?, #tags, #to_s, unmunge, #unmunge, #unsafe_validate, validate, #validate, #value, #value=, #version

Methods included from Util::Docs

#desc, #dochook, #doctable, #markdown_definitionlist, #markdown_header, #nodoc?, #pad, scrub

Methods included from Util

absolute_path?, benchmark, chuser, clear_environment, default_env, deterministic_rand, deterministic_rand_int, exit_on_fail, get_env, get_environment, logmethods, merge_environment, path_to_uri, pretty_backtrace, replace_file, safe_posix_fork, set_env, symbolizehash, thinmark, uri_encode, uri_query_encode, uri_to_path, which, withenv, withumask

Methods included from Util::POSIX

#get_posix_field, #gid, #idfield, #methodbyid, #methodbyname, #search_posix_field, #uid

Methods included from Util::SymbolicFileMode

#normalize_symbolic_mode, #symbolic_mode_to_int, #valid_symbolic_mode?

Methods included from Util::MethodHelper

#requiredopts, #set_options, #symbolize_options

Methods included from Util::Logging

#clear_deprecation_warnings, #debug, #deprecation_warning, #format_exception, #get_deprecation_offender, #log_and_raise, #log_deprecations_to_file, #log_exception, #puppet_deprecation_warning, #send_log, setup_facter_logging!, #warn_once

Methods included from Util::Errors

#adderrorcontext, #devfail, #error_context, #exceptwrap, #fail

Constructor Details

This class inherits a constructor from Puppet::Parameter

Instance Method Details

#quote(value) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



28
29
30
# File 'lib/puppet/parameter/package_options.rb', line 28

def quote(value)
  value.include?(' ') ? %Q["#{value.gsub(/"/, '\"')}"] : value
end

#unsafe_munge(values) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/puppet/parameter/package_options.rb', line 8

def unsafe_munge(values)
  values = [values] unless values.is_a? Array

  values.collect do |val|
    case val
    when Hash
      safe_hash = {}
      val.each_pair do |k, v|
        safe_hash[quote(k)] = quote(v)
      end
      safe_hash
    when String
      quote(val)
    else
      fail(_("Expected either a string or hash of options"))
    end
  end
end