bolt 0.20.3 → 0.20.5

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

Potentially problematic release.


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

Files changed (256) hide show
  1. checksums.yaml +4 -4
  2. data/bolt-modules/boltlib/lib/puppet/functions/run_task.rb +3 -3
  3. data/bolt-modules/boltlib/lib/puppet/functions/set_feature.rb +33 -0
  4. data/lib/bolt/inventory.rb +19 -1
  5. data/lib/bolt/target.rb +15 -0
  6. data/lib/bolt/transport/local.rb +6 -1
  7. data/lib/bolt/transport/orch.rb +2 -0
  8. data/lib/bolt/transport/ssh.rb +7 -2
  9. data/lib/bolt/transport/winrm.rb +6 -1
  10. data/lib/bolt/version.rb +1 -1
  11. data/modules/facts/plans/retrieve.pp +2 -26
  12. data/modules/facts/tasks/init.json +9 -0
  13. data/vendored/puppet/lib/hiera/puppet_function.rb +1 -1
  14. data/vendored/puppet/lib/hiera/scope.rb +24 -2
  15. data/vendored/puppet/lib/puppet.rb +4 -13
  16. data/vendored/puppet/lib/puppet/application.rb +2 -2
  17. data/vendored/puppet/lib/puppet/application/agent.rb +1 -1
  18. data/vendored/puppet/lib/puppet/application/apply.rb +1 -1
  19. data/vendored/puppet/lib/puppet/application/cert.rb +1 -1
  20. data/vendored/puppet/lib/puppet/application/device.rb +8 -8
  21. data/vendored/puppet/lib/puppet/application/face_base.rb +1 -1
  22. data/vendored/puppet/lib/puppet/application/lookup.rb +2 -2
  23. data/vendored/puppet/lib/puppet/application/resource.rb +2 -2
  24. data/vendored/puppet/lib/puppet/application/script.rb +1 -1
  25. data/vendored/puppet/lib/puppet/configurer.rb +47 -24
  26. data/vendored/puppet/lib/puppet/confine.rb +4 -1
  27. data/vendored/puppet/lib/puppet/context.rb +1 -1
  28. data/vendored/puppet/lib/puppet/defaults.rb +32 -44
  29. data/vendored/puppet/lib/puppet/error.rb +14 -7
  30. data/vendored/puppet/lib/puppet/external/dot.rb +23 -17
  31. data/vendored/puppet/lib/puppet/face/config.rb +58 -3
  32. data/vendored/puppet/lib/puppet/face/epp.rb +1 -1
  33. data/vendored/puppet/lib/puppet/face/module/build.rb +3 -3
  34. data/vendored/puppet/lib/puppet/face/module/install.rb +0 -4
  35. data/vendored/puppet/lib/puppet/face/module/list.rb +0 -5
  36. data/vendored/puppet/lib/puppet/face/module/search.rb +1 -1
  37. data/vendored/puppet/lib/puppet/face/module/uninstall.rb +0 -4
  38. data/vendored/puppet/lib/puppet/face/module/upgrade.rb +0 -4
  39. data/vendored/puppet/lib/puppet/face/status.rb +2 -2
  40. data/vendored/puppet/lib/puppet/file_serving/base.rb +5 -5
  41. data/vendored/puppet/lib/puppet/file_serving/metadata.rb +2 -1
  42. data/vendored/puppet/lib/puppet/forge.rb +7 -8
  43. data/vendored/puppet/lib/puppet/forge/errors.rb +3 -3
  44. data/vendored/puppet/lib/puppet/functions/abs.rb +61 -0
  45. data/vendored/puppet/lib/puppet/functions/all.rb +2 -2
  46. data/vendored/puppet/lib/puppet/functions/any.rb +2 -2
  47. data/vendored/puppet/lib/puppet/functions/assert_type.rb +3 -3
  48. data/vendored/puppet/lib/puppet/functions/break.rb +3 -7
  49. data/vendored/puppet/lib/puppet/functions/camelcase.rb +62 -0
  50. data/vendored/puppet/lib/puppet/functions/capitalize.rb +61 -0
  51. data/vendored/puppet/lib/puppet/functions/ceiling.rb +37 -0
  52. data/vendored/puppet/lib/puppet/functions/chomp.rb +57 -0
  53. data/vendored/puppet/lib/puppet/functions/chop.rb +67 -0
  54. data/vendored/puppet/lib/puppet/functions/compare.rb +125 -0
  55. data/vendored/puppet/lib/puppet/functions/convert_to.rb +3 -2
  56. data/vendored/puppet/lib/puppet/functions/dig.rb +21 -1
  57. data/vendored/puppet/lib/puppet/functions/downcase.rb +89 -0
  58. data/vendored/puppet/lib/puppet/functions/each.rb +2 -2
  59. data/vendored/puppet/lib/puppet/functions/empty.rb +1 -3
  60. data/vendored/puppet/lib/puppet/functions/eyaml_lookup_key.rb +4 -2
  61. data/vendored/puppet/lib/puppet/functions/filter.rb +2 -2
  62. data/vendored/puppet/lib/puppet/functions/floor.rb +37 -0
  63. data/vendored/puppet/lib/puppet/functions/get.rb +150 -0
  64. data/vendored/puppet/lib/puppet/functions/getvar.rb +87 -0
  65. data/vendored/puppet/lib/puppet/functions/hiera.rb +5 -5
  66. data/vendored/puppet/lib/puppet/functions/hiera_array.rb +5 -5
  67. data/vendored/puppet/lib/puppet/functions/hiera_hash.rb +6 -6
  68. data/vendored/puppet/lib/puppet/functions/hiera_include.rb +7 -7
  69. data/vendored/puppet/lib/puppet/functions/hocon_data.rb +1 -1
  70. data/vendored/puppet/lib/puppet/functions/json_data.rb +3 -3
  71. data/vendored/puppet/lib/puppet/functions/lest.rb +1 -1
  72. data/vendored/puppet/lib/puppet/functions/lookup.rb +3 -2
  73. data/vendored/puppet/lib/puppet/functions/lstrip.rb +58 -0
  74. data/vendored/puppet/lib/puppet/functions/map.rb +1 -1
  75. data/vendored/puppet/lib/puppet/functions/match.rb +11 -0
  76. data/vendored/puppet/lib/puppet/functions/max.rb +183 -0
  77. data/vendored/puppet/lib/puppet/functions/min.rb +182 -0
  78. data/vendored/puppet/lib/puppet/functions/next.rb +1 -8
  79. data/vendored/puppet/lib/puppet/functions/reduce.rb +1 -1
  80. data/vendored/puppet/lib/puppet/functions/return.rb +1 -8
  81. data/vendored/puppet/lib/puppet/functions/reverse_each.rb +1 -1
  82. data/vendored/puppet/lib/puppet/functions/round.rb +24 -0
  83. data/vendored/puppet/lib/puppet/functions/rstrip.rb +58 -0
  84. data/vendored/puppet/lib/puppet/functions/size.rb +15 -0
  85. data/vendored/puppet/lib/puppet/functions/sort.rb +74 -0
  86. data/vendored/puppet/lib/puppet/functions/step.rb +1 -1
  87. data/vendored/puppet/lib/puppet/functions/strftime.rb +1 -7
  88. data/vendored/puppet/lib/puppet/functions/strip.rb +58 -0
  89. data/vendored/puppet/lib/puppet/functions/then.rb +1 -1
  90. data/vendored/puppet/lib/puppet/functions/tree_each.rb +7 -7
  91. data/vendored/puppet/lib/puppet/functions/upcase.rb +89 -0
  92. data/vendored/puppet/lib/puppet/functions/with.rb +4 -4
  93. data/vendored/puppet/lib/puppet/functions/yaml_data.rb +4 -2
  94. data/vendored/puppet/lib/puppet/graph/simple_graph.rb +9 -5
  95. data/vendored/puppet/lib/puppet/indirector/certificate_revocation_list/rest.rb +0 -11
  96. data/vendored/puppet/lib/puppet/indirector/indirection.rb +8 -12
  97. data/vendored/puppet/lib/puppet/indirector/node/exec.rb +1 -1
  98. data/vendored/puppet/lib/puppet/indirector/node/ldap.rb +1 -1
  99. data/vendored/puppet/lib/puppet/indirector/request.rb +11 -11
  100. data/vendored/puppet/lib/puppet/indirector/rest.rb +11 -11
  101. data/vendored/puppet/lib/puppet/interface/action.rb +2 -5
  102. data/vendored/puppet/lib/puppet/metatype/manager.rb +0 -2
  103. data/vendored/puppet/lib/puppet/module.rb +7 -33
  104. data/vendored/puppet/lib/puppet/module/task.rb +0 -1
  105. data/vendored/puppet/lib/puppet/module_tool.rb +2 -5
  106. data/vendored/puppet/lib/puppet/module_tool/applications/application.rb +5 -5
  107. data/vendored/puppet/lib/puppet/module_tool/applications/builder.rb +2 -2
  108. data/vendored/puppet/lib/puppet/module_tool/applications/checksummer.rb +3 -3
  109. data/vendored/puppet/lib/puppet/module_tool/applications/installer.rb +6 -7
  110. data/vendored/puppet/lib/puppet/module_tool/applications/uninstaller.rb +1 -2
  111. data/vendored/puppet/lib/puppet/module_tool/applications/unpacker.rb +2 -2
  112. data/vendored/puppet/lib/puppet/module_tool/applications/upgrader.rb +5 -6
  113. data/vendored/puppet/lib/puppet/module_tool/dependency.rb +1 -1
  114. data/vendored/puppet/lib/puppet/module_tool/installed_modules.rb +2 -2
  115. data/vendored/puppet/lib/puppet/module_tool/local_tarball.rb +3 -3
  116. data/vendored/puppet/lib/puppet/module_tool/metadata.rb +3 -4
  117. data/vendored/puppet/lib/puppet/module_tool/shared_behaviors.rb +2 -2
  118. data/vendored/puppet/lib/puppet/network/authconfig.rb +0 -13
  119. data/vendored/puppet/lib/puppet/network/format_support.rb +1 -1
  120. data/vendored/puppet/lib/puppet/network/formats.rb +5 -7
  121. data/vendored/puppet/lib/puppet/network/http.rb +0 -2
  122. data/vendored/puppet/lib/puppet/network/http/api.rb +1 -10
  123. data/vendored/puppet/lib/puppet/network/http/api/master/v3/environment.rb +2 -2
  124. data/vendored/puppet/lib/puppet/network/http/api/master/v3/environments.rb +2 -2
  125. data/vendored/puppet/lib/puppet/network/http/compression.rb +1 -1
  126. data/vendored/puppet/lib/puppet/network/http/connection.rb +11 -3
  127. data/vendored/puppet/lib/puppet/network/http/error.rb +3 -3
  128. data/vendored/puppet/lib/puppet/network/http/factory.rb +3 -0
  129. data/vendored/puppet/lib/puppet/network/http/handler.rb +59 -27
  130. data/vendored/puppet/lib/puppet/network/resolver.rb +140 -67
  131. data/vendored/puppet/lib/puppet/node/environment.rb +2 -19
  132. data/vendored/puppet/lib/puppet/parameter.rb +12 -7
  133. data/vendored/puppet/lib/puppet/parser/ast.rb +4 -8
  134. data/vendored/puppet/lib/puppet/parser/ast/branch.rb +3 -3
  135. data/vendored/puppet/lib/puppet/parser/ast/leaf.rb +5 -0
  136. data/vendored/puppet/lib/puppet/parser/ast/pops_bridge.rb +18 -0
  137. data/vendored/puppet/lib/puppet/parser/compiler.rb +3 -4
  138. data/vendored/puppet/lib/puppet/parser/compiler/catalog_validator/relationship_validator.rb +9 -2
  139. data/vendored/puppet/lib/puppet/parser/functions.rb +1 -1
  140. data/vendored/puppet/lib/puppet/parser/functions/assert_type.rb +3 -3
  141. data/vendored/puppet/lib/puppet/parser/functions/create_resources.rb +1 -7
  142. data/vendored/puppet/lib/puppet/parser/functions/each.rb +2 -2
  143. data/vendored/puppet/lib/puppet/parser/functions/filter.rb +1 -1
  144. data/vendored/puppet/lib/puppet/parser/functions/hiera.rb +4 -4
  145. data/vendored/puppet/lib/puppet/parser/functions/hiera_array.rb +5 -5
  146. data/vendored/puppet/lib/puppet/parser/functions/hiera_hash.rb +6 -6
  147. data/vendored/puppet/lib/puppet/parser/functions/hiera_include.rb +10 -11
  148. data/vendored/puppet/lib/puppet/parser/functions/inline_template.rb +1 -1
  149. data/vendored/puppet/lib/puppet/parser/functions/lest.rb +1 -1
  150. data/vendored/puppet/lib/puppet/parser/functions/lookup.rb +1 -1
  151. data/vendored/puppet/lib/puppet/parser/functions/map.rb +1 -1
  152. data/vendored/puppet/lib/puppet/parser/functions/reduce.rb +1 -1
  153. data/vendored/puppet/lib/puppet/parser/functions/return.rb +22 -1
  154. data/vendored/puppet/lib/puppet/parser/functions/reverse_each.rb +1 -1
  155. data/vendored/puppet/lib/puppet/parser/functions/step.rb +1 -1
  156. data/vendored/puppet/lib/puppet/parser/functions/then.rb +1 -1
  157. data/vendored/puppet/lib/puppet/parser/functions/with.rb +4 -4
  158. data/vendored/puppet/lib/puppet/parser/resource.rb +0 -1
  159. data/vendored/puppet/lib/puppet/parser/resource/param.rb +12 -5
  160. data/vendored/puppet/lib/puppet/parser/scope.rb +5 -7
  161. data/vendored/puppet/lib/puppet/pops/evaluator/compare_operator.rb +3 -1
  162. data/vendored/puppet/lib/puppet/pops/evaluator/runtime3_support.rb +2 -7
  163. data/vendored/puppet/lib/puppet/pops/issues.rb +4 -0
  164. data/vendored/puppet/lib/puppet/pops/loader/loader_paths.rb +2 -2
  165. data/vendored/puppet/lib/puppet/pops/loader/module_loaders.rb +17 -12
  166. data/vendored/puppet/lib/puppet/pops/loader/task_instantiator.rb +73 -45
  167. data/vendored/puppet/lib/puppet/pops/lookup/lookup_adapter.rb +55 -6
  168. data/vendored/puppet/lib/puppet/pops/model/model_label_provider.rb +2 -0
  169. data/vendored/puppet/lib/puppet/pops/parser/epp_parser.rb +1 -1
  170. data/vendored/puppet/lib/puppet/pops/parser/epp_support.rb +6 -2
  171. data/vendored/puppet/lib/puppet/pops/parser/lexer2.rb +1 -1
  172. data/vendored/puppet/lib/puppet/pops/pcore.rb +7 -7
  173. data/vendored/puppet/lib/puppet/pops/puppet_stack.rb +15 -1
  174. data/vendored/puppet/lib/puppet/pops/serialization.rb +2 -2
  175. data/vendored/puppet/lib/puppet/pops/serialization/from_data_converter.rb +2 -2
  176. data/vendored/puppet/lib/puppet/pops/serialization/json.rb +7 -7
  177. data/vendored/puppet/lib/puppet/pops/serialization/to_data_converter.rb +5 -5
  178. data/vendored/puppet/lib/puppet/pops/types/types.rb +8 -4
  179. data/vendored/puppet/lib/puppet/pops/validation/checker4_0.rb +73 -0
  180. data/vendored/puppet/lib/puppet/pops/validation/validator_factory_4_0.rb +4 -3
  181. data/vendored/puppet/lib/puppet/provider/augeas/augeas.rb +7 -0
  182. data/vendored/puppet/lib/puppet/provider/service/systemd.rb +1 -1
  183. data/vendored/puppet/lib/puppet/provider/user/aix.rb +2 -2
  184. data/vendored/puppet/lib/puppet/provider/yumrepo/inifile.rb +21 -9
  185. data/vendored/puppet/lib/puppet/reference/providers.rb +1 -1
  186. data/vendored/puppet/lib/puppet/reference/report.rb +1 -1
  187. data/vendored/puppet/lib/puppet/resource.rb +1 -1
  188. data/vendored/puppet/lib/puppet/resource/capability_finder.rb +4 -4
  189. data/vendored/puppet/lib/puppet/resource/catalog.rb +6 -3
  190. data/vendored/puppet/lib/puppet/resource/type.rb +6 -2
  191. data/vendored/puppet/lib/puppet/rest/client.rb +79 -0
  192. data/vendored/puppet/lib/puppet/rest/errors.rb +14 -0
  193. data/vendored/puppet/lib/puppet/rest/response.rb +29 -0
  194. data/vendored/puppet/lib/puppet/rest/route.rb +102 -0
  195. data/vendored/puppet/lib/puppet/rest/routes.rb +31 -0
  196. data/vendored/puppet/lib/puppet/settings.rb +9 -5
  197. data/vendored/puppet/lib/puppet/settings/config_file.rb +1 -1
  198. data/vendored/puppet/lib/puppet/settings/environment_conf.rb +10 -1
  199. data/vendored/puppet/lib/puppet/ssl.rb +0 -1
  200. data/vendored/puppet/lib/puppet/ssl/certificate.rb +6 -2
  201. data/vendored/puppet/lib/puppet/ssl/certificate_authority.rb +3 -3
  202. data/vendored/puppet/lib/puppet/ssl/host.rb +258 -19
  203. data/vendored/puppet/lib/puppet/ssl/validator/default_validator.rb +33 -19
  204. data/vendored/puppet/lib/puppet/syntax_checkers/json.rb +1 -1
  205. data/vendored/puppet/lib/puppet/transaction/event.rb +34 -7
  206. data/vendored/puppet/lib/puppet/transaction/report.rb +17 -14
  207. data/vendored/puppet/lib/puppet/type.rb +20 -12
  208. data/vendored/puppet/lib/puppet/type/file.rb +1 -1
  209. data/vendored/puppet/lib/puppet/type/file/content.rb +15 -2
  210. data/vendored/puppet/lib/puppet/type/file/ensure.rb +1 -1
  211. data/vendored/puppet/lib/puppet/type/schedule.rb +1 -1
  212. data/vendored/puppet/lib/puppet/type/stage.rb +1 -1
  213. data/vendored/puppet/lib/puppet/type/tidy.rb +5 -1
  214. data/vendored/puppet/lib/puppet/type/user.rb +35 -18
  215. data/vendored/puppet/lib/puppet/type/yumrepo.rb +8 -17
  216. data/vendored/puppet/lib/puppet/util.rb +0 -1
  217. data/vendored/puppet/lib/puppet/util/autoload.rb +1 -6
  218. data/vendored/puppet/lib/puppet/util/checksums.rb +0 -2
  219. data/vendored/puppet/lib/puppet/util/classgen.rb +0 -6
  220. data/vendored/puppet/lib/puppet/util/fileparsing.rb +27 -5
  221. data/vendored/puppet/lib/puppet/util/instance_loader.rb +3 -3
  222. data/vendored/puppet/lib/puppet/util/json.rb +77 -0
  223. data/vendored/puppet/lib/puppet/util/json_lockfile.rb +3 -3
  224. data/vendored/puppet/lib/puppet/util/ldap/connection.rb +7 -7
  225. data/vendored/puppet/lib/puppet/util/log/destinations.rb +2 -2
  226. data/vendored/puppet/lib/puppet/util/logging.rb +1 -1
  227. data/vendored/puppet/lib/puppet/util/plist.rb +1 -1
  228. data/vendored/puppet/lib/puppet/util/provider_features.rb +2 -5
  229. data/vendored/puppet/lib/puppet/util/reference.rb +5 -4
  230. data/vendored/puppet/lib/puppet/util/tagging.rb +16 -3
  231. data/vendored/puppet/lib/puppet/version.rb +1 -1
  232. metadata +44 -26
  233. data/vendored/puppet/lib/puppet/application/master.rb +0 -317
  234. data/vendored/puppet/lib/puppet/feature/rack.rb +0 -19
  235. data/vendored/puppet/lib/puppet/network/http/api/ca.rb +0 -2
  236. data/vendored/puppet/lib/puppet/network/http/api/ca/v1.rb +0 -11
  237. data/vendored/puppet/lib/puppet/network/http/rack.rb +0 -33
  238. data/vendored/puppet/lib/puppet/network/http/rack/rest.rb +0 -162
  239. data/vendored/puppet/lib/puppet/network/http/webrick.rb +0 -124
  240. data/vendored/puppet/lib/puppet/network/http/webrick/rest.rb +0 -114
  241. data/vendored/puppet/lib/puppet/network/server.rb +0 -39
  242. data/vendored/puppet/lib/puppet/ssl/configuration.rb +0 -61
  243. data/vendored/puppet/lib/puppet/util/methodhelper.rb +0 -32
  244. data/vendored/puppet/lib/puppet/vendor/load_semantic.rb +0 -1
  245. data/vendored/puppet/lib/puppet/vendor/load_semantic_puppet.rb +0 -1
  246. data/vendored/puppet/lib/puppet/vendor/semantic/lib/semantic.rb +0 -5
  247. data/vendored/puppet/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet.rb +0 -11
  248. data/vendored/puppet/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency.rb +0 -181
  249. data/vendored/puppet/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency/graph.rb +0 -60
  250. data/vendored/puppet/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency/graph_node.rb +0 -117
  251. data/vendored/puppet/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency/module_release.rb +0 -58
  252. data/vendored/puppet/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency/source.rb +0 -25
  253. data/vendored/puppet/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency/unsatisfiable_graph.rb +0 -31
  254. data/vendored/puppet/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/gem_version.rb +0 -3
  255. data/vendored/puppet/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/version.rb +0 -203
  256. data/vendored/puppet/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/version_range.rb +0 -758
@@ -1,6 +1,6 @@
1
1
  Puppet::Parser::Functions::newfunction(:inline_template, :type => :rvalue, :arity => -2, :doc =>
2
2
  "Evaluate a template string and return its value. See
3
- [the templating docs](https://docs.puppetlabs.com/puppet/latest/reference/lang_template.html) for
3
+ [the templating docs](https://puppet.com/docs/puppet/latest/lang_template.html) for
4
4
  more information. Note that if multiple template strings are specified, their
5
5
  output is all concatenated and returned as the output of the function.") do |vals|
6
6
 
@@ -3,7 +3,7 @@ Puppet::Parser::Functions::newfunction(
3
3
  :type => :rvalue,
4
4
  :arity => -2,
5
5
  :doc => <<-DOC
6
- Call a [lambda](https://docs.puppet.com/puppet/latest/reference/lang_lambdas.html)
6
+ Call a [lambda](https://puppet.com/docs/puppet/latest/lang_lambdas.html)
7
7
  (which should accept no arguments) if the argument given to the function is `undef`.
8
8
  Returns the result of calling the lambda if the argument is `undef`, otherwise the
9
9
  given argument.
@@ -31,7 +31,7 @@ The arguments accepted by `lookup` are as follows:
31
31
  first key, it will try again with the subsequent ones, only resorting to a
32
32
  default value if none of them succeed.
33
33
  2. `<VALUE TYPE>` (data type) --- A
34
- [data type](https://docs.puppetlabs.com/puppet/latest/reference/lang_data_type.html)
34
+ [data type](https://puppet.com/docs/puppet/latest/lang_data_type.html)
35
35
  that must match the retrieved value; if not, the lookup (and catalog
36
36
  compilation) will fail. Defaults to `Data` (accepts any normal value).
37
37
  3. `<MERGE BEHAVIOR>` (string or hash; see **"Merge Behaviors"** below) ---
@@ -3,7 +3,7 @@ Puppet::Parser::Functions::newfunction(
3
3
  :type => :rvalue,
4
4
  :arity => -3,
5
5
  :doc => <<-DOC
6
- Applies a [lambda](https://docs.puppetlabs.com/puppet/latest/reference/lang_lambdas.html)
6
+ Applies a [lambda](https://puppet.com/docs/puppet/latest/lang_lambdas.html)
7
7
  to every value in a data structure and returns an array containing the results.
8
8
 
9
9
  This function takes two mandatory arguments, in this order:
@@ -3,7 +3,7 @@ Puppet::Parser::Functions::newfunction(
3
3
  :type => :rvalue,
4
4
  :arity => -3,
5
5
  :doc => <<-DOC
6
- Applies a [lambda](https://docs.puppetlabs.com/puppet/latest/reference/lang_lambdas.html)
6
+ Applies a [lambda](https://puppet.com/docs/puppet/latest/lang_lambdas.html)
7
7
  to every value in a data structure from the first argument, carrying over the returned
8
8
  value of each iteration, and returns the result of the lambda's final iteration. This
9
9
  lets you create a new value or data structure by combining values from the first
@@ -4,7 +4,8 @@ Puppet::Parser::Functions::newfunction(
4
4
  :doc => <<-DOC
5
5
  Immediately returns the given optional value from a function, class body or user defined type body.
6
6
  If a value is not given, an `undef` value is returned. This function does not return to the immediate caller.
7
- If called from within a lambda the return will return from the function evaluating the lambda.
7
+ If this function is called from within a lambda, the return action is from the scope of the
8
+ function containing the lambda (top scope), not the function accepting the lambda (local scope).
8
9
 
9
10
  The signal produced to return a value bubbles up through
10
11
  the call stack until reaching a function, class definition or
@@ -63,6 +64,26 @@ The code would notice `'bar'` but not `'foo'`
63
64
 
64
65
  Note that the returned value is ignored if used in a class or user defined type.
65
66
 
67
+ **Example:** Using `return` in a lambda
68
+
69
+ ```puppet
70
+ # Concatenate three strings into a single string formatted as a list.
71
+ function getFruit() {
72
+ with("apples", "oranges", "bananas") |$x, $y, $z| {
73
+ return("${x}, ${y}, and ${z}")
74
+ }
75
+ notice "not reached"
76
+ }
77
+ $fruit = getFruit()
78
+ notice $fruit
79
+
80
+ # The output contains "apples, oranges, and bananas".
81
+ # "not reached" is not output because the function returns its value within the
82
+ # calling function's scope, which stops processing the calling function before
83
+ # the `notice "not reached"` statement.
84
+ # Using `return()` outside of a calling function results in an error.
85
+ ```
86
+
66
87
  * Also see functions `return` and `break`
67
88
  * Since 4.8.0
68
89
  DOC
@@ -4,7 +4,7 @@ Puppet::Parser::Functions::newfunction(
4
4
  :arity => -1,
5
5
  :doc => <<-DOC
6
6
  Reverses the order of the elements of something that is iterable and optionally runs a
7
- [lambda](https://docs.puppetlabs.com/puppet/latest/reference/lang_lambdas.html) for each
7
+ [lambda](https://puppet.com/docs/puppet/latest/lang_lambdas.html) for each
8
8
  element.
9
9
 
10
10
  This function takes one to two arguments:
@@ -4,7 +4,7 @@ Puppet::Parser::Functions::newfunction(
4
4
  :arity => -1,
5
5
  :doc => <<-DOC
6
6
  Provides stepping with given interval over elements in an iterable and optionally runs a
7
- [lambda](https://docs.puppetlabs.com/puppet/latest/reference/lang_lambdas.html) for each
7
+ [lambda](https://puppet.com/docs/puppet/latest/lang_lambdas.html) for each
8
8
  element.
9
9
 
10
10
  This function takes two to three arguments:
@@ -3,7 +3,7 @@ Puppet::Parser::Functions::newfunction(
3
3
  :type => :rvalue,
4
4
  :arity => -2,
5
5
  :doc => <<-DOC
6
- Call a [lambda](https://docs.puppet.com/puppet/latest/reference/lang_lambdas.html)
6
+ Call a [lambda](https://puppet.com/docs/puppet/latest/lang_lambdas.html)
7
7
  with the given argument unless the argument is undef. Return `undef` if argument is
8
8
  `undef`, and otherwise the result of giving the argument to the lambda.
9
9
 
@@ -3,11 +3,11 @@ Puppet::Parser::Functions::newfunction(
3
3
  :type => :rvalue,
4
4
  :arity => -1,
5
5
  :doc => <<-DOC
6
- Call a [lambda](https://docs.puppetlabs.com/puppet/latest/reference/lang_lambdas.html)
6
+ Call a [lambda](https://puppet.com/docs/puppet/latest/lang_lambdas.html)
7
7
  with the given arguments and return the result. Since a lambda's scope is
8
- [local](https://docs.puppetlabs.com/puppet/latest/reference/lang_lambdas.html#lambda-scope)
9
- to the lambda, you can use the `with` function to create private blocks of code within a
10
- class using variables whose values cannot be accessed outside of the lambda.
8
+ local to the lambda, you can use the `with` function to create private blocks
9
+ of code within a class using variables whose values cannot be accessed outside
10
+ of the lambda.
11
11
 
12
12
  **Example**: Using `with`
13
13
 
@@ -8,7 +8,6 @@ class Puppet::Parser::Resource < Puppet::Resource
8
8
  require 'puppet/util/tagging'
9
9
 
10
10
  include Puppet::Util
11
- include Puppet::Util::MethodHelper
12
11
  include Puppet::Util::Errors
13
12
  include Puppet::Util::Logging
14
13
 
@@ -2,14 +2,21 @@
2
2
  class Puppet::Parser::Resource::Param
3
3
  include Puppet::Util
4
4
  include Puppet::Util::Errors
5
- include Puppet::Util::MethodHelper
6
5
 
7
6
  attr_accessor :name, :value, :source, :add, :file, :line
8
7
 
9
- def initialize(hash)
10
- set_options(hash)
11
- requiredopts(:name)
12
- @name = @name.intern
8
+ def initialize(name: nil, value: nil, source: nil, line: nil, file: nil, add: nil)
9
+ @value = value
10
+ @source = source
11
+ @line = line
12
+ @file = file
13
+ @add = add
14
+
15
+ unless name
16
+ # This must happen after file and line are set to have them reported in the error
17
+ self.fail(Puppet::ResourceError, "'name' is a required option for #{self.class}")
18
+ end
19
+ @name = name.intern
13
20
  end
14
21
 
15
22
  def line_to_i
@@ -7,8 +7,6 @@ require 'puppet/parser'
7
7
  require 'puppet/parser/templatewrapper'
8
8
  require 'puppet/parser/resource'
9
9
 
10
- require 'puppet/util/methodhelper'
11
-
12
10
  # This class is part of the internal parser/evaluator/compiler functionality of Puppet.
13
11
  # It is passed between the various classes that participate in evaluation.
14
12
  # None of its methods are API except those that are clearly marked as such.
@@ -16,7 +14,6 @@ require 'puppet/util/methodhelper'
16
14
  # @api public
17
15
  class Puppet::Parser::Scope
18
16
  extend Forwardable
19
- include Puppet::Util::MethodHelper
20
17
 
21
18
  # Variables that always exist with nil value even if not set
22
19
  BUILT_IN_VARS = ['module_name'.freeze, 'caller_module_name'.freeze].freeze
@@ -374,14 +371,15 @@ class Puppet::Parser::Scope
374
371
  end
375
372
 
376
373
  # Initialize our new scope. Defaults to having no parent.
377
- def initialize(compiler, options = EMPTY_HASH)
374
+ def initialize(compiler, source: nil, resource: nil)
378
375
  if compiler.is_a? Puppet::Parser::AbstractCompiler
379
376
  @compiler = compiler
380
377
  else
381
378
  raise Puppet::DevError, _("you must pass a compiler instance to a new scope object")
382
379
  end
383
380
 
384
- set_options(options)
381
+ @source = source
382
+ @resource = resource
385
383
 
386
384
  extend_with_functions_module
387
385
 
@@ -875,8 +873,8 @@ class Puppet::Parser::Scope
875
873
  return "Scope(#{@resource})" unless @resource.nil?
876
874
 
877
875
  # For logging of function-scope - it is now showing the file and line.
878
- detail = Puppet::Pops::PuppetStack.stacktrace[0]
879
- return "Scope()" unless detail.is_a?(Array)
876
+ detail = Puppet::Pops::PuppetStack.top_of_stack
877
+ return "Scope()" if detail.empty?
880
878
 
881
879
  # shorten the path if possible
882
880
  path = detail[0]
@@ -23,7 +23,7 @@ class CompareOperator
23
23
  @@include_visitor ||= Visitor.new(self, "include", 2, 2)
24
24
  end
25
25
 
26
- def equals (a, b)
26
+ def equals(a, b)
27
27
  @@equals_visitor.visit_this_1(self, a, b)
28
28
  end
29
29
 
@@ -59,6 +59,8 @@ class CompareOperator
59
59
  def cmp_Numeric(a, b)
60
60
  if b.is_a?(Numeric)
61
61
  a <=> b
62
+ elsif b.is_a?(Time::Timespan) || b.is_a?(Time::Timestamp)
63
+ -(b <=> a) # compare other way and invert result
62
64
  else
63
65
  raise ArgumentError.new(_("A Numeric is not comparable to non Numeric"))
64
66
  end
@@ -55,13 +55,8 @@ module Runtime3Support
55
55
  #
56
56
  def runtime_issue(issue, options={})
57
57
  # Get position from puppet runtime stack
58
- stacktrace = Puppet::Pops::PuppetStack.stacktrace()
59
- if stacktrace.size > 0
60
- file, line = stacktrace[0]
61
- else
62
- file = nil
63
- line = nil
64
- end
58
+ file, line = Puppet::Pops::PuppetStack.top_of_stack
59
+
65
60
  # Use a SemanticError as the sourcepos
66
61
  semantic = Puppet::Pops::SemanticError.new(issue, nil, options.merge({:file => file, :line => line}))
67
62
  optionally_fail(issue, semantic)
@@ -486,6 +486,10 @@ module Issues
486
486
  _("Unacceptable name. The name '%{name}' is unacceptable as the name of %{value}") % { name: name, value: label.a_an(semantic) }
487
487
  end
488
488
 
489
+ ILLEGAL_DEFINITION_LOCATION = issue :ILLEGAL_DEFINITION_LOCATION, :name, :file do
490
+ _("Unacceptable location. The name '%{name}' is unacceptable in file '%{file}'") % { name: name, file: file }
491
+ end
492
+
489
493
  CAPTURES_REST_NOT_LAST = hard_issue :CAPTURES_REST_NOT_LAST, :param_name do
490
494
  _("Parameter $%{param} is not last, and has 'captures rest'") % { param: param_name }
491
495
  end
@@ -67,7 +67,7 @@ module LoaderPaths
67
67
  @generic_path = (the_root_path.nil? ? relative_path : File.join(the_root_path, relative_path))
68
68
  end
69
69
 
70
- def match_many?
70
+ def fuzzy_matching?
71
71
  false
72
72
  end
73
73
 
@@ -239,7 +239,7 @@ module LoaderPaths
239
239
  EMPTY_STRING
240
240
  end
241
241
 
242
- def match_many?
242
+ def fuzzy_matching?
243
243
  true
244
244
  end
245
245
 
@@ -291,13 +291,12 @@ module ModuleLoaders
291
291
  raise NotImplementedError.new
292
292
  end
293
293
 
294
- # Abstract method that subclasses override to return an array of paths that match the resolved path regardless of
295
- # path extension.
294
+ # Abstract method that subclasses override to return an array of paths that may be associated with the resolved path.
296
295
  #
297
296
  # @param resolved_path [String] a path, without extension, resolved by a smart path against the loader's root (if it has one)
298
297
  # @return [Array<String>]
299
298
  #
300
- def existing_paths(resolved_path)
299
+ def candidate_paths(resolved_path)
301
300
  raise NotImplementedError.new
302
301
  end
303
302
 
@@ -386,9 +385,9 @@ module ModuleLoaders
386
385
  next unless sp.valid_name?(typed_name)
387
386
  origin = sp.effective_path(typed_name, is_global ? 0 : 1)
388
387
  unless origin.nil?
389
- if sp.match_many?
390
- # Find all paths that starts with origin
391
- origins = existing_paths(origin)
388
+ if sp.fuzzy_matching?
389
+ # Find all paths that might be related to origin
390
+ origins = candidate_paths(origin)
392
391
  return [origins, sp] unless origins.empty?
393
392
  else
394
393
  existing = existing_path(origin)
@@ -424,13 +423,19 @@ module ModuleLoaders
424
423
  @path_index.include?(effective_path) ? effective_path : nil
425
424
  end
426
425
 
427
- def existing_paths(effective_path)
426
+ def candidate_paths(effective_path)
427
+ basename = File.basename(effective_path, '.*')
428
428
  dirname = File.dirname(effective_path)
429
- basename = File.basename(effective_path)
430
- # Select all paths matching `effective_path` up until an optional file extension
431
- @path_index.select do |path|
432
- File.basename(path, '.*') == basename &&
433
- File.dirname(path) == dirname
429
+
430
+ files = @path_index.select do |path|
431
+ File.dirname(path) == dirname
432
+ end
433
+
434
+ # At least one file has to match what we're loading, or it certainly doesn't exist
435
+ if files.any? { |file| File.basename(file, '.*') == basename }
436
+ files
437
+ else
438
+ []
434
439
  end
435
440
  end
436
441
 
@@ -3,66 +3,94 @@
3
3
  module Puppet::Pops
4
4
  module Loader
5
5
  class TaskInstantiator
6
- def self.create(loader, typed_name, source_refs)
7
- name = typed_name.name
8
- metadata = nil
9
- task_source = nil
10
- source_refs.each do |source_ref|
11
- if source_ref.end_with?('.json')
12
- metadata = source_ref
13
- elsif task_source.nil?
14
- task_source = source_ref
15
- else
16
- raise ArgumentError, _('Only one file can exists besides the .json file for task %{name} in directory %{directory}') %
17
- { name: name, directory: File.dirname(source_refs[0]) }
18
- end
19
- end
20
-
21
- if task_source.nil?
22
- raise ArgumentError, _('No source besides task metadata was found in directory %{directory} for task %{name}') %
23
- { name: name, directory: File.dirname(source_refs[0]) }
24
- end
25
- create_task(loader, name, task_source, metadata)
26
- end
27
-
28
- def self.create_task(loader, name, task_source, metadata)
6
+ def self.load_metadata(loader, metadata)
29
7
  if metadata.nil?
30
- create_task_from_hash(name, task_source, EMPTY_HASH)
8
+ EMPTY_HASH
31
9
  else
32
10
  json_text = loader.get_contents(metadata)
33
11
  begin
34
- create_task_from_hash(name, task_source, JSON.parse(json_text) || EMPTY_HASH)
35
- rescue JSON::ParserError => ex
12
+ Puppet::Util::Json.load(json_text).freeze || EMPTY_HASH
13
+ rescue Puppet::Util::Json::ParseError => ex
36
14
  raise Puppet::ParseError.new(ex.message, metadata)
37
- rescue Types::TypeAssertionError => ex
38
- # Not strictly a parser error but from the users perspective, the file content didn't parse properly. The
39
- # ParserError also conveys file info (even though line is unknown)
40
- msg = _('Failed to load metadata for task %{name}: %{reason}') % { :name => name, :reason => ex.message }
41
- raise Puppet::ParseError.new(msg, metadata)
42
15
  end
43
16
  end
44
17
  end
45
18
 
46
- def self.create_task_from_hash(name, task_source, hash)
19
+ def self.validate_implementations(typed_name, directory, metadata, executables)
20
+ name = typed_name.name
21
+ basename = typed_name.name_parts[1] || 'init'
22
+ # If 'implementations' is defined, it needs to mention at least one
23
+ # implementation, and everything it mentions must exist.
24
+ if metadata.key?('implementations')
25
+ if metadata['implementations'].is_a?(Array)
26
+ metadata['implementations'].map do |impl|
27
+ path = executables.find { |real_impl| File.basename(real_impl) == impl['name'] }
28
+ if path
29
+ { "name" => impl['name'], "requirements" => impl.fetch('requirements', []), "path" => path }
30
+ else
31
+ raise ArgumentError, _("Task metadata for task %{name} specifies missing implementation %{implementation}") %
32
+ { name: name, implementation: impl['name'] }
33
+ end
34
+ end
35
+ else
36
+ # If 'implementations' is the wrong type, we just pass it through and
37
+ # let the task type definition reject it.
38
+ metadata['implementations']
39
+ end
40
+ # If implementations isn't defined, then we use executables matching the
41
+ # task name, and only one may exist.
42
+ else
43
+ implementations = executables.select { |impl| File.basename(impl, '.*') == basename }
44
+ if implementations.empty?
45
+ raise ArgumentError, _('No source besides task metadata was found in directory %{directory} for task %{name}') %
46
+ { name: name, directory: directory }
47
+ elsif implementations.length > 1
48
+ raise ArgumentError, _("Multiple executables were found in directory %{directory} for task %{name}; define 'implementations' in metadata to differentiate between them") %
49
+ { name: name, directory: implementations[0] }
50
+ end
51
+
52
+ [{ "name" => File.basename(implementations.first), "path" => implementations.first, "requirements" => [] }]
53
+ end
54
+ end
55
+
56
+ def self.create(loader, typed_name, source_refs)
57
+ name = typed_name.name
58
+ basename = typed_name.name_parts[1] || 'init'
59
+ dirname = File.dirname(source_refs[0])
60
+ metadata_files, executables = source_refs.partition { |source_ref| source_ref.end_with?('.json') }
61
+ metadata_file = metadata_files.find { |source_ref| File.basename(source_ref, '.json') == basename }
62
+
63
+ metadata = load_metadata(loader, metadata_file)
64
+
65
+ implementation_metadata = validate_implementations(typed_name, dirname, metadata, executables)
66
+
47
67
  arguments = {
48
68
  'name' => name,
49
- 'executable' => task_source
69
+ 'implementations' => implementation_metadata
50
70
  }
51
- hash.each_pair do |key, value|
52
- if 'parameters' == key || 'output' == key
53
- ps = {}
54
- value.each_pair do |k, v|
55
- pd = v.dup
56
- t = v['type']
57
- pd['type'] = t.nil? ? Types::TypeFactory.data : Types::TypeParser.singleton.parse(t)
58
- ps[k] = pd
71
+
72
+ begin
73
+ metadata.each_pair do |key, value|
74
+ if %w[parameters output].include?(key)
75
+ ps = {}
76
+ value.each_pair do |k, v|
77
+ pd = v.dup
78
+ t = v['type']
79
+ pd['type'] = t.nil? ? Types::TypeFactory.data : Types::TypeParser.singleton.parse(t)
80
+ ps[k] = pd
81
+ end
82
+ value = ps
59
83
  end
60
- value = ps
84
+ arguments[key] = value unless arguments.key?(key)
61
85
  end
62
- arguments[key] = value
63
- end
64
86
 
65
- Types::TypeFactory.task.from_hash(arguments)
87
+ Types::TypeFactory.task.from_hash(arguments)
88
+ rescue Types::TypeAssertionError => ex
89
+ # Not strictly a parser error but from the users perspective, the file content didn't parse properly. The
90
+ # ParserError also conveys file info (even though line is unknown)
91
+ msg = _('Failed to load metadata for task %{name}: %{reason}') % { name: name, reason: ex.message }
92
+ raise Puppet::ParseError.new(msg, metadata_file)
93
+ end
66
94
  end
67
95
  end
68
96
  end