puppet 3.7.4-x86-mingw32 → 3.7.5-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of puppet might be problematic. Click here for more details.

Files changed (115) hide show
  1. checksums.yaml +7 -0
  2. data/CONTRIBUTING.md +11 -6
  3. data/ext/build_defaults.yaml +2 -2
  4. data/ext/systemd/puppet.service +1 -0
  5. data/lib/hiera/puppet_function.rb +71 -0
  6. data/lib/puppet.rb +12 -0
  7. data/lib/puppet/application/device.rb +22 -5
  8. data/lib/puppet/daemon.rb +13 -4
  9. data/lib/puppet/defaults.rb +27 -4
  10. data/lib/puppet/environments.rb +1 -1
  11. data/lib/puppet/error.rb +4 -0
  12. data/lib/puppet/functions.rb +118 -65
  13. data/lib/puppet/functions/assert_type.rb +5 -5
  14. data/lib/puppet/functions/each.rb +12 -12
  15. data/lib/puppet/functions/epp.rb +3 -4
  16. data/lib/puppet/functions/filter.rb +12 -12
  17. data/lib/puppet/functions/hiera.rb +29 -0
  18. data/lib/puppet/functions/hiera_array.rb +34 -0
  19. data/lib/puppet/functions/hiera_hash.rb +36 -0
  20. data/lib/puppet/functions/hiera_include.rb +50 -0
  21. data/lib/puppet/functions/inline_epp.rb +2 -3
  22. data/lib/puppet/functions/map.rb +12 -12
  23. data/lib/puppet/functions/reduce.rb +6 -6
  24. data/lib/puppet/functions/scanf.rb +3 -3
  25. data/lib/puppet/functions/slice.rb +10 -9
  26. data/lib/puppet/functions/with.rb +3 -4
  27. data/lib/puppet/graph/simple_graph.rb +5 -5
  28. data/lib/puppet/metatype/manager.rb +1 -1
  29. data/lib/puppet/node/environment.rb +1 -1
  30. data/lib/puppet/parser/ast/arithmetic_operator.rb +1 -1
  31. data/lib/puppet/parser/ast/collexpr.rb +1 -1
  32. data/lib/puppet/parser/compiler.rb +3 -3
  33. data/lib/puppet/parser/functions/create_resources.rb +1 -9
  34. data/lib/puppet/parser/functions/defined.rb +1 -1
  35. data/lib/puppet/parser/functions/hiera.rb +20 -11
  36. data/lib/puppet/parser/functions/hiera_array.rb +23 -13
  37. data/lib/puppet/parser/functions/hiera_hash.rb +25 -15
  38. data/lib/puppet/parser/functions/hiera_include.rb +20 -9
  39. data/lib/puppet/parser/functions/lookup.rb +1 -1
  40. data/lib/puppet/parser/functions/realize.rb +1 -1
  41. data/lib/puppet/parser/functions/scanf.rb +21 -12
  42. data/lib/puppet/parser/parser_factory.rb +2 -2
  43. data/lib/puppet/parser/relationship.rb +1 -1
  44. data/lib/puppet/parser/scope.rb +34 -7
  45. data/lib/puppet/pops.rb +2 -0
  46. data/lib/puppet/pops/binder/lookup.rb +24 -7
  47. data/lib/puppet/pops/binder/producers.rb +2 -2
  48. data/lib/puppet/pops/evaluator/closure.rb +1 -1
  49. data/lib/puppet/pops/evaluator/evaluator_impl.rb +109 -17
  50. data/lib/puppet/pops/evaluator/puppet_proc.rb +69 -0
  51. data/lib/puppet/pops/evaluator/runtime3_converter.rb +175 -0
  52. data/lib/puppet/pops/evaluator/runtime3_support.rb +15 -128
  53. data/lib/puppet/pops/functions/dispatch.rb +21 -17
  54. data/lib/puppet/pops/functions/dispatcher.rb +3 -3
  55. data/lib/puppet/pops/functions/function.rb +46 -14
  56. data/lib/puppet/pops/issues.rb +2 -2
  57. data/lib/puppet/pops/model/model_label_provider.rb +1 -1
  58. data/lib/puppet/pops/parser/egrammar.ra +2 -0
  59. data/lib/puppet/pops/parser/eparser.rb +732 -724
  60. data/lib/puppet/pops/parser/heredoc_support.rb +1 -1
  61. data/lib/puppet/pops/parser/lexer2.rb +20 -22
  62. data/lib/puppet/pops/types/class_loader.rb +1 -1
  63. data/lib/puppet/pops/types/type_calculator.rb +104 -37
  64. data/lib/puppet/pops/types/type_factory.rb +1 -1
  65. data/lib/puppet/pops/types/types.rb +4 -1
  66. data/lib/puppet/pops/types/types_meta.rb +2 -2
  67. data/lib/puppet/pops/validation/checker4_0.rb +5 -3
  68. data/lib/puppet/provider/service/systemd.rb +1 -0
  69. data/lib/puppet/provider/yumrepo/inifile.rb +4 -1
  70. data/lib/puppet/resource.rb +3 -2
  71. data/lib/puppet/resource/catalog.rb +3 -2
  72. data/lib/puppet/resource/type.rb +1 -1
  73. data/lib/puppet/settings/environment_conf.rb +12 -4
  74. data/lib/puppet/type/package.rb +23 -13
  75. data/lib/puppet/util/autoload.rb +7 -7
  76. data/lib/puppet/util/errors.rb +4 -2
  77. data/lib/puppet/util/network_device/config.rb +5 -0
  78. data/lib/puppet/version.rb +1 -1
  79. data/lib/puppetx.rb +2 -2
  80. data/spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/usee/lib/puppet/parser/functions/callee.rb +8 -0
  81. data/spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/usee/lib/puppet/parser/functions/callee_ws.rb +8 -0
  82. data/spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/usee/metadata.json +9 -0
  83. data/spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/user/lib/puppet/functions/user/caller.rb +5 -0
  84. data/spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/user/lib/puppet/functions/user/caller_ws.rb +12 -0
  85. data/spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/user/metadata.json +9 -0
  86. data/spec/integration/parser/environment_spec.rb +47 -0
  87. data/spec/integration/parser/future_compiler_spec.rb +11 -6
  88. data/spec/unit/application/device_spec.rb +52 -14
  89. data/spec/unit/daemon_spec.rb +0 -2
  90. data/spec/unit/environments_spec.rb +2 -2
  91. data/spec/unit/functions/assert_type_spec.rb +4 -25
  92. data/spec/unit/functions/hiera_spec.rb +127 -0
  93. data/spec/unit/functions/with_spec.rb +9 -4
  94. data/spec/unit/functions4_spec.rb +98 -35
  95. data/spec/unit/hiera/backend/puppet_backend_spec.rb +1 -1
  96. data/spec/unit/parser/functions/create_resources_spec.rb +2 -2
  97. data/spec/unit/parser/functions/defined_spec.rb +5 -0
  98. data/spec/unit/parser/functions/lookup_spec.rb +5 -1
  99. data/spec/unit/parser/functions/scanf_spec.rb +30 -0
  100. data/spec/unit/parser/scope_spec.rb +5 -0
  101. data/spec/unit/pops/binder/injector_spec.rb +1 -1
  102. data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +33 -5
  103. data/spec/unit/pops/loaders/loaders_spec.rb +22 -1
  104. data/spec/unit/pops/parser/lexer2_spec.rb +28 -16
  105. data/spec/unit/pops/parser/parse_heredoc_spec.rb +21 -0
  106. data/spec/unit/pops/types/type_calculator_spec.rb +141 -19
  107. data/spec/unit/pops/types/type_factory_spec.rb +2 -2
  108. data/spec/unit/pops/validator/validator_spec.rb +25 -3
  109. data/spec/unit/provider/service/systemd_spec.rb +20 -4
  110. data/spec/unit/provider/user/hpux_spec.rb +1 -1
  111. data/spec/unit/provider/yumrepo/inifile_spec.rb +1 -0
  112. data/spec/unit/settings/environment_conf_spec.rb +12 -1
  113. data/spec/unit/type/package_spec.rb +0 -20
  114. data/spec/unit/util/network_device/config_spec.rb +6 -0
  115. metadata +3422 -3421
@@ -36,10 +36,10 @@ Puppet::Functions.create_function(:scanf) do
36
36
  optional_block_param
37
37
  end
38
38
 
39
- def scanf(data, format, block=nil)
39
+ def scanf(data, format)
40
40
  result = data.scanf(format)
41
- if !block.nil?
42
- result = block.call({}, result)
41
+ if block_given?
42
+ result = yield(result)
43
43
  end
44
44
  result
45
45
  end
@@ -51,15 +51,15 @@ Puppet::Functions.create_function(:slice) do
51
51
  optional_block_param
52
52
  end
53
53
 
54
- def slice_Hash(hash, slice_size, pblock = nil)
55
- result = slice_Common(hash, slice_size, [], pblock)
56
- pblock ? hash : result
54
+ def slice_Hash(hash, slice_size, &pblock)
55
+ result = slice_Common(hash, slice_size, [], block_given? ? pblock : nil)
56
+ block_given? ? hash : result
57
57
  end
58
58
 
59
- def slice_Enumerable(enumerable, slice_size, pblock = nil)
59
+ def slice_Enumerable(enumerable, slice_size, &pblock)
60
60
  enum = asserted_enumerable(enumerable)
61
- result = slice_Common(enum, slice_size, nil, pblock)
62
- pblock ? enumerable : result
61
+ result = slice_Common(enum, slice_size, nil, block_given? ? pblock : nil)
62
+ block_given? ? enumerable : result
63
63
  end
64
64
 
65
65
  def slice_Common(o, slice_size, filler, pblock)
@@ -71,7 +71,7 @@ Puppet::Functions.create_function(:slice) do
71
71
  begin
72
72
  if pblock
73
73
  loop do
74
- pblock.call(nil, enumerator.next)
74
+ pblock.call(enumerator.next)
75
75
  end
76
76
  else
77
77
  loop do
@@ -87,7 +87,7 @@ Puppet::Functions.create_function(:slice) do
87
87
  if a.size < serving_size
88
88
  a = a.dup.fill(filler, a.length...serving_size)
89
89
  end
90
- pblock.call(nil, *a)
90
+ pblock.call(*a)
91
91
  end
92
92
  rescue StopIteration
93
93
  end
@@ -101,7 +101,8 @@ Puppet::Functions.create_function(:slice) do
101
101
 
102
102
  def asserted_slice_serving_size(pblock, slice_size)
103
103
  if pblock
104
- serving_size = pblock.last_captures_rest? ? slice_size : pblock.parameter_count
104
+ arity = pblock.arity
105
+ serving_size = arity < 0 ? slice_size : arity
105
106
  else
106
107
  serving_size = 1
107
108
  end
@@ -12,12 +12,11 @@
12
12
  #
13
13
  Puppet::Functions.create_function(:with) do
14
14
  dispatch :with do
15
- param 'Any', 'arg'
16
- arg_count(0, :default)
17
- required_block_param
15
+ repeated_param 'Any', :arg
16
+ block_param
18
17
  end
19
18
 
20
19
  def with(*args)
21
- args[-1].call({}, *args[0..-2])
20
+ yield(*args)
22
21
  end
23
22
  end
@@ -435,19 +435,19 @@ class Puppet::Graph::SimpleGraph
435
435
  graph = (directed? ? DOT::DOTDigraph : DOT::DOTSubgraph).new(params)
436
436
  edge_klass = directed? ? DOT::DOTDirectedEdge : DOT::DOTEdge
437
437
  vertices.each do |v|
438
- name = v.to_s
438
+ name = v.ref
439
439
  params = {'name' => '"'+name+'"',
440
440
  'fontsize' => fontsize,
441
441
  'label' => name}
442
- v_label = v.to_s
442
+ v_label = v.ref
443
443
  params.merge!(v_label) if v_label and v_label.kind_of? Hash
444
444
  graph << DOT::DOTNode.new(params)
445
445
  end
446
446
  edges.each do |e|
447
- params = {'from' => '"'+ e.source.to_s + '"',
448
- 'to' => '"'+ e.target.to_s + '"',
447
+ params = {'from' => '"'+ e.source.ref + '"',
448
+ 'to' => '"'+ e.target.ref + '"',
449
449
  'fontsize' => fontsize }
450
- e_label = e.to_s
450
+ e_label = e.ref
451
451
  params.merge!(e_label) if e_label and e_label.kind_of? Hash
452
452
  graph << edge_klass.new(params)
453
453
  end
@@ -119,7 +119,7 @@ module Manager
119
119
  klass.providerloader = Puppet::Util::Autoload.new(klass, "puppet/provider/#{klass.name.to_s}")
120
120
 
121
121
  # We have to load everything so that we can figure out the default provider.
122
- klass.providerloader.loadall
122
+ klass.providerloader.loadall Puppet.lookup(:current_environment)
123
123
  klass.providify unless klass.providers.empty?
124
124
 
125
125
  klass
@@ -550,7 +550,7 @@ class Puppet::Node::Environment
550
550
  if file == NO_MANIFEST
551
551
  Puppet::Parser::AST::Hostclass.new('')
552
552
  elsif File.directory?(file)
553
- if Puppet[:parser] == 'future'
553
+ if Puppet.future_parser?
554
554
  parse_results = Puppet::FileSystem::PathPattern.absolute(File.join(file, '**/*.pp')).glob.sort.map do | file_to_parse |
555
555
  parser.file = file_to_parse
556
556
  parser.parse
@@ -70,7 +70,7 @@ class Puppet::Parser::AST
70
70
  end
71
71
 
72
72
  def assert_concatenation_supported
73
- return if Puppet[:parser] == 'future'
73
+ return if Puppet.future_parser?
74
74
  raise ParseError.new("Unsupported Operation: Array concatenation available with '--parser future' setting only.")
75
75
  end
76
76
 
@@ -9,7 +9,7 @@ class CollExpr < AST::Branch
9
9
  attr_accessor :test1, :test2, :oper, :form, :type, :parens
10
10
 
11
11
  def evaluate(scope)
12
- if Puppet[:parser] == 'future'
12
+ if Puppet.future_parser?
13
13
  evaluate4x(scope)
14
14
  else
15
15
  evaluate3x(scope)
@@ -150,7 +150,7 @@ class Puppet::Parser::Compiler
150
150
 
151
151
  # Constructs the overrides for the context
152
152
  def context_overrides()
153
- if Puppet[:parser] == 'future'
153
+ if Puppet.future_parser?
154
154
  require 'puppet/loaders'
155
155
  {
156
156
  :current_environment => environment,
@@ -294,7 +294,7 @@ class Puppet::Parser::Compiler
294
294
  # Answers if Puppet Binder should be active or not, and if it should and is not active, then it is activated.
295
295
  # @return [Boolean] true if the Puppet Binder should be activated
296
296
  def is_binder_active?
297
- should_be_active = Puppet[:binder] || Puppet[:parser] == 'future'
297
+ should_be_active = Puppet[:binder] || Puppet.future_parser?
298
298
  if should_be_active
299
299
  # TODO: this should be in a central place, not just for ParserFactory anymore...
300
300
  Puppet::Parser::ParserFactory.assert_rgen_installed()
@@ -447,7 +447,7 @@ class Puppet::Parser::Compiler
447
447
  # look for resources, because we want to consider those to be
448
448
  # parse errors.
449
449
  def fail_on_unevaluated_resource_collections
450
- if Puppet[:parser] == 'future'
450
+ if Puppet.future_parser?
451
451
  remaining = @collections.collect(&:unresolved_resources).flatten.compact
452
452
  else
453
453
  remaining = @collections.collect(&:resources).flatten.compact
@@ -70,13 +70,5 @@ Puppet::Parser::Functions::newfunction(:create_resources, :arity => -3, :doc =>
70
70
  resource.virtual = true
71
71
  end
72
72
 
73
- begin
74
- resource.safeevaluate(self)
75
- rescue Puppet::ParseError => internal_error
76
- if internal_error.original.nil?
77
- raise internal_error
78
- else
79
- raise internal_error.original
80
- end
81
- end
73
+ resource.safeevaluate(self)
82
74
  end
@@ -52,7 +52,7 @@ Puppet::Parser::Functions::newfunction(:defined, :type => :rvalue, :arity => -2,
52
52
  when Puppet::Resource
53
53
  compiler.findresource(val.type, val.title)
54
54
  else
55
- if Puppet[:parser] == 'future'
55
+ if Puppet.future_parser?
56
56
  case val
57
57
  when Puppet::Pops::Types::PResourceType
58
58
  raise ArgumentError, "The given resource type is a reference to all kind of types" if val.type_name.nil?
@@ -3,20 +3,29 @@ require 'hiera_puppet'
3
3
  module Puppet::Parser::Functions
4
4
  newfunction(:hiera, :type => :rvalue, :arity => -2, :doc => "Performs a
5
5
  standard priority lookup and returns the most specific value for a given key.
6
- The returned value can be data of any type (strings, arrays, or hashes).
6
+ The returned value can be data of any type (strings, arrays, or hashes)
7
7
 
8
- In addition to the required `key` argument, `hiera` accepts two additional
9
- arguments:
8
+ The function can be called in one of three ways:
9
+ 1. Using 1 to 3 arguments where the arguments are:
10
+ 'key' [String] Required
11
+ The key to lookup.
12
+ 'default` [Any] Optional
13
+ A value to return when there's no match for `key`. Optional
14
+ `override` [Any] Optional
15
+ An argument in the third position, providing a data source
16
+ to consult for matching values, even if it would not ordinarily be
17
+ part of the matched hierarchy. If Hiera doesn't find a matching key
18
+ in the named override data source, it will continue to search through the
19
+ rest of the hierarchy.
10
20
 
11
- - a `default` argument in the second position, providing a value to be
12
- returned in the absence of matches to the `key` argument
13
- - an `override` argument in the third position, providing a data source
14
- to consult for matching values, even if it would not ordinarily be
15
- part of the matched hierarchy. If Hiera doesn't find a matching key
16
- in the named override data source, it will continue to search through the
17
- rest of the hierarchy.
21
+ 2. Using a 'key' and an optional 'override' parameter like in #1 but with a block to
22
+ provide the default value. The block is called with one parameter (the key) and
23
+ should return the value. This option can only be used with the 3x future parser or
24
+ from 4.0.0.
18
25
 
19
- More thorough examples of `hiera` are available at:
26
+ 3. Like #1 but with all arguments passed in an array.
27
+
28
+ More thorough examples of `hiera` are available at:
20
29
  <http://docs.puppetlabs.com/hiera/1/puppet.html#hiera-lookup-functions>
21
30
  ") do |*args|
22
31
  key, default, override = HieraPuppet.parse_args(args)
@@ -1,23 +1,33 @@
1
1
  require 'hiera_puppet'
2
2
 
3
3
  module Puppet::Parser::Functions
4
- newfunction(:hiera_array, :type => :rvalue, :arity => -2,:doc => "Returns all
4
+ newfunction(:hiera_array, :type => :rvalue, :arity => -2,:doc => "Returns all
5
5
  matches throughout the hierarchy --- not just the first match --- as a flattened array of unique values.
6
6
  If any of the matched values are arrays, they're flattened and included in the results.
7
-
8
- In addition to the required `key` argument, `hiera_array` accepts two additional
9
- arguments:
10
-
11
- - a `default` argument in the second position, providing a string or array to be returned
12
- in the absence of matches to the `key` argument
13
- - an `override` argument in the third position, providing a data source to consult for
14
- matching values, even if it would not ordinarily be part of the matched hierarchy.
15
- If Hiera doesn't find a matching key in the named override data source, it will
16
- continue to search through the rest of the hierarchy.
17
-
7
+
8
+ The function can be called in one of three ways:
9
+ 1. Using 1 to 3 arguments where the arguments are:
10
+ 'key' [String] Required
11
+ The key to lookup.
12
+ 'default` [Any] Optional
13
+ A value to return when there's no match for `key`. Optional
14
+ `override` [Any] Optional
15
+ An argument in the third position, providing a data source
16
+ to consult for matching values, even if it would not ordinarily be
17
+ part of the matched hierarchy. If Hiera doesn't find a matching key
18
+ in the named override data source, it will continue to search through the
19
+ rest of the hierarchy.
20
+
21
+ 2. Using a 'key' and an optional 'override' parameter like in #1 but with a block to
22
+ provide the default value. The block is called with one parameter (the key) and
23
+ should return the value. This option can only be used with the 3x future parser or
24
+ from 4.0.0.
25
+
26
+ 3. Like #1 but with all arguments passed in an array.
27
+
18
28
  If any matched value is a hash, puppet will raise a type mismatch error.
19
29
 
20
- More thorough examples of `hiera` are available at:
30
+ More thorough examples of `hiera` are available at:
21
31
  <http://docs.puppetlabs.com/hiera/1/puppet.html#hiera-lookup-functions>
22
32
  ") do |*args|
23
33
  key, default, override = HieraPuppet.parse_args(args)
@@ -1,25 +1,35 @@
1
1
  require 'hiera_puppet'
2
2
 
3
3
  module Puppet::Parser::Functions
4
- newfunction(:hiera_hash, :type => :rvalue, :arity => -2, :doc =>
5
- "Returns a merged hash of matches from throughout the hierarchy. In cases where two or
6
- more hashes share keys, the hierarchy order determines which key/value pair will be
4
+ newfunction(:hiera_hash, :type => :rvalue, :arity => -2, :doc =>
5
+ "Returns a merged hash of matches from throughout the hierarchy. In cases where two or
6
+ more hashes share keys, the hierarchy order determines which key/value pair will be
7
7
  used in the returned hash, with the pair in the highest priority data source winning.
8
-
9
- In addition to the required `key` argument, `hiera_hash` accepts two additional
10
- arguments:
11
-
12
- - a `default` argument in the second position, providing a hash to be returned in the
13
- absence of any matches for the `key` argument
14
- - an `override` argument in the third position, providing a data source to insert at
15
- the top of the hierarchy, even if it would not ordinarily match during a Hiera data
16
- source lookup. If Hiera doesn't find a match in the named override data source, it will
17
- continue to search through the rest of the hierarchy.
18
-
8
+
9
+ The function can be called in one of three ways:
10
+ 1. Using 1 to 3 arguments where the arguments are:
11
+ 'key' [String] Required
12
+ The key to lookup.
13
+ 'default` [Any] Optional
14
+ A value to return when there's no match for `key`. Optional
15
+ `override` [Any] Optional
16
+ An argument in the third position, providing a data source
17
+ to consult for matching values, even if it would not ordinarily be
18
+ part of the matched hierarchy. If Hiera doesn't find a matching key
19
+ in the named override data source, it will continue to search through the
20
+ rest of the hierarchy.
21
+
22
+ 2. Using a 'key' and an optional 'override' parameter like in #1 but with a block to
23
+ provide the default value. The block is called with one parameter (the key) and
24
+ should return the value. This option can only be used with the 3x future parser or
25
+ from 4.0.0.
26
+
27
+ 3. Like #1 but with all arguments passed in an array.
28
+
19
29
  `hiera_hash` expects that all values returned will be hashes. If any of the values
20
30
  found in the data sources are strings or arrays, puppet will raise a type mismatch error.
21
31
 
22
- More thorough examples of `hiera_hash` are available at:
32
+ More thorough examples of `hiera_hash` are available at:
23
33
  <http://docs.puppetlabs.com/hiera/1/puppet.html#hiera-lookup-functions>
24
34
  ") do |*args|
25
35
  key, default, override = HieraPuppet.parse_args(args)
@@ -19,15 +19,26 @@ module Puppet::Parser::Functions
19
19
  - apache
20
20
  - apache::passenger
21
21
 
22
- In addition to the required `key` argument, `hiera_include` accepts two additional
23
- arguments:
24
-
25
- - a `default` argument in the second position, providing an array to be returned
26
- in the absence of matches to the `key` argument
27
- - an `override` argument in the third position, providing a data source to consult
28
- for matching values, even if it would not ordinarily be part of the matched hierarchy.
29
- If Hiera doesn't find a matching key in the named override data source, it will continue
30
- to search through the rest of the hierarchy.
22
+ The function can be called in one of three ways:
23
+ 1. Using 1 to 3 arguments where the arguments are:
24
+ 'key' [String] Required
25
+ The key to lookup.
26
+ 'default` [Any] Optional
27
+ A value to return when there's no match for `key`. Optional
28
+ `override` [Any] Optional
29
+ An argument in the third position, providing a data source
30
+ to consult for matching values, even if it would not ordinarily be
31
+ part of the matched hierarchy. If Hiera doesn't find a matching key
32
+ in the named override data source, it will continue to search through the
33
+ rest of the hierarchy.
34
+
35
+ 2. Using a 'key' and an optional 'override' parameter like in #1 but with a block to
36
+ provide the default value. The block is called with one parameter (the key) and
37
+ should return the array to be used in the subsequent call to include.
38
+ This option can only be used with the 3x future parser or
39
+ from 4.0.0.
40
+
41
+ 3. Like #1 but with all arguments passed in an array.
31
42
 
32
43
  More thorough examples of `hiera_include` are available at:
33
44
  <http://docs.puppetlabs.com/hiera/1/puppet.html#hiera-lookup-functions>
@@ -137,7 +137,7 @@ If you want to make lookup return undef when no value was found instead of raisi
137
137
 
138
138
  ENDHEREDOC
139
139
 
140
- unless Puppet[:binder] || Puppet[:parser] == 'future'
140
+ unless Puppet[:binder] || Puppet.future_parser?
141
141
  raise Puppet::ParseError, "The lookup function is only available with settings --binder true, or --parser future"
142
142
  end
143
143
  Puppet::Pops::Binder::Lookup.lookup(self, args)
@@ -8,7 +8,7 @@ Puppet::Parser::Functions::newfunction(:realize, :arity => -2, :doc => "Make a v
8
8
  reference; e.g.: `realize User[luke]`." ) do |vals|
9
9
 
10
10
  vals = [vals] unless vals.is_a?(Array)
11
- if Puppet[:parser] == 'future'
11
+ if Puppet.future_parser?
12
12
  coll = Puppet::Pops::Evaluator::Collectors::FixedSetCollector.new(self, vals.flatten)
13
13
  else
14
14
  coll = Puppet::Parser::Collector.new(self, :nomatter, nil, nil, :virtual)
@@ -1,3 +1,5 @@
1
+ require 'scanf'
2
+
1
3
  Puppet::Parser::Functions::newfunction(
2
4
  :scanf,
3
5
  :type => :rvalue,
@@ -7,17 +9,22 @@ Scans a string and returns an array of one or more converted values as directed
7
9
  See the documenation of Ruby's String::scanf method for details about the supported formats (which
8
10
  are similar but not identical to the formats used in Puppet's `sprintf` function.
9
11
 
10
- This function takes two mandatory arguments: the first is the String to convert, and the second
11
- the format String. A parameterized block may optionally be given, which is called with the result
12
- that is produced by scanf if no block is present, the result of the block is then returned by
13
- the function.
12
+ This function takes two mandatory arguments: the first is the String to
13
+ convert, and the second the format String. The result of the scan is an Array,
14
+ with each sucessfully scanned and transformed value.args The scanning stops if
15
+ a scan is unsuccesful and the scanned result up to that point is returned. If
16
+ there was no succesful scan at all, the result is an empty Array.
17
+
18
+ scanf("42", "%i")[0] == 42
19
+
14
20
 
15
- The result of the scan is an Array, with each sucessfully scanned and transformed value.args The scanning
16
- stops if a scan is unsuccesful and the scanned result up to that point is returned. If there was no
17
- succesful scan at all, the result is an empty Array. The optional code block is typically used to
18
- assert that the scan was succesful, and either produce the same input, or perform unwrapping of
19
- the result
21
+ When used with the future parser, an optional parameterized block may be given.
22
+ The block is called with the result that is produced by scanf if no block is
23
+ present, the result of the block is then returned by the function.
20
24
 
25
+ The optional code block is typically used to assert that the scan was
26
+ succesful, and either produce the same input, or perform unwrapping of
27
+ the result:
21
28
 
22
29
  "42".scanf("%i")
23
30
  "42".scanf("%i") |$x| {
@@ -27,9 +34,11 @@ the result
27
34
  $x[0]
28
35
  }
29
36
 
30
- - since 3.7.4
31
- - note requires `parser = future`
37
+ - since 3.7.4 with `parser = future`
38
+ - since 3.7.5 with classic parser
32
39
  DOC
33
40
  ) do |args|
34
- function_fail(["scanf() is only available when parser/evaluator future is in effect"])
41
+ data = args[0]
42
+ format = args[1]
43
+ result = data.scanf(format)
35
44
  end