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
@@ -14,7 +14,7 @@ require 'hiera/puppet_function'
14
14
  # * If this argument isn't provided and this function results in a lookup failure, Puppet
15
15
  # fails with a compilation error.
16
16
  # 3. The optional name of an arbitrary
17
- # [hierarchy level](https://docs.puppetlabs.com/hiera/latest/hierarchy.html) to insert at the
17
+ # [hierarchy level](https://puppet.com/docs/hiera/latest/hierarchy.html) to insert at the
18
18
  # top of the hierarchy. This lets you temporarily modify the hierarchy for a single lookup.
19
19
  # * If Hiera doesn't find a matching key in the overriding hierarchy level, it continues
20
20
  # searching the rest of the hierarchy.
@@ -56,7 +56,7 @@ require 'hiera/puppet_function'
56
56
  # ```
57
57
  #
58
58
  # You can optionally generate the default value with a
59
- # [lambda](https://docs.puppetlabs.com/puppet/latest/reference/lang_lambdas.html) that
59
+ # [lambda](https://puppet.com/docs/puppet/latest/lang_lambdas.html) that
60
60
  # takes one parameter.
61
61
  #
62
62
  # @example Using `hiera` with a lambda
@@ -72,13 +72,13 @@ require 'hiera/puppet_function'
72
72
  # # "Key 'users' not found".
73
73
  # ```
74
74
  #
75
- # The returned value's data type depends on the types of the results. In the example
75
+ # The returned value's data type depends on the types of the results. In the example
76
76
  # above, Hiera matches the 'users' key and returns it as a hash.
77
77
  #
78
78
  # See
79
- # [the 'Using the lookup function' documentation](https://docs.puppet.com/puppet/latest/hiera_use_function.html) for how to perform lookup of data.
79
+ # [the 'Using the lookup function' documentation](https://puppet.com/docs/puppet/latest/hiera_automatic.html) for how to perform lookup of data.
80
80
  # Also see
81
- # [the 'Using the deprecated hiera functions' documentation](https://docs.puppet.com/puppet/latest/hiera_use_hiera_functions.html)
81
+ # [the 'Using the deprecated hiera functions' documentation](https://puppet.com/docs/puppet/latest/hiera_automatic.html)
82
82
  # for more information about the Hiera 3 functions.
83
83
  #
84
84
  # @since 4.0.0
@@ -3,7 +3,7 @@ require 'hiera/puppet_function'
3
3
  # Finds all matches of a key throughout the hierarchy and returns them as a single flattened
4
4
  # array of unique values. If any of the matched values are arrays, they're flattened and
5
5
  # included in the results. This is called an
6
- # [array merge lookup](https://docs.puppetlabs.com/hiera/latest/lookup_types.html#array-merge).
6
+ # [array merge lookup](https://puppet.com/docs/hiera/latest/lookup_types.html#array-merge).
7
7
  #
8
8
  # This function is deprecated in favor of the `lookup` function. While this function
9
9
  # continues to work, it does **not** support:
@@ -17,7 +17,7 @@ require 'hiera/puppet_function'
17
17
  # * If this argument isn't provided and this function results in a lookup failure, Puppet
18
18
  # fails with a compilation error.
19
19
  # 3. The optional name of an arbitrary
20
- # [hierarchy level](https://docs.puppetlabs.com/hiera/latest/hierarchy.html) to insert at the
20
+ # [hierarchy level](https://puppet.com/docs/hiera/latest/hierarchy.html) to insert at the
21
21
  # top of the hierarchy. This lets you temporarily modify the hierarchy for a single lookup.
22
22
  # * If Hiera doesn't find a matching key in the overriding hierarchy level, it continues
23
23
  # searching the rest of the hierarchy.
@@ -46,7 +46,7 @@ require 'hiera/puppet_function'
46
46
  # ```
47
47
  #
48
48
  # You can optionally generate the default value with a
49
- # [lambda](https://docs.puppetlabs.com/puppet/latest/reference/lang_lambdas.html) that
49
+ # [lambda](https://puppet.com/docs/puppet/latest/lang_lambdas.html) that
50
50
  # takes one parameter.
51
51
  #
52
52
  # @example Using `hiera_array` with a lambda
@@ -65,9 +65,9 @@ require 'hiera/puppet_function'
65
65
  # value is a hash, Puppet raises a type mismatch error.
66
66
  #
67
67
  # See
68
- # [the 'Using the lookup function' documentation](https://docs.puppet.com/puppet/latest/hiera_use_function.html) for how to perform lookup of data.
68
+ # [the 'Using the lookup function' documentation](https://puppet.com/docs/puppet/latest/hiera_automatic.html) for how to perform lookup of data.
69
69
  # Also see
70
- # [the 'Using the deprecated hiera functions' documentation](https://docs.puppet.com/puppet/latest/hiera_use_hiera_functions.html)
70
+ # [the 'Using the deprecated hiera functions' documentation](https://puppet.com/docs/puppet/latest/hiera_automatic.html)
71
71
  # for more information about the Hiera 3 functions.
72
72
  #
73
73
  # @since 4.0.0
@@ -9,10 +9,10 @@ require 'hiera/puppet_function'
9
9
  #
10
10
  # If any of the matched hashes share keys, the final hash uses the value from the
11
11
  # highest priority match. This is called a
12
- # [hash merge lookup](https://docs.puppetlabs.com/hiera/latest/lookup_types.html#hash-merge).
12
+ # [hash merge lookup](https://puppet.com/docs/hiera/latest/lookup_types.html#hash-merge).
13
13
  #
14
14
  # The merge strategy is determined by Hiera's
15
- # [`:merge_behavior`](https://docs.puppetlabs.com/hiera/latest/configuring.html#mergebehavior)
15
+ # [`:merge_behavior`](https://puppet.com/docs/hiera/latest/configuring.html#mergebehavior)
16
16
  # setting.
17
17
  #
18
18
  # The `hiera_hash` function takes up to three arguments, in this order:
@@ -22,7 +22,7 @@ require 'hiera/puppet_function'
22
22
  # * If this argument isn't provided and this function results in a lookup failure, Puppet
23
23
  # fails with a compilation error.
24
24
  # 3. The optional name of an arbitrary
25
- # [hierarchy level](https://docs.puppetlabs.com/hiera/latest/hierarchy.html) to insert at the
25
+ # [hierarchy level](https://puppet.com/docs/hiera/latest/hierarchy.html) to insert at the
26
26
  # top of the hierarchy. This lets you temporarily modify the hierarchy for a single lookup.
27
27
  # * If Hiera doesn't find a matching key in the overriding hierarchy level, it continues
28
28
  # searching the rest of the hierarchy.
@@ -56,7 +56,7 @@ require 'hiera/puppet_function'
56
56
  # ```
57
57
  #
58
58
  # You can optionally generate the default value with a
59
- # [lambda](https://docs.puppetlabs.com/puppet/latest/reference/lang_lambdas.html) that
59
+ # [lambda](https://puppet.com/docs/puppet/latest/lang_lambdas.html) that
60
60
  # takes one parameter.
61
61
  #
62
62
  # @example Using `hiera_hash` with a lambda
@@ -76,9 +76,9 @@ require 'hiera/puppet_function'
76
76
  # found in the data sources are strings or arrays, Puppet raises a type mismatch error.
77
77
  #
78
78
  # See
79
- # [the 'Using the lookup function' documentation](https://docs.puppet.com/puppet/latest/hiera_use_function.html) for how to perform lookup of data.
79
+ # [the 'Using the lookup function' documentation](https://puppet.com/docs/puppet/latest/hiera_automatic.html) for how to perform lookup of data.
80
80
  # Also see
81
- # [the 'Using the deprecated hiera functions' documentation](https://docs.puppet.com/puppet/latest/hiera_use_hiera_functions.html)
81
+ # [the 'Using the deprecated hiera functions' documentation](https://puppet.com/docs/puppet/latest/hiera_automatic.html)
82
82
  # for more information about the Hiera 3 functions.
83
83
  #
84
84
  # @since 4.0.0
@@ -1,7 +1,7 @@
1
1
  require 'hiera/puppet_function'
2
2
 
3
3
  # Assigns classes to a node using an
4
- # [array merge lookup](https://docs.puppetlabs.com/hiera/latest/lookup_types.html#array-merge)
4
+ # [array merge lookup](https://puppet.com/docs/hiera/latest/lookup_types.html#array-merge)
5
5
  # that retrieves the value for a user-specified key from Hiera's data.
6
6
  #
7
7
  # This function is deprecated in favor of the `lookup` function in combination with `include`.
@@ -10,7 +10,7 @@ require 'hiera/puppet_function'
10
10
  # * lookup across global, environment, and module layers
11
11
  #
12
12
  # @example Using `lookup` and `include` instead of of the deprecated `hiera_include`
13
- #
13
+ #
14
14
  # ```puppet
15
15
  # # In site.pp, outside of any node definitions and below any top-scope variables:
16
16
  # lookup('classes', Array[String], 'unique').include
@@ -32,13 +32,13 @@ require 'hiera/puppet_function'
32
32
  # * If this argument isn't provided and this function results in a lookup failure, Puppet
33
33
  # fails with a compilation error.
34
34
  # 3. The optional name of an arbitrary
35
- # [hierarchy level](https://docs.puppetlabs.com/hiera/latest/hierarchy.html) to insert at the
35
+ # [hierarchy level](https://puppet.com/docs/hiera/latest/hierarchy.html) to insert at the
36
36
  # top of the hierarchy. This lets you temporarily modify the hierarchy for a single lookup.
37
37
  # * If Hiera doesn't find a matching key in the overriding hierarchy level, it continues
38
38
  # searching the rest of the hierarchy.
39
39
  #
40
40
  # The function uses an
41
- # [array merge lookup](https://docs.puppetlabs.com/hiera/latest/lookup_types.html#array-merge)
41
+ # [array merge lookup](https://puppet.com/docs/hiera/latest/lookup_types.html#array-merge)
42
42
  # to retrieve the `classes` array, so every node gets every class from the hierarchy.
43
43
  #
44
44
  # @example Using `hiera_include`
@@ -66,7 +66,7 @@ require 'hiera/puppet_function'
66
66
  # ```
67
67
  #
68
68
  # You can optionally generate the default value with a
69
- # [lambda](https://docs.puppetlabs.com/puppet/latest/reference/lang_lambdas.html) that
69
+ # [lambda](https://puppet.com/docs/puppet/latest/lang_lambdas.html) that
70
70
  # takes one parameter.
71
71
  #
72
72
  # @example Using `hiera_include` with a lambda
@@ -83,9 +83,9 @@ require 'hiera/puppet_function'
83
83
  # ```
84
84
  #
85
85
  # See
86
- # [the 'Using the lookup function' documentation](https://docs.puppet.com/puppet/latest/hiera_use_function.html) for how to perform lookup of data.
86
+ # [the 'Using the lookup function' documentation](https://puppet.com/docs/puppet/latest/hiera_automatic.html) for how to perform lookup of data.
87
87
  # Also see
88
- # [the 'Using the deprecated hiera functions' documentation](https://docs.puppet.com/puppet/latest/hiera_use_hiera_functions.html)
88
+ # [the 'Using the deprecated hiera functions' documentation](https://puppet.com/docs/puppet/latest/hiera_automatic.html)
89
89
  # for more information about the Hiera 3 functions.
90
90
  #
91
91
  # @since 4.0.0
@@ -1,5 +1,5 @@
1
1
  # The `hocon_data` is a hiera 5 `data_hash` data provider function.
2
- # See [the configuration guide documentation](https://docs.puppet.com/puppet/latest/hiera_config_yaml_5.html#configuring-a-hierarchy-level-built-in-backends) for
2
+ # See [the configuration guide documentation](https://puppet.com/docs/puppet/latest/hiera_config_yaml_5.html#configuring-a-hierarchy-level-built-in-backends) for
3
3
  # how to use this function.
4
4
  #
5
5
  # Note that this function is not supported without a hocon library being present.
@@ -1,5 +1,5 @@
1
1
  # The `json_data` is a hiera 5 `data_hash` data provider function.
2
- # See [the configuration guide documentation](https://docs.puppet.com/puppet/latest/hiera_config_yaml_5.html#configuring-a-hierarchy-level-built-in-backends) for
2
+ # See [the configuration guide documentation](https://puppet.com/docs/puppet/latest/hiera_config_yaml_5.html#configuring-a-hierarchy-level-built-in-backends) for
3
3
  # how to use this function.
4
4
  #
5
5
  # @since 4.8.0
@@ -19,8 +19,8 @@ Puppet::Functions.create_function(:json_data) do
19
19
  path = options['path']
20
20
  context.cached_file_data(path) do |content|
21
21
  begin
22
- JSON.parse(content)
23
- rescue JSON::ParserError => ex
22
+ Puppet::Util::Json.load(content)
23
+ rescue Puppet::Util::Json::ParseError => ex
24
24
  # Filename not included in message, so we add it here.
25
25
  raise Puppet::DataBinding::LookupError, "Unable to parse (%{path}): %{message}" % { path: path, message: ex.message }
26
26
  end
@@ -1,4 +1,4 @@
1
- # Calls a [lambda](https://docs.puppet.com/puppet/latest/reference/lang_lambdas.html)
1
+ # Calls a [lambda](https://puppet.com/docs/puppet/latest/lang_lambdas.html)
2
2
  # without arguments if the value given to `lest` is `undef`.
3
3
  # Returns the result of calling the lambda if the argument is `undef`, otherwise the
4
4
  # given argument.
@@ -29,7 +29,7 @@
29
29
  # first key, it will try again with the subsequent ones, only resorting to a
30
30
  # default value if none of them succeed.
31
31
  # 2. `<VALUE TYPE>` (data type) --- A
32
- # [data type](https://docs.puppetlabs.com/puppet/latest/reference/lang_data_type.html)
32
+ # [data type](https://puppet.com/docs/puppet/latest/lang_data_type.html)
33
33
  # that must match the retrieved value; if not, the lookup (and catalog
34
34
  # compilation) will fail. Defaults to `Data` (accepts any normal value).
35
35
  # 3. `<MERGE BEHAVIOR>` (string or hash; see **"Merge Behaviors"** below) ---
@@ -207,7 +207,8 @@ Puppet::Functions.create_function(:lookup, Puppet::Functions::InternalFunction)
207
207
  end
208
208
 
209
209
  def do_lookup(scope, name, value_type, default_value, has_default, override, default_values_hash, merge, &block)
210
- Puppet::Pops::Lookup.lookup(name, value_type, default_value, has_default, merge, Puppet::Pops::Lookup::Invocation.new(scope, override, default_values_hash), &block)
210
+ Puppet::Pops::Lookup.lookup(name, value_type, default_value, has_default, merge,
211
+ Puppet::Pops::Lookup::Invocation.new(scope, override, default_values_hash), &block)
211
212
  end
212
213
 
213
214
  def hash_args(options_hash)
@@ -0,0 +1,58 @@
1
+ # Strips leading spaces from a String
2
+ #
3
+ # This function is compatible with the stdlib function with the same name.
4
+ #
5
+ # The function does the following:
6
+ # * For a `String` the conversion removes all leading ASCII white space characters such as space, tab, newline, and return.
7
+ # It does not remove other space-like characters like hard space (Unicode U+00A0). (Tip, `/^[[:space:]]/` regular expression
8
+ # matches all space-like characters).
9
+ # * For an `Iterable[Variant[String, Numeric]]` (for example an `Array`) each value is processed and the conversion is not recursive.
10
+ # * If the value is `Numeric` it is simply returned (this is for backwards compatibility).
11
+ # * An error is raised for all other data types.
12
+ #
13
+ # @example Removing leading space from a String
14
+ # ```puppet
15
+ # "\n\thello".lstrip()
16
+ # camelcase("\n\thello")
17
+ # ```
18
+ # Would both result in `"hello"`
19
+ #
20
+ # @example Removing leading space from strings in an Array
21
+ # ```puppet
22
+ # ["\n\thello", "\n\thi"].lstrip()
23
+ # lstrip(["\n\thello", "\n\thi"])
24
+ # ```
25
+ # Would both result in `['hello', 'hi']`
26
+ #
27
+ Puppet::Functions.create_function(:lstrip) do
28
+
29
+ dispatch :on_numeric do
30
+ param 'Numeric', :arg
31
+ end
32
+
33
+ dispatch :on_string do
34
+ param 'String', :arg
35
+ end
36
+
37
+ dispatch :on_iterable do
38
+ param 'Iterable[Variant[String, Numeric]]', :arg
39
+ end
40
+
41
+ # unit function - since the old implementation skipped Numeric values
42
+ def on_numeric(n)
43
+ n
44
+ end
45
+
46
+ def on_string(s)
47
+ s.lstrip
48
+ end
49
+
50
+ def on_iterable(a)
51
+ a.map {|x| do_lstrip(x) }
52
+ end
53
+
54
+ def do_lstrip(x)
55
+ # x can only be a String or Numeric because type constraints have been automatically applied
56
+ x.is_a?(String) ? x.lstrip : x
57
+ end
58
+ end
@@ -1,4 +1,4 @@
1
- # Applies a [lambda](https://docs.puppetlabs.com/puppet/latest/reference/lang_lambdas.html)
1
+ # Applies a [lambda](https://puppet.com/docs/puppet/latest/lang_lambdas.html)
2
2
  # to every value in a data structure and returns an array containing the results.
3
3
  #
4
4
  # This function takes two mandatory arguments, in this order:
@@ -90,6 +90,17 @@ Puppet::Functions.create_function(:match) do
90
90
  do_match(s, regexp)
91
91
  end
92
92
 
93
+ def match_PTypeAliasType(alias_t, s)
94
+ match(s, alias_t.resolved_type)
95
+ end
96
+
97
+ def match_PVariantType(var_t, s)
98
+ # Find first matching type (or error out if one of the variants is not acceptable)
99
+ result = nil
100
+ var_t.types.find {|t| result = match(s, t) }
101
+ result
102
+ end
103
+
93
104
  def match_PRegexpType(regexp_t, s)
94
105
  raise ArgumentError, _("Given Regexp Type has no regular expression") unless regexp_t.pattern
95
106
  do_match(s, regexp_t.regexp)
@@ -0,0 +1,183 @@
1
+ # Returns the highest value among a variable number of arguments.
2
+ # Takes at least one argument.
3
+ #
4
+ # This function is (with one exception) compatible with the stdlib function
5
+ # with the same name and performs deprecated type conversion before
6
+ # comparison as follows:
7
+ #
8
+ # * If a value converted to String is an optionally '-' prefixed,
9
+ # string of digits, one optional decimal point, followed by optional
10
+ # decimal digits - then the comparison is performed on the values
11
+ # converted to floating point.
12
+ # * If a value is not considered convertible to float, it is converted
13
+ # to a `String` and the comparison is a lexical compare where min is
14
+ # the lexicographical later value.
15
+ # * A lexicographical compare is performed in a system locale - international
16
+ # characters may therefore not appear in what a user thinks is the correct order.
17
+ # * The conversion rules apply to values in pairs - the rule must hold for both
18
+ # values - a value may therefore be compared using different rules depending
19
+ # on the "other value".
20
+ # * The returned result found to be the "highest" is the original unconverted value.
21
+ #
22
+ # The above rules have been deprecated in Puppet 6.0.0 as they produce strange results when
23
+ # given values of mixed data types. In general, either convert values to be
24
+ # all `String` or all `Numeric` values before calling the function, or call the
25
+ # function with a lambda that performs type conversion and comparison. This because one
26
+ # simply cannot compare `Boolean` with `Regexp` and with any arbitrary `Array`, `Hash` or
27
+ # `Object` and getting a meaningful result.
28
+ #
29
+ # The one change in the function's behavior is when the function is given a single
30
+ # array argument. The stdlib implementation would return that array as the result where
31
+ # it now instead returns the max value from that array.
32
+ #
33
+ # @example 'max of values - stdlib compatible'
34
+ #
35
+ # ```puppet
36
+ # notice(max(1)) # would notice 1
37
+ # notice(max(1,2)) # would notice 2
38
+ # notice(max("1", 2)) # would notice 2
39
+ # notice(max("0777", 512)) # would notice "0777", since "0777" is not converted from octal form
40
+ # notice(max(0777, 512)) # would notice 512, since 0777 is decimal 511
41
+ # notice(max('aa', 'ab')) # would notice 'ab'
42
+ # notice(max(['a'], ['b'])) # would notice ['b'], since "['b']" is after "['a']"
43
+ # ```
44
+ #
45
+ # @example find 'max' value in an array - stdlib compatible
46
+ #
47
+ # ```puppet
48
+ # $x = [1,2,3,4]
49
+ # notice(max(*$x)) # would notice 4
50
+ # ```
51
+ #
52
+ # @example find 'max' value in an array directly - since Puppet 6.0.0
53
+ #
54
+ # ```puppet
55
+ # $x = [1,2,3,4]
56
+ # notice(max($x)) # would notice 4
57
+ # notice($x.max) # would notice 4
58
+ # ```
59
+ # This example shows that a single array argument is used as the set of values
60
+ # as opposed to being a single returned value.
61
+ #
62
+ # When calling with a lambda, it must accept two variables and it must return
63
+ # one of -1, 0, or 1 depending on if first argument is before/lower than, equal to,
64
+ # or higher/after the second argument.
65
+ #
66
+ # @example 'max of values using a lambda - since Puppet 6.0.0'
67
+ #
68
+ # ```puppet
69
+ # notice(max("2", "10", "100") |$a, $b| { compare($a, $b) })
70
+ # ```
71
+ #
72
+ # Would notice "2" as higher since it is lexicographically higher/after the other values. Without the
73
+ # lambda the stdlib compatible (deprecated) behavior would have been to return "100" since number conversion
74
+ # kicks in.
75
+ #
76
+ Puppet::Functions.create_function(:max) do
77
+ dispatch :on_numeric do
78
+ repeated_param 'Numeric', :values
79
+ end
80
+
81
+ dispatch :on_string do
82
+ repeated_param 'String', :values
83
+ end
84
+
85
+ dispatch :on_single_numeric_array do
86
+ param 'Array[Numeric]', :values
87
+ optional_block_param 'Callable[2,2]', :block
88
+ end
89
+
90
+ dispatch :on_single_string_array do
91
+ param 'Array[String]', :values
92
+ optional_block_param 'Callable[2,2]', :block
93
+ end
94
+
95
+ dispatch :on_single_any_array do
96
+ param 'Array', :values
97
+ optional_block_param 'Callable[2,2]', :block
98
+ end
99
+
100
+ dispatch :on_any_with_block do
101
+ repeated_param 'Any', :values
102
+ block_param 'Callable[2,2]', :block
103
+ end
104
+
105
+ dispatch :on_any do
106
+ repeated_param 'Any', :values
107
+ end
108
+
109
+
110
+ # All are Numeric - ok now, will be ok later
111
+ def on_numeric(*args)
112
+ assert_arg_count(args)
113
+ args.max
114
+ end
115
+
116
+ # All are String, may convert to numeric (which is deprecated)
117
+ def on_string(*args)
118
+ assert_arg_count(args)
119
+
120
+ args.max do|a,b|
121
+ if a.to_s =~ %r{\A^-?\d+([._eE]\d+)?\z} && b.to_s =~ %r{\A-?\d+([._eE]\d+)?\z}
122
+ Puppet.warn_once('deprecations', 'max_function_numeric_coerce_string',
123
+ _("The max() function's auto conversion of String to Numeric is deprecated - change to convert input before calling, or use lambda"))
124
+ a.to_f <=> b.to_f
125
+ else
126
+ # case sensitive as in the stdlib function
127
+ a <=> b
128
+ end
129
+ end
130
+ end
131
+
132
+ def on_any_with_block(*args, &block)
133
+ args.max {|x,y| block.call(x,y) }
134
+ end
135
+
136
+ def on_single_numeric_array(array, &block)
137
+ if block_given?
138
+ on_any_with_block(*array, &block)
139
+ else
140
+ on_numeric(*array)
141
+ end
142
+ end
143
+
144
+ def on_single_string_array(array, &block)
145
+ if block_given?
146
+ on_any_with_block(*array, &block)
147
+ else
148
+ on_string(*array)
149
+ end
150
+ end
151
+
152
+ def on_single_any_array(array, &block)
153
+ if block_given?
154
+ on_any_with_block(*array, &block)
155
+ else
156
+ on_any(*array)
157
+ end
158
+ end
159
+
160
+ # Mix of data types - while only some compares are actually bad it will deprecate
161
+ # the entire call
162
+ #
163
+ def on_any(*args)
164
+ assert_arg_count(args)
165
+ args.max do |a, b|
166
+ as = a.to_s
167
+ bs = b.to_s
168
+ if as =~ %r{\A^-?\d+([._eE]\d+)?\z} && bs =~ %r{\A-?\d+([._eE]\d+)?\z}
169
+ Puppet.warn_once('deprecations', 'max_function_numeric_coerce_string',
170
+ _("The max() function's auto conversion of String to Numeric is deprecated - change to convert input before calling, or use lambda"))
171
+ a.to_f <=> b.to_f
172
+ else
173
+ Puppet.warn_once('deprecations', 'max_function_string_coerce_any',
174
+ _("The max() function's auto conversion of Any to String is deprecated - change to convert input before calling, or use lambda"))
175
+ as <=> bs
176
+ end
177
+ end
178
+ end
179
+
180
+ def assert_arg_count(args)
181
+ raise(ArgumentError, 'max(): Wrong number of arguments need at least one') if args.empty?
182
+ end
183
+ end