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
@@ -39,7 +39,7 @@ Puppet::Type.newtype(:yumrepo) do
39
39
  end
40
40
 
41
41
  newparam(:target) do
42
- desc "The filename to write the yum repository to."
42
+ desc "The target parameter will be enabled in a future release and should not be used."
43
43
 
44
44
  defaultto :absent
45
45
  end
@@ -261,17 +261,12 @@ Puppet::Type.newtype(:yumrepo) do
261
261
  end
262
262
 
263
263
  newproperty(:priority) do
264
- desc "Priority of this repository from 1-99. Requires that
265
- the `priorities` plugin is installed and enabled.
264
+ desc "Priority of this repository. Can be any integer value
265
+ (including negative). Requires that the `priorities` plugin
266
+ is installed and enabled.
266
267
  #{ABSENT_DOC}"
267
268
 
268
- newvalues(/.*/, :absent)
269
- validate do |value|
270
- next if value.to_s == 'absent'
271
- unless (1..99).include?(value.to_i)
272
- fail(_("Must be within range 1-99"))
273
- end
274
- end
269
+ newvalues(/^-?\d+$/, :absent)
275
270
  end
276
271
 
277
272
  newproperty(:throttle) do
@@ -326,6 +321,8 @@ Puppet::Type.newtype(:yumrepo) do
326
321
  desc "Password for this proxy. #{ABSENT_DOC}"
327
322
 
328
323
  newvalues(/.*/, :absent)
324
+
325
+ sensitive true
329
326
  end
330
327
 
331
328
  newproperty(:s3_enabled) do
@@ -428,12 +425,6 @@ Puppet::Type.newtype(:yumrepo) do
428
425
  desc "Password to use with the username for basic authentication.
429
426
  #{ABSENT_DOC}"
430
427
  newvalues(/.*/, :absent)
431
- end
432
-
433
- private
434
-
435
- def set_sensitive_parameters(sensitive_parameters)
436
- parameter(:password).sensitive = true if parameter(:password)
437
- super(sensitive_parameters)
428
+ sensitive true
438
429
  end
439
430
  end
@@ -690,7 +690,6 @@ end
690
690
 
691
691
 
692
692
  require 'puppet/util/errors'
693
- require 'puppet/util/methodhelper'
694
693
  require 'puppet/util/metaid'
695
694
  require 'puppet/util/classgen'
696
695
  require 'puppet/util/docs'
@@ -1,7 +1,6 @@
1
1
  require 'pathname'
2
2
  require 'puppet/util/rubygems'
3
3
  require 'puppet/util/warnings'
4
- require 'puppet/util/methodhelper'
5
4
  require 'puppet/pops/adaptable'
6
5
 
7
6
  # An adapter that ties the module_directories cache to the environment where the modules are parsed. This
@@ -14,8 +13,6 @@ end
14
13
 
15
14
  # Autoload paths, either based on names or all at once.
16
15
  class Puppet::Util::Autoload
17
- include Puppet::Util::MethodHelper
18
-
19
16
  @loaded = {}
20
17
 
21
18
  class << self
@@ -182,12 +179,10 @@ class Puppet::Util::Autoload
182
179
 
183
180
  attr_accessor :object, :path
184
181
 
185
- def initialize(obj, path, options = {})
182
+ def initialize(obj, path)
186
183
  @path = path.to_s
187
184
  raise ArgumentError, _("Autoload paths cannot be fully qualified") if Puppet::Util.absolute_path?(@path)
188
185
  @object = obj
189
-
190
- set_options(options)
191
186
  end
192
187
 
193
188
  def load(name, env = nil)
@@ -340,8 +340,6 @@ module Puppet::Util::Checksums
340
340
  end
341
341
  end
342
342
 
343
- private_class_method
344
-
345
343
  # Perform an incremental checksum on a file.
346
344
  def checksum_file(digest, filename, lite = false)
347
345
  buffer = lite ? 512 : 4096
@@ -1,5 +1,3 @@
1
- require 'puppet/util/methodhelper'
2
-
3
1
  module Puppet
4
2
  class ConstantAlreadyDefined < Error; end
5
3
  class SubclassAlreadyDefined < Error; end
@@ -9,7 +7,6 @@ end
9
7
  # @api public
10
8
  #
11
9
  module Puppet::Util::ClassGen
12
- include Puppet::Util::MethodHelper
13
10
  include Puppet::Util
14
11
 
15
12
  # Create a new class.
@@ -66,7 +63,6 @@ module Puppet::Util::ClassGen
66
63
  # @return [Boolean] whether the class was removed or not
67
64
  #
68
65
  def rmclass(name, options)
69
- options = symbolize_options(options)
70
66
  const = genconst_string(name, options)
71
67
  retval = false
72
68
  if is_constant_defined?(const)
@@ -100,8 +96,6 @@ module Puppet::Util::ClassGen
100
96
  # slightly abstract version of genclass.
101
97
  # @api private
102
98
  def genthing(name, type, options, block)
103
- options = symbolize_options(options)
104
-
105
99
  name = name.to_s.downcase.intern
106
100
 
107
101
  if type == Module
@@ -24,15 +24,12 @@
24
24
  # You could then call 'parser.to_line(hash)' on any of those hashes to generate
25
25
  # the text line again.
26
26
 
27
- require 'puppet/util/methodhelper'
28
-
29
27
  module Puppet::Util::FileParsing
30
28
  include Puppet::Util
31
29
  attr_writer :line_separator, :trailing_separator
32
30
 
33
31
  class FileRecord
34
32
  include Puppet::Util
35
- include Puppet::Util::MethodHelper
36
33
  attr_accessor :absent, :joiner, :rts, :separator, :rollup, :name, :match, :block_eval
37
34
 
38
35
  attr_reader :fields, :optional, :type
@@ -48,11 +45,36 @@ module Puppet::Util::FileParsing
48
45
  end
49
46
  end
50
47
 
51
- def initialize(type, options = {}, &block)
48
+ def initialize(type,
49
+ absent: nil,
50
+ block_eval: nil,
51
+ fields: nil,
52
+ joiner: nil,
53
+ match: nil,
54
+ optional: nil,
55
+ post_parse: nil,
56
+ pre_gen: nil,
57
+ rollup: nil,
58
+ rts: nil,
59
+ separator: nil,
60
+ to_line: nil,
61
+ &block)
52
62
  @type = type.intern
53
63
  raise ArgumentError, _("Invalid record type %{record_type}") % { record_type: @type } unless [:record, :text].include?(@type)
54
64
 
55
- set_options(options)
65
+ @absent = absent
66
+ @block_eval = block_eval
67
+ @joiner = joiner
68
+ @match = match
69
+ @rollup = rollup if rollup
70
+ @rts = rts
71
+ @separator = separator
72
+
73
+ self.fields = fields if fields
74
+ self.optional = optional if optional
75
+ self.post_parse = post_parse if post_parse
76
+ self.pre_gen = pre_gen if pre_gen
77
+ self.to_line = to_line if to_line
56
78
 
57
79
  if self.type == :record
58
80
  # Now set defaults.
@@ -12,12 +12,12 @@ module Puppet::Util::InstanceLoader
12
12
  end
13
13
 
14
14
  # Define a new type of autoloading.
15
- def instance_load(type, path, options = {})
15
+ def instance_load(type, path)
16
16
  @autoloaders ||= {}
17
17
  @instances ||= {}
18
18
  type = type.intern
19
19
  @instances[type] = {}
20
- @autoloaders[type] = Puppet::Util::Autoload.new(self, path, options)
20
+ @autoloaders[type] = Puppet::Util::Autoload.new(self, path)
21
21
 
22
22
  # Now define our new simple methods
23
23
  unless respond_to?(type)
@@ -41,7 +41,7 @@ module Puppet::Util::InstanceLoader
41
41
 
42
42
  # Use this method so they all get loaded
43
43
  loaded_instances(type).sort { |a,b| a.to_s <=> b.to_s }.each do |name|
44
- mod = self.loaded_instance(name)
44
+ mod = self.loaded_instance(type, name)
45
45
  docs << "#{name}\n#{"-" * name.to_s.length}\n"
46
46
 
47
47
  docs << Puppet::Util::Docs.scrub(mod.doc) << "\n\n"
@@ -0,0 +1,77 @@
1
+ module Puppet::Util
2
+ module Json
3
+ class ParseError < StandardError
4
+ attr_reader :cause, :data
5
+
6
+ def self.build(original_exception, data)
7
+ new(original_exception.message).tap do |exception|
8
+ exception.instance_eval do
9
+ @cause = original_exception
10
+ set_backtrace original_exception.backtrace
11
+ @data = data
12
+ end
13
+ end
14
+ end
15
+ end
16
+
17
+ begin
18
+ require 'multi_json'
19
+ # Force backend detection before attempting to use the library
20
+ # or load any other JSON libraries
21
+ MultiJson.default_adapter
22
+
23
+ # Preserve core type monkey-patching done by the built-in JSON gem
24
+ require 'json'
25
+ rescue LoadError
26
+ require 'json'
27
+ end
28
+
29
+ # These methods do similar processing to the fallback implemented by MultiJson
30
+ # when using the built-in JSON backend, to ensure consistent behavior
31
+ # whether or not MultiJson can be loaded.
32
+ def self.load(string, options = {})
33
+ if defined? MultiJson
34
+ begin
35
+ # This ensures that JrJackson will parse very large or very small
36
+ # numbers as floats rather than BigDecimals, which are serialized as
37
+ # strings by the built-in JSON gem and therefore can cause schema errors,
38
+ # for example, when we are rendering reports to JSON using `to_pson` in
39
+ # PuppetDB.
40
+ if MultiJson.adapter.name == "MultiJson::Adapters::JrJackson"
41
+ options[:use_bigdecimal] = false
42
+ end
43
+
44
+ MultiJson.load(string, options)
45
+ rescue MultiJson::ParseError => e
46
+ raise Puppet::Util::Json::ParseError.build(e, string)
47
+ end
48
+ else
49
+ begin
50
+ string = string.read if string.respond_to?(:read)
51
+
52
+ options[:symbolize_names] = true if options.delete(:symbolize_keys)
53
+ ::JSON.parse(string, options)
54
+ rescue JSON::ParserError => e
55
+ raise Puppet::Util::Json::ParseError.build(e, string)
56
+ end
57
+ end
58
+ end
59
+
60
+ def self.dump(object, options = {})
61
+ if defined? MultiJson
62
+ # MultiJson calls `merge` on the options it is passed, which relies
63
+ # on the options' defining a `to_hash` method. In Ruby 1.9.3,
64
+ # JSON::Ext::Generator::State only defines `to_h`, not `to_hash`, so we
65
+ # need to convert it first, similar to what is done in the `else` block
66
+ # below. Later versions of the JSON gem alias `to_h` to `to_hash`, so this
67
+ # can be removed once we drop Ruby 1.9.3 support.
68
+ options = options.to_h if options.class.name == "JSON::Ext::Generator::State"
69
+
70
+ MultiJson.dump(object, options)
71
+ else
72
+ options.merge!(::JSON::PRETTY_STATE_PROTOTYPE.to_h) if options.delete(:pretty)
73
+ object.to_json(options)
74
+ end
75
+ end
76
+ end
77
+ end
@@ -23,7 +23,7 @@ class Puppet::Util::JsonLockfile < Puppet::Util::Lockfile
23
23
  def lock(lock_data = nil)
24
24
  return false if locked?
25
25
 
26
- super(lock_data.to_json)
26
+ super(Puppet::Util::Json.dump(lock_data))
27
27
  end
28
28
 
29
29
  # Retrieve the (optional) lock data that was specified at the time the file
@@ -35,8 +35,8 @@ class Puppet::Util::JsonLockfile < Puppet::Util::Lockfile
35
35
  return nil unless file_locked?
36
36
  file_contents = super
37
37
  return nil if file_contents.nil? or file_contents.empty?
38
- JSON.parse(file_contents)
39
- rescue JSON::ParserError
38
+ Puppet::Util::Json.load(file_contents)
39
+ rescue Puppet::Util::Json::ParseError
40
40
  Puppet.warning _("Unable to read lockfile data from %{path}: not in JSON") % { path: @file_path }
41
41
  nil
42
42
  end
@@ -1,9 +1,6 @@
1
1
  require 'puppet/util/ldap'
2
- require 'puppet/util/methodhelper'
3
2
 
4
3
  class Puppet::Util::Ldap::Connection
5
- include Puppet::Util::MethodHelper
6
-
7
4
  attr_accessor :host, :port, :user, :password, :reset, :ssl
8
5
 
9
6
  attr_reader :connection
@@ -34,12 +31,15 @@ class Puppet::Util::Ldap::Connection
34
31
  connection.unbind if connection.bound?
35
32
  end
36
33
 
37
- def initialize(host, port, options = {})
34
+ def initialize(host, port, user: nil, password: nil, reset: nil, ssl: nil)
38
35
  raise Puppet::Error, _("Could not set up LDAP Connection: Missing ruby/ldap libraries") unless Puppet.features.ldap?
39
36
 
40
- @host, @port = host, port
41
-
42
- set_options(options)
37
+ @host = host
38
+ @port = port
39
+ @user = user
40
+ @password = password
41
+ @reset = reset
42
+ @ssl = ssl
43
43
  end
44
44
 
45
45
  # Create a per-connection unique name.
@@ -109,7 +109,7 @@ Puppet::Util::Log.newdesttype :file do
109
109
  def handle(msg)
110
110
  if @json > 0
111
111
  @json > 1 ? @file.puts(',') : @json = 2
112
- JSON.dump(msg.to_structured_hash, @file)
112
+ Puppet::Util::Json.dump(msg.to_structured_hash, @file)
113
113
  else
114
114
  @file.puts("#{msg.time} #{msg.source} (#{msg.level}): #{msg}")
115
115
  end
@@ -135,7 +135,7 @@ Puppet::Util::Log.newdesttype :logstash_event do
135
135
 
136
136
  def handle(msg)
137
137
  message = format(msg)
138
- $stdout.puts message.to_json
138
+ $stdout.puts Puppet::Util::Json.dump(message)
139
139
  end
140
140
  end
141
141
 
@@ -176,7 +176,7 @@ module Logging
176
176
  else
177
177
  error_location_str = Puppet::Util::Errors.error_location(file, line)
178
178
  if error_location_str.empty?
179
- '\n ' + _('(file & line not available)')
179
+ "\n " + _('(file & line not available)')
180
180
  else
181
181
  "\n %{error_location}" % { error_location: error_location_str }
182
182
  end
@@ -41,7 +41,7 @@ module Puppet::Util::Plist
41
41
 
42
42
  Puppet.debug "Plist #{file_path} ill-formatted, converting with plutil"
43
43
  begin
44
- plist = Puppet::Util::Execution.execute(['/usr/bin/plutil', '-convert', 'xml1', '-o', '/dev/stdout', file_path],
44
+ plist = Puppet::Util::Execution.execute(['/usr/bin/plutil', '-convert', 'xml1', '-o', '-', file_path],
45
45
  {:failonfail => true, :combine => true})
46
46
  return parse_plist(plist)
47
47
  rescue Puppet::ExecutionFailure => detail
@@ -1,5 +1,4 @@
1
1
  # Provides feature definitions.
2
- require 'puppet/util/methodhelper'
3
2
  require 'puppet/util/docs'
4
3
  require 'puppet/util'
5
4
  # This module models provider features and handles checking whether the features
@@ -13,7 +12,6 @@ module Puppet::Util::ProviderFeatures
13
12
  # @todo Unclear what is api and what is private in this class
14
13
  class ProviderFeature
15
14
  include Puppet::Util
16
- include Puppet::Util::MethodHelper
17
15
  include Puppet::Util::Docs
18
16
  attr_accessor :name, :docs, :methods
19
17
 
@@ -32,11 +30,10 @@ module Puppet::Util::ProviderFeatures
32
30
  end
33
31
  end
34
32
 
35
- def initialize(name, docs, hash)
33
+ def initialize(name, docs, methods: nil)
36
34
  self.name = name.intern
37
35
  self.docs = docs
38
- hash = symbolize_options(hash)
39
- set_options(hash)
36
+ @methods = methods
40
37
  end
41
38
 
42
39
  private
@@ -1,11 +1,9 @@
1
1
  require 'puppet/util/instance_loader'
2
- require 'puppet/util/methodhelper'
3
2
  require 'fileutils'
4
3
 
5
4
  # Manage Reference Documentation.
6
5
  class Puppet::Util::Reference
7
6
  include Puppet::Util
8
- include Puppet::Util::MethodHelper
9
7
  include Puppet::Util::Docs
10
8
 
11
9
  extend Puppet::Util::InstanceLoader
@@ -78,9 +76,12 @@ class Puppet::Util::Reference
78
76
  self.dynamic
79
77
  end
80
78
 
81
- def initialize(name, options = {}, &block)
79
+ def initialize(name, title: nil, depth: nil, dynamic: nil, doc: nil, &block)
82
80
  @name = name
83
- set_options(options)
81
+ @title = title
82
+ @depth = depth
83
+ @dynamic = dynamic
84
+ @doc = doc
84
85
 
85
86
  meta_def(:generate, &block)
86
87
 
@@ -1,7 +1,7 @@
1
1
  require 'puppet/util/tag_set'
2
2
 
3
3
  module Puppet::Util::Tagging
4
- ValidTagRegex = /\A[[:alnum:]_][[:alnum:]_:.-]*\Z/
4
+ ValidTagRegex = /\A[[:alnum:]_][[:alnum:]_:.-]*\Z/u
5
5
 
6
6
  # Add a tag to the current tag set.
7
7
  # When a tag set is used for a scope, these tags will be added to all of
@@ -17,7 +17,7 @@ module Puppet::Util::Tagging
17
17
  # up since we get a lot of duplicates and rarely fail on bad tags
18
18
  if @tags.add?(name)
19
19
  # not seen before, so now we test if it is valid
20
- if name =~ ValidTagRegex
20
+ if valid_tag?(name)
21
21
  if split_qualified_tags?
22
22
  # avoid adding twice by first testing if the string contains '::'
23
23
  @tags.merge(name.split('::')) if name.include?('::')
@@ -40,7 +40,7 @@ module Puppet::Util::Tagging
40
40
  # since that results in testing the same string twice
41
41
  #
42
42
  def tag_if_valid(name)
43
- if name.is_a?(String) && name =~ ValidTagRegex
43
+ if name.is_a?(String) && valid_tag?(name)
44
44
  name = name.downcase
45
45
  @tags ||= new_tags
46
46
  if @tags.add?(name) && name.include?('::')
@@ -106,6 +106,19 @@ module Puppet::Util::Tagging
106
106
  tag(*tags)
107
107
  end
108
108
 
109
+ def valid_tag?(maybe_tag)
110
+ begin
111
+ tag_enc = maybe_tag.encoding
112
+ if tag_enc == Encoding::UTF_8 || tag_enc == Encoding::ASCII
113
+ maybe_tag =~ ValidTagRegex
114
+ else
115
+ maybe_tag.encode(Encoding::UTF_8) =~ ValidTagRegex
116
+ end
117
+ rescue Encoding::UndefinedConversionError, Encoding::InvalidByteSequenceError
118
+ false
119
+ end
120
+ end
121
+
109
122
  private
110
123
 
111
124
  def split_qualified_tags?