puppet 4.7.1-universal-darwin → 4.8.0-universal-darwin

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 (276) hide show
  1. data/Gemfile +0 -3
  2. data/MAINTAINERS +76 -0
  3. data/README.md +0 -6
  4. data/Rakefile +2 -2
  5. data/lib/puppet/agent.rb +3 -3
  6. data/lib/puppet/application/apply.rb +1 -1
  7. data/lib/puppet/configurer.rb +2 -2
  8. data/lib/puppet/data_providers.rb +1 -0
  9. data/lib/puppet/data_providers/data_adapter.rb +1 -0
  10. data/lib/puppet/data_providers/data_function_support.rb +1 -0
  11. data/lib/puppet/data_providers/function_env_data_provider.rb +1 -0
  12. data/lib/puppet/data_providers/function_module_data_provider.rb +1 -0
  13. data/lib/puppet/data_providers/hiera_config.rb +1 -0
  14. data/lib/puppet/data_providers/hiera_env_data_provider.rb +1 -0
  15. data/lib/puppet/data_providers/hiera_interpolate.rb +1 -0
  16. data/lib/puppet/data_providers/hiera_module_data_provider.rb +1 -0
  17. data/lib/puppet/data_providers/hiera_support.rb +1 -2
  18. data/lib/puppet/data_providers/json_data_provider_factory.rb +2 -0
  19. data/lib/puppet/data_providers/yaml_data_provider_factory.rb +2 -0
  20. data/lib/puppet/defaults.rb +20 -1
  21. data/lib/puppet/environments.rb +5 -2
  22. data/lib/puppet/face/catalog.rb +1 -1
  23. data/lib/puppet/face/epp.rb +57 -11
  24. data/lib/puppet/face/module/install.rb +6 -6
  25. data/lib/puppet/functions.rb +23 -24
  26. data/lib/puppet/functions/alert.rb +14 -0
  27. data/lib/puppet/functions/binary_file.rb +25 -0
  28. data/lib/puppet/functions/break.rb +22 -0
  29. data/lib/puppet/functions/contain.rb +33 -0
  30. data/lib/puppet/functions/crit.rb +14 -0
  31. data/lib/puppet/functions/debug.rb +14 -0
  32. data/lib/puppet/functions/emerg.rb +14 -0
  33. data/lib/puppet/functions/epp.rb +1 -1
  34. data/lib/puppet/functions/err.rb +14 -0
  35. data/lib/puppet/functions/find_file.rb +31 -0
  36. data/lib/puppet/functions/include.rb +21 -0
  37. data/lib/puppet/functions/info.rb +14 -0
  38. data/lib/puppet/functions/new.rb +1 -1
  39. data/lib/puppet/functions/next.rb +23 -0
  40. data/lib/puppet/functions/notice.rb +14 -0
  41. data/lib/puppet/functions/regsubst.rb +12 -16
  42. data/lib/puppet/functions/require.rb +37 -0
  43. data/lib/puppet/functions/return.rb +22 -0
  44. data/lib/puppet/functions/strftime.rb +35 -0
  45. data/lib/puppet/functions/warning.rb +14 -0
  46. data/lib/puppet/generate/models/type/type.rb +4 -0
  47. data/lib/puppet/generate/templates/type/pcore.erb +2 -1
  48. data/lib/puppet/indirector/face.rb +6 -1
  49. data/lib/puppet/network/http/error.rb +2 -2
  50. data/lib/puppet/network/http/handler.rb +2 -2
  51. data/lib/puppet/node/environment.rb +11 -0
  52. data/lib/puppet/parser/ast.rb +5 -0
  53. data/lib/puppet/parser/ast/pops_bridge.rb +17 -4
  54. data/lib/puppet/parser/compiler.rb +29 -1
  55. data/lib/puppet/parser/functions.rb +6 -0
  56. data/lib/puppet/parser/functions/assert_type.rb +1 -1
  57. data/lib/puppet/parser/functions/binary_file.rb +24 -0
  58. data/lib/puppet/parser/functions/break.rb +39 -0
  59. data/lib/puppet/parser/functions/contain.rb +7 -15
  60. data/lib/puppet/parser/functions/defined.rb +2 -2
  61. data/lib/puppet/parser/functions/dig.rb +1 -1
  62. data/lib/puppet/parser/functions/each.rb +1 -1
  63. data/lib/puppet/parser/functions/epp.rb +2 -2
  64. data/lib/puppet/parser/functions/filter.rb +1 -1
  65. data/lib/puppet/parser/functions/find_file.rb +28 -0
  66. data/lib/puppet/parser/functions/hiera.rb +4 -4
  67. data/lib/puppet/parser/functions/hiera_array.rb +1 -1
  68. data/lib/puppet/parser/functions/hiera_hash.rb +1 -1
  69. data/lib/puppet/parser/functions/hiera_include.rb +1 -1
  70. data/lib/puppet/parser/functions/include.rb +4 -8
  71. data/lib/puppet/parser/functions/inline_epp.rb +1 -1
  72. data/lib/puppet/parser/functions/lest.rb +1 -1
  73. data/lib/puppet/parser/functions/lookup.rb +4 -2
  74. data/lib/puppet/parser/functions/map.rb +1 -1
  75. data/lib/puppet/parser/functions/match.rb +1 -1
  76. data/lib/puppet/parser/functions/new.rb +414 -18
  77. data/lib/puppet/parser/functions/next.rb +38 -0
  78. data/lib/puppet/parser/functions/reduce.rb +1 -1
  79. data/lib/puppet/parser/functions/regsubst.rb +4 -2
  80. data/lib/puppet/parser/functions/require.rb +4 -27
  81. data/lib/puppet/parser/functions/return.rb +71 -0
  82. data/lib/puppet/parser/functions/reverse_each.rb +1 -1
  83. data/lib/puppet/parser/functions/scanf.rb +13 -8
  84. data/lib/puppet/parser/functions/slice.rb +1 -1
  85. data/lib/puppet/parser/functions/split.rb +1 -1
  86. data/lib/puppet/parser/functions/step.rb +1 -1
  87. data/lib/puppet/parser/functions/strftime.rb +185 -0
  88. data/lib/puppet/parser/functions/then.rb +1 -1
  89. data/lib/puppet/parser/functions/type.rb +1 -1
  90. data/lib/puppet/parser/functions/with.rb +3 -3
  91. data/lib/puppet/parser/resource.rb +8 -5
  92. data/lib/puppet/parser/scope.rb +1 -1
  93. data/lib/puppet/plugins/configuration.rb +8 -0
  94. data/lib/puppet/plugins/data_providers.rb +1 -0
  95. data/lib/puppet/plugins/data_providers/data_provider.rb +7 -28
  96. data/lib/puppet/plugins/data_providers/registry.rb +1 -0
  97. data/lib/puppet/pops.rb +4 -0
  98. data/lib/puppet/pops/evaluator/access_operator.rb +36 -5
  99. data/lib/puppet/pops/evaluator/closure.rb +81 -12
  100. data/lib/puppet/pops/evaluator/compare_operator.rb +24 -1
  101. data/lib/puppet/pops/evaluator/evaluator_impl.rb +29 -5
  102. data/lib/puppet/pops/evaluator/json_strict_literal_evaluator.rb +1 -1
  103. data/lib/puppet/pops/evaluator/runtime3_converter.rb +53 -62
  104. data/lib/puppet/pops/evaluator/runtime3_support.rb +15 -6
  105. data/lib/puppet/pops/functions/dispatch.rb +9 -2
  106. data/lib/puppet/pops/functions/dispatcher.rb +3 -1
  107. data/lib/puppet/pops/functions/function.rb +19 -2
  108. data/lib/puppet/pops/issues.rb +9 -0
  109. data/lib/puppet/pops/label_provider.rb +2 -2
  110. data/lib/puppet/pops/loader/loader.rb +17 -0
  111. data/lib/puppet/pops/loader/static_loader.rb +0 -41
  112. data/lib/puppet/pops/lookup.rb +12 -0
  113. data/lib/puppet/pops/lookup/context.rb +86 -0
  114. data/lib/puppet/pops/lookup/explainer.rb +46 -6
  115. data/lib/puppet/pops/lookup/invocation.rb +19 -0
  116. data/lib/puppet/pops/lookup/sub_lookup.rb +1 -1
  117. data/lib/puppet/pops/model/factory.rb +20 -8
  118. data/lib/puppet/pops/model/model_label_provider.rb +3 -0
  119. data/lib/puppet/pops/model/model_meta.rb +2 -0
  120. data/lib/puppet/pops/model/model_tree_dumper.rb +14 -0
  121. data/lib/puppet/pops/parser/egrammar.ra +11 -6
  122. data/lib/puppet/pops/parser/eparser.rb +1112 -1086
  123. data/lib/puppet/pops/parser/heredoc_support.rb +1 -2
  124. data/lib/puppet/pops/pcore.rb +1 -0
  125. data/lib/puppet/pops/puppet_stack.rb +3 -3
  126. data/lib/puppet/pops/resource/param.rb +5 -1
  127. data/lib/puppet/pops/resource/resource_type_impl.rb +8 -4
  128. data/lib/puppet/pops/resource/resource_type_set.pcore +1 -0
  129. data/lib/puppet/pops/serialization/abstract_reader.rb +19 -2
  130. data/lib/puppet/pops/serialization/abstract_writer.rb +16 -3
  131. data/lib/puppet/pops/serialization/deserializer.rb +5 -1
  132. data/lib/puppet/pops/serialization/extension.rb +2 -0
  133. data/lib/puppet/pops/serialization/json.rb +76 -26
  134. data/lib/puppet/pops/serialization/serializer.rb +5 -1
  135. data/lib/puppet/pops/serialization/time_factory.rb +2 -1
  136. data/lib/puppet/pops/time/timespan.rb +718 -0
  137. data/lib/puppet/pops/time/timestamp.rb +148 -0
  138. data/lib/puppet/pops/types/p_binary_type.rb +220 -0
  139. data/lib/puppet/pops/types/p_object_type.rb +12 -6
  140. data/lib/puppet/pops/types/p_sensitive_type.rb +5 -1
  141. data/lib/puppet/pops/types/p_timespan_type.rb +141 -0
  142. data/lib/puppet/pops/types/p_timestamp_type.rb +69 -0
  143. data/lib/puppet/pops/types/string_converter.rb +62 -0
  144. data/lib/puppet/pops/types/type_asserter.rb +1 -1
  145. data/lib/puppet/pops/types/type_calculator.rb +17 -3
  146. data/lib/puppet/pops/types/type_factory.rb +35 -1
  147. data/lib/puppet/pops/types/type_formatter.rb +64 -11
  148. data/lib/puppet/pops/types/type_mismatch_describer.rb +110 -61
  149. data/lib/puppet/pops/types/type_parser.rb +18 -4
  150. data/lib/puppet/pops/types/types.rb +98 -63
  151. data/lib/puppet/pops/validation.rb +9 -1
  152. data/lib/puppet/pops/validation/checker4_0.rb +7 -0
  153. data/lib/puppet/property.rb +1 -1
  154. data/lib/puppet/provider.rb +3 -6
  155. data/lib/puppet/provider/mcx/mcxcontent.rb +1 -1
  156. data/lib/puppet/provider/mount/parsed.rb +18 -4
  157. data/lib/puppet/provider/nameservice/directoryservice.rb +15 -7
  158. data/lib/puppet/provider/package/gem.rb +6 -1
  159. data/lib/puppet/provider/package/pip.rb +0 -1
  160. data/lib/puppet/provider/package/pkg.rb +5 -1
  161. data/lib/puppet/provider/package/pkgng.rb +1 -1
  162. data/lib/puppet/provider/package/yum.rb +10 -0
  163. data/lib/puppet/provider/service/launchd.rb +1 -0
  164. data/lib/puppet/provider/user/directoryservice.rb +6 -6
  165. data/lib/puppet/provider/yumrepo/inifile.rb +1 -1
  166. data/lib/puppet/provider/zpool/zpool.rb +1 -1
  167. data/lib/puppet/resource.rb +54 -12
  168. data/lib/puppet/resource/capability_finder.rb +15 -9
  169. data/lib/puppet/resource/catalog.rb +25 -6
  170. data/lib/puppet/resource/type.rb +3 -1
  171. data/lib/puppet/settings.rb +1 -1
  172. data/lib/puppet/settings/environment_conf.rb +12 -4
  173. data/lib/puppet/syntax_checkers/base64.rb +41 -0
  174. data/lib/puppet/syntax_checkers/json.rb +0 -2
  175. data/lib/puppet/transaction.rb +6 -0
  176. data/lib/puppet/transaction/additional_resource_generator.rb +5 -0
  177. data/lib/puppet/transaction/report.rb +7 -2
  178. data/lib/puppet/type.rb +2 -1
  179. data/lib/puppet/type/file/checksum.rb +1 -0
  180. data/lib/puppet/type/file/content.rb +4 -4
  181. data/lib/puppet/type/mount.rb +44 -0
  182. data/lib/puppet/type/ssh_authorized_key.rb +1 -1
  183. data/lib/puppet/type/tidy.rb +3 -0
  184. data/lib/puppet/type/user.rb +12 -6
  185. data/lib/puppet/util/log.rb +25 -0
  186. data/lib/puppet/util/plist.rb +8 -3
  187. data/lib/puppet/version.rb +1 -1
  188. data/lib/puppet_x.rb +7 -1
  189. data/spec/integration/application/apply_spec.rb +118 -0
  190. data/spec/integration/parser/compiler_spec.rb +28 -0
  191. data/spec/integration/parser/pcore_resource_spec.rb +40 -3
  192. data/spec/integration/provider/mount_spec.rb +2 -1
  193. data/spec/integration/util/windows/principal_spec.rb +2 -2
  194. data/spec/integration/util/windows/registry_spec.rb +4 -4
  195. data/spec/lib/puppet_spec/compiler.rb +5 -1
  196. data/spec/lib/puppet_spec/unindent.rb +5 -0
  197. data/spec/shared_contexts/types_setup.rb +6 -0
  198. data/spec/shared_examples/rhel_package_provider.rb +16 -0
  199. data/spec/spec_helper.rb +1 -0
  200. data/spec/unit/agent_spec.rb +11 -0
  201. data/spec/unit/application/lookup_spec.rb +94 -3
  202. data/spec/unit/capability_spec.rb +22 -0
  203. data/spec/unit/configurer_spec.rb +8 -0
  204. data/spec/unit/face/epp_face_spec.rb +22 -3
  205. data/spec/unit/functions/assert_type_spec.rb +3 -3
  206. data/spec/unit/functions/binary_file_spec.rb +46 -0
  207. data/spec/unit/functions/break_spec.rb +89 -0
  208. data/spec/unit/{parser/functions → functions}/contain_spec.rb +68 -3
  209. data/spec/unit/functions/find_file_spec.rb +69 -0
  210. data/spec/unit/functions/include_spec.rb +175 -0
  211. data/spec/unit/functions/logging_spec.rb +54 -0
  212. data/spec/unit/functions/lookup_spec.rb +3 -3
  213. data/spec/unit/functions/new_spec.rb +105 -5
  214. data/spec/unit/functions/next_spec.rb +93 -0
  215. data/spec/unit/functions/require_spec.rb +83 -0
  216. data/spec/unit/functions/return_spec.rb +105 -0
  217. data/spec/unit/{parser/functions → functions}/shared.rb +14 -11
  218. data/spec/unit/functions/strftime_spec.rb +152 -0
  219. data/spec/unit/functions4_spec.rb +22 -0
  220. data/spec/unit/indirector/face_spec.rb +10 -2
  221. data/spec/unit/network/http/error_spec.rb +1 -2
  222. data/spec/unit/network/http/handler_spec.rb +6 -5
  223. data/spec/unit/parser/functions/hiera_array_spec.rb +1 -1
  224. data/spec/unit/parser/functions/hiera_hash_spec.rb +1 -1
  225. data/spec/unit/parser/functions/hiera_include_spec.rb +1 -1
  226. data/spec/unit/parser/functions/hiera_spec.rb +1 -1
  227. data/spec/unit/parser/functions/lookup_spec.rb +1 -1
  228. data/spec/unit/parser/functions/regsubst_spec.rb +1 -1
  229. data/spec/unit/parser/functions/split_spec.rb +1 -1
  230. data/spec/unit/pops/evaluator/access_ops_spec.rb +81 -1
  231. data/spec/unit/pops/evaluator/arithmetic_ops_spec.rb +170 -0
  232. data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +29 -4
  233. data/spec/unit/pops/evaluator/runtime3_converter_spec.rb +112 -4
  234. data/spec/unit/pops/loaders/dependency_loader_spec.rb +12 -0
  235. data/spec/unit/pops/loaders/static_loader_spec.rb +0 -26
  236. data/spec/unit/pops/lookup/context_spec.rb +149 -0
  237. data/spec/unit/pops/parser/parse_functions_spec.rb +19 -0
  238. data/spec/unit/pops/parser/parse_lambda_spec.rb +19 -0
  239. data/spec/unit/pops/puppet_stack_spec.rb +1 -1
  240. data/spec/unit/pops/resource/resource_type_impl_spec.rb +74 -0
  241. data/spec/unit/pops/serialization/packer_spec.rb +34 -14
  242. data/spec/unit/pops/serialization/serialization_spec.rb +67 -5
  243. data/spec/unit/pops/time/timespan_spec.rb +121 -0
  244. data/spec/unit/pops/types/p_binary_type_spec.rb +243 -0
  245. data/spec/unit/pops/types/p_object_type_spec.rb +7 -7
  246. data/spec/unit/pops/types/p_sensitive_type_spec.rb +1 -1
  247. data/spec/unit/pops/types/p_timespan_type_spec.rb +273 -0
  248. data/spec/unit/pops/types/p_timestamp_type_spec.rb +311 -0
  249. data/spec/unit/pops/types/p_type_set_type_spec.rb +13 -13
  250. data/spec/unit/pops/types/ruby_generator_spec.rb +12 -12
  251. data/spec/unit/pops/types/string_converter_spec.rb +89 -0
  252. data/spec/unit/pops/types/type_asserter_spec.rb +3 -3
  253. data/spec/unit/pops/types/type_calculator_spec.rb +113 -5
  254. data/spec/unit/pops/types/type_formatter_spec.rb +40 -0
  255. data/spec/unit/pops/types/type_mismatch_describer_spec.rb +49 -38
  256. data/spec/unit/pops/types/type_parser_spec.rb +87 -4
  257. data/spec/unit/pops/types/types_spec.rb +1 -1
  258. data/spec/unit/pops/validator/validator_spec.rb +23 -0
  259. data/spec/unit/provider/mount/parsed_spec.rb +47 -29
  260. data/spec/unit/provider/package/pkg_spec.rb +109 -99
  261. data/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +1 -0
  262. data/spec/unit/provider/user/aix_spec.rb +1 -1
  263. data/spec/unit/provider/user/directoryservice_spec.rb +101 -30
  264. data/spec/unit/resource/capability_finder_spec.rb +29 -7
  265. data/spec/unit/resource/catalog_spec.rb +127 -0
  266. data/spec/unit/ssl/certificate_request_spec.rb +1 -1
  267. data/spec/unit/transaction/additional_resource_generator_spec.rb +30 -0
  268. data/spec/unit/transaction/persistence_spec.rb +1 -6
  269. data/spec/unit/transaction/report_spec.rb +23 -0
  270. data/spec/unit/transaction_spec.rb +38 -0
  271. data/spec/unit/type/mount_spec.rb +5 -0
  272. data/spec/unit/util/plist_spec.rb +14 -2
  273. metadata +71 -12
  274. data/spec/integration/parser/functions/require_spec.rb +0 -43
  275. data/spec/unit/parser/functions/include_spec.rb +0 -55
  276. data/spec/unit/parser/functions/require_spec.rb +0 -68
@@ -21,7 +21,7 @@ Puppet::Face.define(:module, '1.0.0') do
21
21
 
22
22
  $ puppet module install puppetlabs-vcsrepo
23
23
  Preparing to install into /etc/puppetlabs/code/modules ...
24
- Downloading from https://forgeapi.puppetlabs.com ...
24
+ Downloading from https://forgeapi.puppet.com ...
25
25
  Installing -- do not interrupt ...
26
26
  /etc/puppetlabs/code/modules
27
27
  └── puppetlabs-vcsrepo (v0.0.4)
@@ -30,7 +30,7 @@ Puppet::Face.define(:module, '1.0.0') do
30
30
 
31
31
  $ puppet module install puppetlabs-vcsrepo --environment development
32
32
  Preparing to install into /etc/puppetlabs/code/environments/development/modules ...
33
- Downloading from https://forgeapi.puppetlabs.com ...
33
+ Downloading from https://forgeapi.puppet.com ...
34
34
  Installing -- do not interrupt ...
35
35
  /etc/puppetlabs/code/environments/development/modules
36
36
  └── puppetlabs-vcsrepo (v0.0.4)
@@ -39,7 +39,7 @@ Puppet::Face.define(:module, '1.0.0') do
39
39
 
40
40
  $ puppet module install puppetlabs-vcsrepo -v 0.0.4
41
41
  Preparing to install into /etc/puppetlabs/modules ...
42
- Downloading from https://forgeapi.puppetlabs.com ...
42
+ Downloading from https://forgeapi.puppet.com ...
43
43
  Installing -- do not interrupt ...
44
44
  /etc/puppetlabs/code/modules
45
45
  └── puppetlabs-vcsrepo (v0.0.4)
@@ -48,7 +48,7 @@ Puppet::Face.define(:module, '1.0.0') do
48
48
 
49
49
  $ puppet module install puppetlabs-vcsrepo --target-dir=/opt/puppetlabs/puppet/modules
50
50
  Preparing to install into /opt/puppetlabs/puppet/modules ...
51
- Downloading from https://forgeapi.puppetlabs.com ...
51
+ Downloading from https://forgeapi.puppet.com ...
52
52
  Installing -- do not interrupt ...
53
53
  /opt/puppetlabs/puppet/modules
54
54
  └── puppetlabs-vcsrepo (v0.0.4)
@@ -57,7 +57,7 @@ Puppet::Face.define(:module, '1.0.0') do
57
57
 
58
58
  $ puppet module install puppetlabs-vcsrepo --target-dir=/opt/puppetlabs/puppet/modules --modulepath /etc/puppetlabs/code/modules
59
59
  Preparing to install into /opt/puppetlabs/puppet/modules ...
60
- Downloading from https://forgeapi.puppetlabs.com ...
60
+ Downloading from https://forgeapi.puppet.com ...
61
61
  Installing -- do not interrupt ...
62
62
  /opt/puppetlabs/puppet/modules
63
63
  └── puppetlabs-vcsrepo (v0.0.4)
@@ -66,7 +66,7 @@ Puppet::Face.define(:module, '1.0.0') do
66
66
 
67
67
  $ puppet module install puppetlabs-vcsrepo-0.0.4.tar.gz
68
68
  Preparing to install into /etc/puppetlabs/code/modules ...
69
- Downloading from https://forgeapi.puppetlabs.com ...
69
+ Downloading from https://forgeapi.puppet.com ...
70
70
  Installing -- do not interrupt ...
71
71
  /etc/puppetlabs/code/modules
72
72
  └── puppetlabs-vcsrepo (v0.0.4)
@@ -162,7 +162,7 @@ module Puppet::Functions
162
162
  end
163
163
 
164
164
  # Creates a function in, or in a local loader under the given loader.
165
- # This method should only be used when manually creating functions
165
+ # This method should only be used when manually creating functions
166
166
  # for the sake of testing. Functions that are autoloaded should
167
167
  # always use the `create_function` method and the autoloader will supply
168
168
  # the correct loader.
@@ -258,8 +258,8 @@ module Puppet::Functions
258
258
  def self.any_signature(from, to, names)
259
259
  # Construct the type for the signature
260
260
  # Tuple[Object, from, to]
261
- factory = Puppet::Pops::Types::TypeFactory
262
- [factory.callable(factory.any, from, to), names]
261
+ param_types = Puppet::Pops::Types::PTupleType.new([Puppet::Pops::Types::PAnyType::DEFAULT], Puppet::Pops::Types::PIntegerType.new(from, to))
262
+ [Puppet::Pops::Types::PCallableType.new(param_types), names]
263
263
  end
264
264
 
265
265
  # Function
@@ -272,8 +272,7 @@ module Puppet::Functions
272
272
 
273
273
  # @api private
274
274
  def self.builder
275
- @all_callables ||= Puppet::Pops::Types::TypeFactory.all_callables
276
- DispatcherBuilder.new(dispatcher, Puppet::Pops::Types::TypeParser.singleton, @all_callables, loader)
275
+ DispatcherBuilder.new(dispatcher, Puppet::Pops::Types::TypeParser.singleton, Puppet::Pops::Types::PCallableType::DEFAULT, loader)
277
276
  end
278
277
 
279
278
  # Dispatch any calls that match the signature to the provided method name.
@@ -310,7 +309,7 @@ module Puppet::Functions
310
309
  t = Puppet::Pops::Loader::TypeDefinitionInstantiator.create_from_model(type_alias_expr, aliases.loader)
311
310
 
312
311
  # Also define a method for convenient access to the defined type alias.
313
- # Since initial capital letter in Ruby means a Constant these names use a prefix of
312
+ # Since initial capital letter in Ruby means a Constant these names use a prefix of
314
313
  # `type`. As an example, the type 'MyType' is accessed by calling `type_MyType`.
315
314
  define_method("type_#{t.name}") { t }
316
315
  end
@@ -466,6 +465,15 @@ module Puppet::Functions
466
465
  @block_type = Puppet::Pops::Types::TypeFactory.optional(@block_type)
467
466
  end
468
467
 
468
+ # Defines the return type. Defaults to 'Any'
469
+ # @param [String] type a reference to a Puppet Data Type
470
+ #
471
+ # @api public
472
+ def return_type(type)
473
+ raise ArgumentError, "Argument to 'return_type' must be a String reference to a Puppet Data Type. Got #{type.class}" unless type.is_a?(String)
474
+ @return_type = type
475
+ end
476
+
469
477
  private
470
478
 
471
479
  # @api private
@@ -505,8 +513,9 @@ module Puppet::Functions
505
513
  @max = 0
506
514
  @block_type = nil
507
515
  @block_name = nil
516
+ @return_type = nil
508
517
  self.instance_eval &block
509
- callable_t = create_callable(@types, @block_type, @min, @max)
518
+ callable_t = create_callable(@types, @block_type, @return_type, @min, @max)
510
519
  @dispatcher.add_dispatch(callable_t, meth_name, @names, @block_name, @injections, @weaving, @max == :default)
511
520
  end
512
521
 
@@ -516,28 +525,19 @@ module Puppet::Functions
516
525
  # Optional[Callable], Callable, or nil.
517
526
  #
518
527
  # @api private
519
- def create_callable(types, block_type, from, to)
528
+ def create_callable(types, block_type, return_type, from, to)
520
529
  mapped_types = types.map do |t|
521
530
  @type_parser.parse(t, loader)
522
531
  end
523
-
524
- if from == 0 || from != to
525
- # :optional and/or :repeated parameters are present.
526
- mapped_types << from
527
- mapped_types << to
528
- end
529
-
530
- if block_type
531
- mapped_types << block_type
532
- end
533
-
534
- Puppet::Pops::Types::TypeFactory.callable(*mapped_types)
532
+ param_types = Puppet::Pops::Types::PTupleType.new(mapped_types, from > 0 && from == to ? nil : Puppet::Pops::Types::PIntegerType.new(from, to))
533
+ return_type = @type_parser.parse(return_type, loader) unless return_type.nil?
534
+ Puppet::Pops::Types::PCallableType.new(param_types, block_type, return_type)
535
535
  end
536
536
  end
537
537
 
538
538
  # The LocalTypeAliasBuilder is used by the 'local_types' method to collect the individual
539
539
  # type aliases given by the function's author.
540
- #
540
+ #
541
541
  class LocalTypeAliasesBuilder
542
542
  attr_reader :local_types, :parser, :loader
543
543
 
@@ -552,7 +552,7 @@ module Puppet::Functions
552
552
  # in string form without the leading 'type' keyword.
553
553
  # Calls to local_type must be made before the first parameter definition or an error will
554
554
  # be raised.
555
- #
555
+ #
556
556
  # @param assignment_string [String] a string on the form 'AliasType = ExistingType'
557
557
  # @api public
558
558
  #
@@ -601,8 +601,7 @@ module Puppet::Functions
601
601
  class InternalFunction < Function
602
602
  # @api private
603
603
  def self.builder
604
- @all_callables ||= Puppet::Pops::Types::TypeFactory.all_callables
605
- InternalDispatchBuilder.new(dispatcher, Puppet::Pops::Types::TypeParser.singleton, @all_callables, loader)
604
+ InternalDispatchBuilder.new(dispatcher, Puppet::Pops::Types::TypeParser.singleton, Puppet::Pops::Types::PCallableType::DEFAULT, loader)
606
605
  end
607
606
 
608
607
  # Defines class level injected attribute with reader method
@@ -0,0 +1,14 @@
1
+ # Log a message on the server at level alert.
2
+ Puppet::Functions.create_function(:alert, Puppet::Functions::InternalFunction) do
3
+ # @param values The values to log.
4
+ # @return [Undef]
5
+ dispatch :alert do
6
+ scope_param
7
+ repeated_param 'Any', :values
8
+ return_type 'Undef'
9
+ end
10
+
11
+ def alert(scope, *values)
12
+ Puppet::Util::Log.log_func(scope, :alert, values)
13
+ end
14
+ end
@@ -0,0 +1,25 @@
1
+ # Loads a binary file from a module or file system and returns its contents as a Binary.
2
+ # (Documented in 3.x stub)
3
+ #
4
+ # @since 4.8.0
5
+ #
6
+ Puppet::Functions.create_function(:binary_file, Puppet::Functions::InternalFunction) do
7
+ dispatch :binary_file do
8
+ scope_param
9
+ param 'String', :path
10
+ end
11
+
12
+ def binary_file(scope, unresolved_path)
13
+ path = nil
14
+ found = Puppet::Parser::Files.find_file(unresolved_path, scope.compiler.environment)
15
+ if found && Puppet::FileSystem.exist?(found)
16
+ path = found
17
+ end
18
+
19
+ if path
20
+ Puppet::Pops::Types::PBinaryType::Binary.from_binary_string(Puppet::FileSystem.binread(path))
21
+ else
22
+ raise Puppet::ParseError, "binary_file(): The given file '#{path}' does not exist"
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,22 @@
1
+ # Make iteration break as if there were no more values to process
2
+ #
3
+ # @since 4.7.0
4
+ #
5
+ Puppet::Functions.create_function(:break) do
6
+ dispatch :break_impl do
7
+ end
8
+
9
+ def break_impl()
10
+ stacktrace = Puppet::Pops::PuppetStack.stacktrace()
11
+ if stacktrace.size > 0
12
+ file, line = stacktrace[0]
13
+ else
14
+ file = nil
15
+ line = nil
16
+ end
17
+ # PuppetStopIteration contains file and line and is a StopIteration exception
18
+ # so it can break a Ruby Kernel#loop or enumeration
19
+ #
20
+ raise Puppet::Pops::Evaluator::PuppetStopIteration.new(file, line)
21
+ end
22
+ end
@@ -0,0 +1,33 @@
1
+ # Called within a class definition, establishes a containment
2
+ # relationship with another class
3
+ # For documentation, see the 3.x stub
4
+ #
5
+ Puppet::Functions.create_function(:contain, Puppet::Functions::InternalFunction) do
6
+ dispatch :contain do
7
+ scope_param
8
+ # The function supports what the type system sees as Ruby runtime objects, and
9
+ # they cannot be parameterized to find what is actually valid instances.
10
+ # The validation is instead done in the function body itself via a call to
11
+ # `transform_and_assert_classnames` on the calling scope.
12
+ required_repeated_param 'Any', :names
13
+ end
14
+
15
+ def contain(scope, *classes)
16
+ # Make call patterns uniform and protected against nested arrays, also make
17
+ # names absolute if so desired.
18
+ classes = scope.transform_and_assert_classnames(classes.flatten)
19
+
20
+ result = classes.map {|name| Puppet::Pops::Types::TypeFactory.host_class(name) }
21
+ containing_resource = scope.resource
22
+
23
+ # This is the same as calling the include function but faster and does not rely on the include
24
+ # function.
25
+ (scope.compiler.evaluate_classes(classes, scope, false) || []).each do |resource|
26
+ if ! scope.catalog.edge?(containing_resource, resource)
27
+ scope.catalog.add_edge(containing_resource, resource)
28
+ end
29
+ end
30
+ # Result is an Array[Class, 1, n] which allows chaining other operations
31
+ result
32
+ end
33
+ end
@@ -0,0 +1,14 @@
1
+ # Log a message on the server at level crit.
2
+ Puppet::Functions.create_function(:crit, Puppet::Functions::InternalFunction) do
3
+ # @param values The values to log.
4
+ # @return [Undef]
5
+ dispatch :crit do
6
+ scope_param
7
+ repeated_param 'Any', :values
8
+ return_type 'Undef'
9
+ end
10
+
11
+ def crit(scope, *values)
12
+ Puppet::Util::Log.log_func(scope, :crit, values)
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ # Log a message on the server at level debug.
2
+ Puppet::Functions.create_function(:debug, Puppet::Functions::InternalFunction) do
3
+ # @param values The values to log.
4
+ # @return [Undef]
5
+ dispatch :debug do
6
+ scope_param
7
+ repeated_param 'Any', :values
8
+ return_type 'Undef'
9
+ end
10
+
11
+ def debug(scope, *values)
12
+ Puppet::Util::Log.log_func(scope, :debug, values)
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ # Log a message on the server at level emerg.
2
+ Puppet::Functions.create_function(:emerg, Puppet::Functions::InternalFunction) do
3
+ # @param values The values to log.
4
+ # @return [Undef]
5
+ dispatch :emerg do
6
+ scope_param
7
+ repeated_param 'Any', :values
8
+ return_type 'Undef'
9
+ end
10
+
11
+ def emerg(scope, *values)
12
+ Puppet::Util::Log.log_func(scope, :emerg, values)
13
+ end
14
+ end
@@ -18,7 +18,7 @@
18
18
  # template and pass the `docroot` and `virtual_docroot` parameters, call the `epp`
19
19
  # function like this:
20
20
  #
21
- # `epp('apache/templates/vhost/_docroot.epp', { 'docroot' => '/var/www/html',
21
+ # `epp('apache/vhost/_docroot.epp', { 'docroot' => '/var/www/html',
22
22
  # 'virtual_docroot' => '/var/www/example' })`
23
23
  #
24
24
  # Puppet produces a syntax error if you pass more parameters than are declared in
@@ -0,0 +1,14 @@
1
+ # Log a message on the server at level err.
2
+ Puppet::Functions.create_function(:err, Puppet::Functions::InternalFunction) do
3
+ # @param values The values to log.
4
+ # @return [Undef]
5
+ dispatch :err do
6
+ scope_param
7
+ repeated_param 'Any', :values
8
+ return_type 'Undef'
9
+ end
10
+
11
+ def err(scope, *values)
12
+ Puppet::Util::Log.log_func(scope, :err, values)
13
+ end
14
+ end
@@ -0,0 +1,31 @@
1
+ # Finds an existing file from a module and returns its path.
2
+ # (Documented in 3.x stub)
3
+ #
4
+ # @since 4.8.0
5
+ #
6
+ Puppet::Functions.create_function(:find_file, Puppet::Functions::InternalFunction) do
7
+ dispatch :find_file do
8
+ scope_param
9
+ repeated_param 'String', :paths
10
+ end
11
+
12
+ dispatch :find_file_array do
13
+ scope_param
14
+ repeated_param 'Array[String]', :paths_array
15
+ end
16
+
17
+ def find_file_array(scope, array)
18
+ find_file(scope, *array)
19
+ end
20
+
21
+ def find_file(scope, *args)
22
+ path = nil
23
+ args.each do |file|
24
+ found = Puppet::Parser::Files.find_file(file, scope.compiler.environment)
25
+ if found && Puppet::FileSystem.exist?(found)
26
+ return found
27
+ end
28
+ end
29
+ nil
30
+ end
31
+ end
@@ -0,0 +1,21 @@
1
+ # Include the specified classes
2
+ # For documentation see the 3.x stub
3
+ Puppet::Functions.create_function(:include, Puppet::Functions::InternalFunction) do
4
+ dispatch :include do
5
+ scope_param
6
+ # The function supports what the type system sees as Ruby runtime objects, and
7
+ # they cannot be parameterized to find what is actually valid instances.
8
+ # The validation is instead done in the function body itself via a call to
9
+ # `transform_and_assert_classnames` on the calling scope.
10
+ required_repeated_param 'Any', :names
11
+ end
12
+
13
+ def include(scope, *classes)
14
+ classes = scope.transform_and_assert_classnames(classes.flatten)
15
+ result = classes.map {|name| Puppet::Pops::Types::TypeFactory.host_class(name) }
16
+ scope.compiler.evaluate_classes(classes, scope, false)
17
+
18
+ # Result is an Array[Class, 1, n] which allows chaining other operations
19
+ result
20
+ end
21
+ end
@@ -0,0 +1,14 @@
1
+ # Log a message on the server at level info.
2
+ Puppet::Functions.create_function(:info, Puppet::Functions::InternalFunction) do
3
+ # @param values The values to log.
4
+ # @return [Undef]
5
+ dispatch :info do
6
+ scope_param
7
+ repeated_param 'Any', :values
8
+ return_type 'Undef'
9
+ end
10
+
11
+ def info(scope, *values)
12
+ Puppet::Util::Log.log_func(scope, :info, values)
13
+ end
14
+ end
@@ -26,6 +26,6 @@ Puppet::Functions.create_function(:new, Puppet::Functions::InternalFunction) do
26
26
  end
27
27
 
28
28
  def assert_type(type, value)
29
- Puppet::Pops::Types::TypeAsserter.assert_instance_of('new():', type, value)
29
+ Puppet::Pops::Types::TypeAsserter.assert_instance_of(['Converted value from %s.new()', type], type, value)
30
30
  end
31
31
  end
@@ -0,0 +1,23 @@
1
+ # Make iteration continue with the next value optionally given a value for this iteration.
2
+ # If a value is not given it defaults to `undef`
3
+ #
4
+ # @since 4.7.0
5
+ #
6
+ Puppet::Functions.create_function(:next) do
7
+ dispatch :next_impl do
8
+ optional_param 'Any', :value
9
+ end
10
+
11
+ def next_impl(value = nil)
12
+ stacktrace = Puppet::Pops::PuppetStack.stacktrace()
13
+ if stacktrace.size > 0
14
+ file, line = stacktrace[0]
15
+ else
16
+ file = nil
17
+ line = nil
18
+ end
19
+
20
+ exc = Puppet::Pops::Evaluator::Next.new(value, file, line)
21
+ raise exc
22
+ end
23
+ end