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
@@ -16,6 +16,8 @@ class LookupAdapter < DataAdapter
16
16
 
17
17
  HASH = 'hash'.freeze
18
18
  MERGE = 'merge'.freeze
19
+ CONVERT_TO = 'convert_to'.freeze
20
+ NEW = 'new'.freeze
19
21
 
20
22
  def self.create_adapter(compiler)
21
23
  new(compiler)
@@ -52,18 +54,65 @@ class LookupAdapter < DataAdapter
52
54
  catch(:no_such_key) { do_lookup(LookupKey::LOOKUP_OPTIONS, lookup_invocation, HASH) }
53
55
  nil
54
56
  else
57
+ lookup_options = lookup_lookup_options(key, lookup_invocation) || {}
58
+
55
59
  if merge.nil?
56
60
  # Used cached lookup_options
57
- merge = lookup_merge_options(key, lookup_invocation)
61
+ # merge = lookup_merge_options(key, lookup_invocation)
62
+ merge = lookup_options[MERGE]
58
63
  lookup_invocation.report_merge_source(LOOKUP_OPTIONS) unless merge.nil?
59
64
  end
60
- lookup_invocation.with(:data, key.to_s) do
61
- catch(:no_such_key) { return do_lookup(key, lookup_invocation, merge) }
62
- throw :no_such_key if lookup_invocation.global_only?
63
- key.dig(lookup_invocation, lookup_default_in_module(key, lookup_invocation))
64
- end
65
+ convert_result(key.to_s, lookup_options, lookup_invocation, lambda do
66
+ lookup_invocation.with(:data, key.to_s) do
67
+ catch(:no_such_key) { return do_lookup(key, lookup_invocation, merge) }
68
+ throw :no_such_key if lookup_invocation.global_only?
69
+ key.dig(lookup_invocation, lookup_default_in_module(key, lookup_invocation))
70
+ end
71
+ end)
72
+ end
73
+ end
74
+ end
75
+
76
+ # Performs a possible conversion of the result of calling `the_lookup` lambda
77
+ # The conversion takes place if there is a 'convert_to' key in the lookup_options
78
+ # If there is no conversion, the result of calling `the_lookup` is returned
79
+ # otherwise the successfully converted value.
80
+ # Errors are raised if the convert_to is faulty (bad type string, or if a call to
81
+ # new(T, <args>) fails.
82
+ #
83
+ # @param key [String] The key to lookup
84
+ # @param lookup_options [Hash] a hash of options
85
+ # @param lookup_invocation [Invocation] the lookup invocation
86
+ # @param the_lookup [Lambda] zero arg lambda that performs the lookup of a value
87
+ # @return [Object] the looked up value, or converted value if there was conversion
88
+ # @throw :no_such_key when the object is not found (if thrown by `the_lookup`)
89
+ #
90
+ def convert_result(key, lookup_options, lookup_invocation, the_lookup)
91
+ result = the_lookup.call
92
+ convert_to = lookup_options[CONVERT_TO]
93
+ return result if convert_to.nil?
94
+
95
+ convert_to = convert_to.is_a?(Array) ? convert_to : [convert_to]
96
+ if convert_to[0].is_a?(String)
97
+ begin
98
+ convert_to[0] = Puppet::Pops::Types::TypeParser.singleton.parse(convert_to[0])
99
+ rescue StandardError => e
100
+ raise Puppet::DataBinding::LookupError,
101
+ _("Invalid data type in lookup_options for key '%{key}' could not parse '%{source}', error: '%{msg}") %
102
+ { key: key, source: convert_to[0], msg: e.message}
65
103
  end
66
104
  end
105
+ begin
106
+ result = lookup_invocation.scope.call_function(NEW, [convert_to[0], result, *convert_to[1..-1]])
107
+ # TRANSLATORS 'lookup_options', 'convert_to' and args_string variable should not be translated,
108
+ args_string = Puppet::Pops::Types::StringConverter.singleton.convert(convert_to)
109
+ lookup_invocation.report_text { _("Applying convert_to lookup_option with arguments %{args}") % { args: args_string } }
110
+ rescue StandardError => e
111
+ raise Puppet::DataBinding::LookupError,
112
+ _("The convert_to lookup_option for key '%{key}' raised error: %{msg}") %
113
+ { key: key, msg: e.message}
114
+ end
115
+ result
67
116
  end
68
117
 
69
118
  def lookup_global(key, lookup_invocation, merge_strategy)
@@ -104,6 +104,8 @@ class ModelLabelProvider
104
104
  def label_Sensitive o ; "Sensitive" end
105
105
  def label_Timestamp o ; "Timestamp" end
106
106
  def label_Timespan o ; "Timespan" end
107
+ def label_Version o ; "Semver" end
108
+ def label_VersionRange o ; "SemverRange" end
107
109
 
108
110
  def label_PResourceType o
109
111
  if o.title
@@ -6,7 +6,7 @@ class Puppet::Pops::Parser::EppParser < Puppet::Pops::Parser::Parser
6
6
  # @return [void]
7
7
  #
8
8
  def initvars
9
- self.lexer = Puppet::Pops::Parser::Lexer2.new()# {:mode => :epp})
9
+ self.lexer = Puppet::Pops::Parser::Lexer2.new()
10
10
  end
11
11
 
12
12
  # Parses a file expected to contain epp text/DSL logic.
@@ -229,6 +229,7 @@ module EppSupport
229
229
 
230
230
  when "#"
231
231
  # template comment
232
+
232
233
  # drop the scanned <%, and skip past -%>, or %>, but also skip %%>
233
234
  s.slice!(-2..-1)
234
235
 
@@ -240,8 +241,11 @@ module EppSupport
240
241
  @mode = :error
241
242
  return s
242
243
  end
243
- # Always trim leading whitespace on the same line when there is a comment
244
- s.sub!(/[ \t]*\z/, '')
244
+ # Trim leading whitespace on the same line when start was <%#-
245
+ if part[1] == '-'
246
+ s.sub!(/[ \t]*\z/, '')
247
+ end
248
+
245
249
  @skip_leading = true if part.end_with?("-%>")
246
250
  # Continue scanning for more text
247
251
 
@@ -647,7 +647,7 @@ class Lexer2
647
647
  #
648
648
  def lex_file(file)
649
649
  initvars
650
- contents = Puppet::FileSystem.exist?(file) ? Puppet::FileSystem.read(file, :encoding => 'utf-8') : ''
650
+ contents = Puppet::FileSystem.exist?(file) ? Puppet::FileSystem.read(file, :mode => 'rb', :encoding => 'utf-8') : ''
651
651
  assert_not_bom(contents)
652
652
  @scanner = StringScanner.new(contents.freeze)
653
653
  @locator = Locator.locator(contents, file)
@@ -35,20 +35,20 @@ module Pcore
35
35
  if Puppet[:tasks]
36
36
  add_object_type('Task', <<-PUPPET, loader)
37
37
  {
38
- attributes => {
38
+ attributes => {
39
39
  # Fully qualified name of the task
40
40
  name => { type => Pattern[/\\A[a-z][a-z0-9_]*(?:::[a-z][a-z0-9_]*)*\\z/] },
41
41
 
42
- # Full path to executable
43
- executable => { type => String },
42
+ # List of implementations with requirements
43
+ implementations => { type => Array[Struct[name => String, path => String, Optional[requirements] => Array[String]], 1] },
44
44
 
45
45
  # Task description
46
46
  description => { type => Optional[String], value => undef },
47
47
 
48
48
  # Puppet Task version
49
49
  puppet_task_version => { type => Integer, value => 1 },
50
-
51
- # Type, description, and sensitive property of each parameter
50
+
51
+ # Type, description, and sensitive property of each parameter
52
52
  parameters => {
53
53
  type => Optional[Hash[
54
54
  Pattern[/\\A[a-z][a-z0-9_]*\\z/],
@@ -59,7 +59,7 @@ module Pcore
59
59
  value => undef
60
60
  },
61
61
 
62
- # Type, description, and sensitive property of each output
62
+ # Type, description, and sensitive property of each output
63
63
  output => {
64
64
  type => Optional[Hash[
65
65
  Pattern[/\\A[a-z][a-z0-9_]*\\z/],
@@ -69,7 +69,7 @@ module Pcore
69
69
  type => Type]]],
70
70
  value => undef
71
71
  },
72
-
72
+
73
73
  supports_noop => { type => Boolean, value => false },
74
74
  input_method => { type => String, value => 'both' },
75
75
  }
@@ -17,6 +17,9 @@ module Puppet::Pops
17
17
  # will be represented with the text `unknown` and `0´ respectively.
18
18
  #
19
19
  module PuppetStack
20
+ # Pattern matching an entry in the ruby stack that is a puppet entry
21
+ PP_ENTRY_PATTERN = /^(.*\.pp)?:([0-9]+):in (`stack'|`block in call_function')/
22
+
20
23
  # Sends a message to an obj such that it appears to come from
21
24
  # file, line when calling stacktrace.
22
25
  #
@@ -33,11 +36,22 @@ module PuppetStack
33
36
 
34
37
  def self.stacktrace
35
38
  caller().reduce([]) do |memo, loc|
36
- if loc =~ /^(.*\.pp)?:([0-9]+):in (`stack'|`block in call_function')/
39
+ if loc =~ PP_ENTRY_PATTERN
37
40
  memo << [$1.nil? ? 'unknown' : $1, $2.to_i]
38
41
  end
39
42
  memo
40
43
  end
41
44
  end
45
+
46
+ # Returns an Array with the top of the puppet stack, or an empty Array if there was no such entry.
47
+ #
48
+ def self.top_of_stack
49
+ caller.each do |loc|
50
+ if loc =~ PP_ENTRY_PATTERN
51
+ return [$1.nil? ? 'unknown' : $1, $2.to_i]
52
+ end
53
+ end
54
+ []
55
+ end
42
56
  end
43
57
  end
@@ -7,12 +7,12 @@ module Serialization
7
7
  class SerializationError < Puppet::Error
8
8
  end
9
9
 
10
- PCORE_TYPE_KEY = '__pcore_type__'.freeze
10
+ PCORE_TYPE_KEY = '__ptype'.freeze
11
11
 
12
12
  # Key used when the value can be represented as, and recreated from, a single string that can
13
13
  # be passed to a `from_string` method or an array of values that can be passed to the default
14
14
  # initializer method.
15
- PCORE_VALUE_KEY = '__pcore_value__'.freeze
15
+ PCORE_VALUE_KEY = '__pvalue'.freeze
16
16
 
17
17
  # Type key used for hashes that contain keys that are not of type String
18
18
  PCORE_TYPE_HASH = 'Hash'.freeze
@@ -64,7 +64,7 @@ module Serialization
64
64
  # @option options [Loaders::Loader] :loader the loader to use. Can be `nil` in which case the default is
65
65
  # determined by the {Types::TypeParser}.
66
66
  # @option options [Boolean] :allow_unresolved `true` to allow that rich_data hashes are kept "as is" if the
67
- # designated '__pcore_type__' cannot be resolved. Defaults to `false`.
67
+ # designated '__ptype' cannot be resolved. Defaults to `false`.
68
68
  # @return [RichData] the processed result.
69
69
  #
70
70
  # @api public
@@ -78,7 +78,7 @@ module Serialization
78
78
  # @option options [Loaders::Loader] :loader the loader to use. Can be `nil` in which case the default is
79
79
  # determined by the {Types::TypeParser}.
80
80
  # @option options [Boolean] :allow_unresolved `true` to allow that rich_data hashes are kept "as is" if the
81
- # designated '__pcore_type__' cannot be resolved. Defaults to `false`.
81
+ # designated '__ptype' cannot be resolved. Defaults to `false`.
82
82
  #
83
83
  # @api public
84
84
  def initialize(options = EMPTY_HASH)
@@ -1,4 +1,4 @@
1
- require 'json'
1
+ require 'puppet/util/json'
2
2
 
3
3
  module Puppet::Pops
4
4
  module Serialization
@@ -146,12 +146,12 @@ module JSON
146
146
  end
147
147
 
148
148
  def to_a
149
- ::JSON.parse(io_string)
149
+ ::Puppet::Util::Json.load(io_string)
150
150
  end
151
151
 
152
152
  def to_json
153
153
  if @indent > 0
154
- ::JSON.pretty_unparse(to_a, { :indent => ' ' * @indent })
154
+ ::Puppet::Util::Json.dump(to_a, { :pretty => true, :indent => ' ' * @indent })
155
155
  else
156
156
  io_string
157
157
  end
@@ -159,7 +159,7 @@ module JSON
159
159
 
160
160
  # Write a payload object. Not subject to extensions
161
161
  def write_pl(obj)
162
- @io << obj.to_json << ','
162
+ @io << Puppet::Util::Json.dump(obj) << ','
163
163
  end
164
164
 
165
165
  def io_string
@@ -198,7 +198,7 @@ module JSON
198
198
  if ext.nil?
199
199
  case obj
200
200
  when Numeric, String, true, false, nil
201
- @io << obj.to_json
201
+ @io << Puppet::Util::Json.dump(obj)
202
202
  write_delim
203
203
  else
204
204
  raise SerializationError, _("Unable to serialize a %{obj}") % { obj: obj.class.name }
@@ -284,9 +284,9 @@ module JSON
284
284
  def parse_io(io)
285
285
  case io
286
286
  when IO, StringIO
287
- ::JSON.parse(io.read)
287
+ ::Puppet::Util::Json.load(io.read)
288
288
  when String
289
- ::JSON.parse(io)
289
+ ::Puppet::Util::Json.load(io)
290
290
  else
291
291
  io
292
292
  end
@@ -290,12 +290,12 @@ module Serialization
290
290
  def serialization_issue(issue, options = EMPTY_HASH)
291
291
  semantic = @semantic
292
292
  if semantic.nil?
293
- stacktrace = Puppet::Pops::PuppetStack.stacktrace()
294
- if stacktrace.size > 0
295
- file, line = stacktrace[0]
296
- semantic = Puppet::Pops::SemanticError.new(issue, nil, {:file => file, :line => line})
297
- else
293
+ tos = Puppet::Pops::PuppetStack.top_of_stack
294
+ if tos.empty?
298
295
  semantic = Puppet::Pops::SemanticError.new(issue, nil, EMPTY_HASH)
296
+ else
297
+ file, line = stacktrace
298
+ semantic = Puppet::Pops::SemanticError.new(issue, nil, {:file => file, :line => line})
299
299
  end
300
300
  end
301
301
  optionally_fail(issue, semantic, options)
@@ -906,11 +906,15 @@ class PNumericType < PScalarDataType
906
906
  0
907
907
  else
908
908
  begin
909
- if from[0] == '0' && (from[1].downcase == 'b' || from[1].downcase == 'x')
910
- Integer(from)
911
- else
912
- Puppet::Pops::Utils.to_n(from)
909
+ if from[0] == '0'
910
+ second_char = (from[1] || '').downcase
911
+ if second_char == 'b' || second_char == 'x'
912
+ # use built in conversion
913
+ return Integer(from)
914
+ end
913
915
  end
916
+
917
+ Puppet::Pops::Utils.to_n(from)
914
918
  rescue TypeError => e
915
919
  raise TypeConversionError.new(e.message)
916
920
  rescue ArgumentError => e
@@ -35,6 +35,7 @@ class Checker4_0 < Evaluator::LiteralEvaluator
35
35
 
36
36
  @check_visitor = self.class.check_visitor
37
37
  @acceptor = diagnostics_producer
38
+ @file_to_namespace = {}
38
39
 
39
40
  # Use null migration checker unless given in context
40
41
  @migration_checker = (Puppet.lookup(:migration_checker) { Migration::MigrationChecker.new() })
@@ -395,6 +396,8 @@ class Checker4_0 < Evaluator::LiteralEvaluator
395
396
  if o.name !~ Patterns::CLASSREF_DECL
396
397
  acceptor.accept(Issues::ILLEGAL_DEFINITION_NAME, o, {:name=>o.name})
397
398
  end
399
+
400
+ internal_check_file_namespace(o, o.name, o.locator.file)
398
401
  internal_check_reserved_type_name(o, o.name)
399
402
  internal_check_future_reserved_word(o, o.name)
400
403
  end
@@ -530,6 +533,76 @@ class Checker4_0 < Evaluator::LiteralEvaluator
530
533
  end
531
534
  end
532
535
 
536
+ def internal_check_file_namespace(o, name, file)
537
+ return if file.nil?
538
+
539
+ lc_file = file.downcase
540
+
541
+ file_namespace = @file_to_namespace[lc_file]
542
+ if file_namespace.nil?
543
+ return if @file_to_namespace.key?(lc_file)
544
+ file_namespace = @file_to_namespace[lc_file] = namespace_for_file(lc_file)
545
+ return if file_namespace.nil?
546
+ end
547
+
548
+ if !name.downcase.start_with?(file_namespace)
549
+ acceptor.accept(Issues::ILLEGAL_DEFINITION_LOCATION, o, {:name => name, :file => file})
550
+ end
551
+ end
552
+
553
+ NEVER_MATCH = '\b'.freeze
554
+
555
+ def namespace_for_file(file)
556
+ path = Pathname.new(file)
557
+
558
+ return nil if path.extname != ".pp"
559
+
560
+ return nil if initial_manifest?(path)
561
+
562
+ path = path.each_filename.to_a
563
+
564
+ # Example definition dir: manifests in this path:
565
+ # <modules dir>/<module name>/manifests/<module subdir>/<classfile>.pp
566
+ definition_dir_index = find_module_definition_dir(path)
567
+
568
+ # How can we get this result?
569
+ # If it is not an initial manifest, it must come from a module,
570
+ # and from the manifests dir there. This may never get used...
571
+ return NEVER_MATCH if definition_dir_index.nil? || definition_dir_index == 0
572
+
573
+ before_definition_dir = definition_dir_index - 1
574
+ after_definition_dir = definition_dir_index + 1
575
+ names = path[after_definition_dir .. -2] # Directories inside module
576
+ names.unshift(path[before_definition_dir]) # Name of the module itself
577
+ # Do not include name of module init file at top level of module
578
+ filename = path[-1]
579
+ if !(path.length == (after_definition_dir+1) && filename == 'init.pp')
580
+ names.push(filename[0 .. -4]) # Remove .pp from filename
581
+ end
582
+
583
+ names.join("::").freeze
584
+ end
585
+
586
+ def initial_manifest?(path)
587
+ manifest_setting = Puppet[:manifest]
588
+
589
+ # Does this ever happen outside of tests?
590
+ if manifest_setting.nil?
591
+ return path.basename.to_s == 'site.pp'
592
+ end
593
+
594
+ full_path = path.expand_path.to_s
595
+ full_path == manifest_setting || full_path.start_with?(manifest_setting)
596
+ end
597
+
598
+ # Returns module root directory index in path for files under 'manifests',
599
+ # 'functions', 'types' and 'plans'
600
+ def find_module_definition_dir(path)
601
+ reverse_index = path.reverse_each.find_index do |dir|
602
+ dir == 'manifests' || dir == 'functions' || dir == 'types' || dir == 'plans'
603
+ end
604
+ return reverse_index.nil? ? nil : (path.length - 1) - reverse_index
605
+ end
533
606
 
534
607
  RESERVED_PARAMETERS = {
535
608
  'name' => true,
@@ -27,15 +27,16 @@ class ValidatorFactory_4_0 < Factory
27
27
  # Configure each issue that should **not** be an error
28
28
  #
29
29
  # Validate as per the current runtime configuration
30
- p[Issues::RT_NO_STORECONFIGS_EXPORT] = Puppet[:storeconfigs] ? :ignore : :warning
31
- p[Issues::RT_NO_STORECONFIGS] = Puppet[:storeconfigs] ? :ignore : :warning
30
+ p[Issues::RT_NO_STORECONFIGS_EXPORT] = Puppet[:storeconfigs] ? :ignore : :warning
31
+ p[Issues::RT_NO_STORECONFIGS] = Puppet[:storeconfigs] ? :ignore : :warning
32
32
 
33
33
  p[Issues::FUTURE_RESERVED_WORD] = :deprecation
34
34
 
35
35
  p[Issues::DUPLICATE_KEY] = Puppet[:strict] == :off ? :ignore : Puppet[:strict]
36
36
  p[Issues::NAME_WITH_HYPHEN] = :error
37
37
  p[Issues::EMPTY_RESOURCE_SPECIALIZATION] = :ignore
38
- p[Issues::CLASS_NOT_VIRTUALIZABLE] = Puppet[:strict] == :off ? :warning : Puppet[:strict]
38
+ p[Issues::CLASS_NOT_VIRTUALIZABLE] = Puppet[:strict] == :off ? :warning : Puppet[:strict]
39
+ p[Issues::ILLEGAL_DEFINITION_LOCATION] = Puppet[:strict] == :off ? :ignore : Puppet[:strict]
39
40
  p
40
41
  end
41
42
  end
@@ -122,6 +122,13 @@ Puppet::Type.type(:augeas).provide(:augeas) do
122
122
  if delim == "'" || delim == "\""
123
123
  sc.getch
124
124
  argline << sc.scan(/([^\\#{delim}]|(\\.))*/)
125
+ # Unescape the delimiter so it's actually possible to have a
126
+ # literal delim inside the string. We only unescape the
127
+ # delimeter and not every backslash-escaped character so that
128
+ # things like escaped spaces '\ ' get passed through because
129
+ # Augeas needs to see them. If we unescaped them, too, users
130
+ # would be forced to double-escape them
131
+ argline.last.gsub!(/\\(#{delim})/, '\1')
125
132
  sc.getch
126
133
  else
127
134
  argline << sc.scan(/[^\s]+/)