puppet 5.3.3 → 5.3.4

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

Potentially problematic release.


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

Files changed (291) hide show
  1. data/CONTRIBUTING.md +1 -1
  2. data/Gemfile +3 -0
  3. data/ext/puppet-test +3 -2
  4. data/lib/hiera/puppet_function.rb +5 -2
  5. data/lib/hiera_puppet.rb +3 -3
  6. data/lib/puppet.rb +2 -5
  7. data/lib/puppet/agent.rb +22 -2
  8. data/lib/puppet/agent/locker.rb +6 -5
  9. data/lib/puppet/application.rb +18 -1
  10. data/lib/puppet/application/agent.rb +9 -2
  11. data/lib/puppet/application/apply.rb +1 -1
  12. data/lib/puppet/application/config.rb +1 -0
  13. data/lib/puppet/application/device.rb +1 -2
  14. data/lib/puppet/application/filebucket.rb +22 -5
  15. data/lib/puppet/application/help.rb +1 -0
  16. data/lib/puppet/application/lookup.rb +1 -3
  17. data/lib/puppet/application_support.rb +6 -1
  18. data/lib/puppet/bindings.rb +2 -1
  19. data/lib/puppet/configurer.rb +9 -4
  20. data/lib/puppet/configurer/downloader_factory.rb +10 -0
  21. data/lib/puppet/configurer/plugin_handler.rb +11 -4
  22. data/lib/puppet/daemon.rb +2 -2
  23. data/lib/puppet/defaults.rb +99 -27
  24. data/lib/puppet/environments.rb +2 -0
  25. data/lib/puppet/error.rb +5 -15
  26. data/lib/puppet/external/pson/common.rb +2 -2
  27. data/lib/puppet/face/catalog.rb +1 -1
  28. data/lib/puppet/face/config.rb +14 -1
  29. data/lib/puppet/face/epp.rb +4 -2
  30. data/lib/puppet/face/help.rb +12 -14
  31. data/lib/puppet/face/man.rb +1 -0
  32. data/lib/puppet/face/module/build.rb +1 -1
  33. data/lib/puppet/face/module/list.rb +6 -17
  34. data/lib/puppet/face/module/uninstall.rb +14 -3
  35. data/lib/puppet/face/node.rb +1 -0
  36. data/lib/puppet/face/status.rb +1 -0
  37. data/lib/puppet/file_serving/base.rb +2 -1
  38. data/lib/puppet/file_serving/configuration.rb +3 -0
  39. data/lib/puppet/file_serving/configuration/parser.rb +23 -9
  40. data/lib/puppet/file_serving/mount/locales.rb +35 -0
  41. data/lib/puppet/forge.rb +2 -1
  42. data/lib/puppet/forge/errors.rb +24 -22
  43. data/lib/puppet/functions/binary_file.rb +1 -0
  44. data/lib/puppet/functions/each.rb +10 -4
  45. data/lib/puppet/functions/eyaml_lookup_key.rb +4 -2
  46. data/lib/puppet/functions/lookup.rb +2 -2
  47. data/lib/puppet/functions/map.rb +12 -2
  48. data/lib/puppet/functions/slice.rb +2 -3
  49. data/lib/puppet/functions/unique.rb +1 -1
  50. data/lib/puppet/functions/yaml_data.rb +1 -1
  51. data/lib/puppet/gettext/config.rb +144 -41
  52. data/lib/puppet/gettext/module_translations.rb +42 -0
  53. data/lib/puppet/graph/relationship_graph.rb +1 -1
  54. data/lib/puppet/graph/simple_graph.rb +3 -3
  55. data/lib/puppet/indirector/catalog/compiler.rb +40 -25
  56. data/lib/puppet/indirector/exec.rb +1 -1
  57. data/lib/puppet/indirector/facts/facter.rb +3 -3
  58. data/lib/puppet/indirector/facts/network_device.rb +2 -2
  59. data/lib/puppet/indirector/file_bucket_file/file.rb +4 -1
  60. data/lib/puppet/indirector/indirection.rb +17 -9
  61. data/lib/puppet/indirector/ldap.rb +2 -2
  62. data/lib/puppet/indirector/node/write_only_yaml.rb +3 -1
  63. data/lib/puppet/indirector/rest.rb +8 -5
  64. data/lib/puppet/indirector/ssl_file.rb +2 -2
  65. data/lib/puppet/indirector/terminus.rb +3 -3
  66. data/lib/puppet/interface.rb +2 -1
  67. data/lib/puppet/interface/action.rb +41 -24
  68. data/lib/puppet/interface/action_builder.rb +14 -5
  69. data/lib/puppet/interface/action_manager.rb +1 -1
  70. data/lib/puppet/interface/documentation.rb +21 -10
  71. data/lib/puppet/interface/face_collection.rb +4 -2
  72. data/lib/puppet/interface/option.rb +36 -15
  73. data/lib/puppet/interface/option_builder.rb +23 -9
  74. data/lib/puppet/interface/option_manager.rb +8 -3
  75. data/lib/puppet/metatype/manager.rb +7 -3
  76. data/lib/puppet/module.rb +18 -21
  77. data/lib/puppet/module_tool/errors/installer.rb +18 -20
  78. data/lib/puppet/module_tool/errors/shared.rb +20 -15
  79. data/lib/puppet/module_tool/errors/uninstaller.rb +1 -0
  80. data/lib/puppet/module_tool/errors/upgrader.rb +1 -1
  81. data/lib/puppet/module_tool/tar/mini.rb +57 -4
  82. data/lib/puppet/network/auth_config_parser.rb +18 -13
  83. data/lib/puppet/network/authstore.rb +2 -2
  84. data/lib/puppet/network/client_request.rb +1 -1
  85. data/lib/puppet/network/format.rb +3 -3
  86. data/lib/puppet/network/http/api/indirection_type.rb +1 -1
  87. data/lib/puppet/network/http/api/master/v3/environment.rb +5 -2
  88. data/lib/puppet/network/http/error.rb +7 -7
  89. data/lib/puppet/network/http/factory.rb +9 -0
  90. data/lib/puppet/network/http/rack.rb +2 -2
  91. data/lib/puppet/network/http/webrick.rb +2 -4
  92. data/lib/puppet/node.rb +25 -6
  93. data/lib/puppet/node/environment.rb +14 -0
  94. data/lib/puppet/node/facts.rb +9 -0
  95. data/lib/puppet/parameter.rb +3 -3
  96. data/lib/puppet/parameter/value_collection.rb +9 -9
  97. data/lib/puppet/parser/ast/leaf.rb +1 -1
  98. data/lib/puppet/parser/ast/node.rb +2 -2
  99. data/lib/puppet/parser/ast/pops_bridge.rb +1 -1
  100. data/lib/puppet/parser/compiler.rb +6 -5
  101. data/lib/puppet/parser/functions.rb +1 -1
  102. data/lib/puppet/parser/functions/generate.rb +2 -4
  103. data/lib/puppet/parser/functions/inline_template.rb +1 -2
  104. data/lib/puppet/parser/functions/sprintf.rb +17 -3
  105. data/lib/puppet/parser/functions/template.rb +6 -2
  106. data/lib/puppet/parser/resource.rb +30 -31
  107. data/lib/puppet/parser/scope.rb +20 -11
  108. data/lib/puppet/parser/templatewrapper.rb +4 -3
  109. data/lib/puppet/pops/evaluator/collector_transformer.rb +2 -1
  110. data/lib/puppet/pops/evaluator/collectors/abstract_collector.rb +1 -1
  111. data/lib/puppet/pops/evaluator/epp_evaluator.rb +21 -8
  112. data/lib/puppet/pops/evaluator/evaluator_impl.rb +2 -1
  113. data/lib/puppet/pops/evaluator/external_syntax_support.rb +1 -1
  114. data/lib/puppet/pops/evaluator/runtime3_converter.rb +3 -1
  115. data/lib/puppet/pops/evaluator/runtime3_resource_support.rb +1 -1
  116. data/lib/puppet/pops/evaluator/runtime3_support.rb +4 -4
  117. data/lib/puppet/pops/functions/dispatch.rb +1 -1
  118. data/lib/puppet/pops/functions/function.rb +8 -2
  119. data/lib/puppet/pops/issue_reporter.rb +7 -2
  120. data/lib/puppet/pops/issues.rb +10 -4
  121. data/lib/puppet/pops/label_provider.rb +1 -1
  122. data/lib/puppet/pops/loader/module_loaders.rb +5 -2
  123. data/lib/puppet/pops/loader/static_loader.rb +1 -1
  124. data/lib/puppet/pops/loaders.rb +7 -3
  125. data/lib/puppet/pops/lookup/explainer.rb +2 -1
  126. data/lib/puppet/pops/lookup/hiera_config.rb +2 -2
  127. data/lib/puppet/pops/lookup/lookup_adapter.rb +4 -4
  128. data/lib/puppet/pops/merge_strategy.rb +6 -3
  129. data/lib/puppet/pops/migration/migration_checker.rb +8 -8
  130. data/lib/puppet/pops/model/ast_transformer.rb +1 -1
  131. data/lib/puppet/pops/model/factory.rb +4 -2
  132. data/lib/puppet/pops/resource/resource_type_impl.rb +1 -1
  133. data/lib/puppet/pops/serialization/abstract_writer.rb +2 -1
  134. data/lib/puppet/pops/types/iterable.rb +2 -0
  135. data/lib/puppet/pops/types/p_object_type.rb +36 -15
  136. data/lib/puppet/pops/types/type_calculator.rb +2 -1
  137. data/lib/puppet/pops/types/type_factory.rb +3 -1
  138. data/lib/puppet/pops/types/type_mismatch_describer.rb +19 -6
  139. data/lib/puppet/pops/types/type_parser.rb +7 -7
  140. data/lib/puppet/pops/types/types.rb +10 -4
  141. data/lib/puppet/pops/validation.rb +14 -12
  142. data/lib/puppet/property.rb +14 -6
  143. data/lib/puppet/property/ensure.rb +2 -2
  144. data/lib/puppet/provider.rb +4 -4
  145. data/lib/puppet/provider/group/aix.rb +4 -2
  146. data/lib/puppet/provider/ldap.rb +2 -2
  147. data/lib/puppet/provider/naginator.rb +1 -1
  148. data/lib/puppet/provider/nameservice.rb +7 -4
  149. data/lib/puppet/provider/nameservice/directoryservice.rb +4 -3
  150. data/lib/puppet/provider/package/aix.rb +1 -1
  151. data/lib/puppet/provider/package/nim.rb +7 -8
  152. data/lib/puppet/provider/package/opkg.rb +1 -1
  153. data/lib/puppet/provider/package/pkg.rb +9 -6
  154. data/lib/puppet/provider/package/pkgutil.rb +3 -3
  155. data/lib/puppet/provider/package/yum.rb +1 -1
  156. data/lib/puppet/provider/parsedfile.rb +4 -4
  157. data/lib/puppet/provider/selmodule/semodule.rb +5 -3
  158. data/lib/puppet/provider/service/base.rb +1 -1
  159. data/lib/puppet/provider/service/init.rb +1 -1
  160. data/lib/puppet/provider/service/launchd.rb +2 -2
  161. data/lib/puppet/provider/service/runit.rb +2 -1
  162. data/lib/puppet/provider/service/smf.rb +2 -0
  163. data/lib/puppet/provider/service/systemd.rb +1 -0
  164. data/lib/puppet/provider/service/upstart.rb +1 -1
  165. data/lib/puppet/provider/user/aix.rb +13 -6
  166. data/lib/puppet/provider/user/openbsd.rb +2 -1
  167. data/lib/puppet/provider/yumrepo/inifile.rb +2 -1
  168. data/lib/puppet/provider/zone/solaris.rb +2 -2
  169. data/lib/puppet/reference/configuration.rb +4 -2
  170. data/lib/puppet/relationship.rb +2 -1
  171. data/lib/puppet/reports/store.rb +1 -1
  172. data/lib/puppet/resource.rb +7 -5
  173. data/lib/puppet/resource/capability_finder.rb +14 -11
  174. data/lib/puppet/resource/catalog.rb +33 -18
  175. data/lib/puppet/resource/type.rb +5 -5
  176. data/lib/puppet/settings.rb +19 -13
  177. data/lib/puppet/settings/base_setting.rb +23 -8
  178. data/lib/puppet/settings/config_file.rb +14 -4
  179. data/lib/puppet/settings/environment_conf.rb +19 -9
  180. data/lib/puppet/ssl/base.rb +9 -4
  181. data/lib/puppet/ssl/oids.rb +8 -2
  182. data/lib/puppet/syntax_checkers/base64.rb +5 -6
  183. data/lib/puppet/transaction.rb +7 -3
  184. data/lib/puppet/transaction/persistence.rb +16 -1
  185. data/lib/puppet/transaction/report.rb +6 -0
  186. data/lib/puppet/type.rb +27 -35
  187. data/lib/puppet/type/file.rb +2 -1
  188. data/lib/puppet/type/file/data_sync.rb +2 -1
  189. data/lib/puppet/type/file/source.rb +1 -1
  190. data/lib/puppet/type/group.rb +1 -1
  191. data/lib/puppet/type/mount.rb +1 -1
  192. data/lib/puppet/type/resources.rb +1 -1
  193. data/lib/puppet/type/schedule.rb +26 -14
  194. data/lib/puppet/type/user.rb +9 -3
  195. data/lib/puppet/type/zone.rb +1 -1
  196. data/lib/puppet/util.rb +27 -21
  197. data/lib/puppet/util/at_fork/solaris.rb +6 -4
  198. data/lib/puppet/util/command_line.rb +5 -0
  199. data/lib/puppet/util/command_line/trollop.rb +6 -5
  200. data/lib/puppet/util/errors.rb +61 -8
  201. data/lib/puppet/util/fileparsing.rb +3 -5
  202. data/lib/puppet/util/http_proxy.rb +14 -6
  203. data/lib/puppet/util/instance_loader.rb +1 -3
  204. data/lib/puppet/util/ldap/manager.rb +6 -3
  205. data/lib/puppet/util/log.rb +19 -24
  206. data/lib/puppet/util/logging.rb +21 -28
  207. data/lib/puppet/util/methodhelper.rb +1 -1
  208. data/lib/puppet/util/nagios_maker.rb +1 -1
  209. data/lib/puppet/util/network_device/config.rb +21 -13
  210. data/lib/puppet/util/plist.rb +3 -1
  211. data/lib/puppet/util/posix.rb +1 -1
  212. data/lib/puppet/util/provider_features.rb +1 -1
  213. data/lib/puppet/util/rdoc/generators/puppet_generator.rb +1 -1
  214. data/lib/puppet/util/reference.rb +2 -3
  215. data/lib/puppet/util/selinux.rb +1 -1
  216. data/lib/puppet/util/storage.rb +2 -2
  217. data/lib/puppet/util/windows/eventlog.rb +10 -5
  218. data/lib/puppet/util/windows/file.rb +61 -9
  219. data/lib/puppet/util/windows/process.rb +1 -1
  220. data/lib/puppet/util/windows/taskscheduler.rb +2 -2
  221. data/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet.rb +5 -1
  222. data/lib/puppet/version.rb +1 -1
  223. data/locales/en/puppet.po +19 -0
  224. data/locales/ja/puppet.po +2739 -809
  225. data/locales/puppet.pot +2367 -734
  226. data/spec/fixtures/unit/application/environments/production/data/common.yaml +2 -0
  227. data/spec/integration/agent/logging_spec.rb +2 -0
  228. data/spec/integration/faces/plugin_spec.rb +1 -0
  229. data/spec/integration/network/authconfig_spec.rb +2 -2
  230. data/spec/integration/parser/collection_spec.rb +2 -2
  231. data/spec/integration/parser/scope_spec.rb +16 -3
  232. data/spec/integration/provider/cron/crontab_spec.rb +1 -0
  233. data/spec/integration/transaction/report_spec.rb +5 -0
  234. data/spec/lib/matchers/json.rb +14 -13
  235. data/spec/unit/agent_spec.rb +33 -0
  236. data/spec/unit/application/config_spec.rb +4 -0
  237. data/spec/unit/application/lookup_spec.rb +30 -0
  238. data/spec/unit/application_spec.rb +18 -0
  239. data/spec/unit/configurer/downloader_factory_spec.rb +33 -0
  240. data/spec/unit/configurer/plugin_handler_spec.rb +71 -16
  241. data/spec/unit/environments_spec.rb +15 -0
  242. data/spec/unit/face/config_spec.rb +8 -9
  243. data/spec/unit/face/epp_face_spec.rb +2 -2
  244. data/spec/unit/face/plugin_spec.rb +50 -4
  245. data/spec/unit/file_serving/configuration/parser_spec.rb +2 -2
  246. data/spec/unit/file_serving/mount/locales_spec.rb +73 -0
  247. data/spec/unit/functions/break_spec.rb +108 -50
  248. data/spec/unit/functions/defined_spec.rb +2 -2
  249. data/spec/unit/functions/hiera_spec.rb +0 -1
  250. data/spec/unit/functions/lookup_spec.rb +85 -19
  251. data/spec/unit/functions/next_spec.rb +1 -1
  252. data/spec/unit/functions/return_spec.rb +2 -2
  253. data/spec/unit/gettext/config_spec.rb +125 -0
  254. data/spec/unit/gettext/module_loading_spec.rb +53 -0
  255. data/spec/unit/indirector/json_spec.rb +0 -11
  256. data/spec/unit/indirector/node/exec_spec.rb +1 -1
  257. data/spec/unit/info_service_spec.rb +1 -1
  258. data/spec/unit/interface_spec.rb +12 -0
  259. data/spec/unit/module_spec.rb +0 -28
  260. data/spec/unit/module_tool/tar/mini_spec.rb +34 -5
  261. data/spec/unit/network/http/factory_spec.rb +22 -0
  262. data/spec/unit/network/http/webrick_spec.rb +30 -29
  263. data/spec/unit/node/environment_spec.rb +16 -0
  264. data/spec/unit/node_spec.rb +102 -16
  265. data/spec/unit/parser/environment_compiler_spec.rb +1 -1
  266. data/spec/unit/parser/functions/sprintf_spec.rb +26 -0
  267. data/spec/unit/parser/resource/param_spec.rb +1 -1
  268. data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +9 -9
  269. data/spec/unit/pops/loaders/static_loader_spec.rb +1 -1
  270. data/spec/unit/pops/parser/parse_containers_spec.rb +1 -1
  271. data/spec/unit/pops/types/type_calculator_spec.rb +40 -0
  272. data/spec/unit/pops/types/type_mismatch_describer_spec.rb +9 -0
  273. data/spec/unit/provider/selmodule_spec.rb +6 -0
  274. data/spec/unit/provider/service/init_spec.rb +1 -1
  275. data/spec/unit/provider/service/smf_spec.rb +2 -0
  276. data/spec/unit/provider/service/systemd_spec.rb +14 -0
  277. data/spec/unit/resource/catalog_spec.rb +12 -2
  278. data/spec/unit/settings/config_file_spec.rb +1 -1
  279. data/spec/unit/transaction/persistence_spec.rb +42 -0
  280. data/spec/unit/transaction/report_spec.rb +19 -4
  281. data/spec/unit/transaction_spec.rb +27 -0
  282. data/spec/unit/type/schedule_spec.rb +14 -0
  283. data/spec/unit/type_spec.rb +3 -3
  284. data/spec/unit/util/errors_spec.rb +1 -1
  285. data/spec/unit/util/http_proxy_spec.rb +37 -0
  286. data/spec/unit/util/log_spec.rb +3 -3
  287. data/spec/unit/util/logging_spec.rb +7 -7
  288. data/spec/unit/util/monkey_patches_spec.rb +6 -2
  289. metadata +3433 -3416
  290. checksums.yaml +0 -7
  291. data/spec/unit/gettext_config_spec.rb +0 -57
@@ -378,7 +378,7 @@ class Puppet::Parser::Scope
378
378
  if compiler.is_a? Puppet::Parser::Compiler
379
379
  @compiler = compiler
380
380
  else
381
- raise Puppet::DevError, "you must pass a compiler instance to a new scope object"
381
+ raise Puppet::DevError, _("you must pass a compiler instance to a new scope object")
382
382
  end
383
383
 
384
384
  set_options(options)
@@ -611,6 +611,7 @@ class Puppet::Parser::Scope
611
611
  begin
612
612
  qs = qualified_scope(class_name)
613
613
  unless qs.nil?
614
+ return qs.get_local_variable(leaf_name) if qs.has_local_variable?(leaf_name)
614
615
  iscope = qs.inherited_scope
615
616
  return lookup_qualified_variable("#{iscope.source.name}::#{leaf_name}", options) unless iscope.nil?
616
617
  end
@@ -623,15 +624,23 @@ class Puppet::Parser::Scope
623
624
  return handle_not_found('', fqn, options)
624
625
  end
625
626
 
627
+ # @api private
628
+ def has_local_variable?(name)
629
+ @ephemeral.last.include?(name)
630
+ end
631
+
632
+ # @api private
633
+ def get_local_variable(name)
634
+ @ephemeral.last[name]
635
+ end
636
+
626
637
  def handle_not_found(class_name, variable_name, position, reason = nil)
627
638
  unless Puppet[:strict_variables]
628
639
  # Do not issue warning if strict variables are on, as an error will be raised by variable_not_found
629
640
  location = if position[:lineproc]
630
- " at #{position[:lineproc].call}"
631
- elsif position[:file] && position[:line]
632
- " at #{position[:file]}:#{position[:line]}"
641
+ Puppet::Util::Errors.error_location_with_space(nil, position[:lineproc].call)
633
642
  else
634
- ""
643
+ Puppet::Util::Errors.error_location_with_space(position[:file], position[:line])
635
644
  end
636
645
  variable_not_found("#{class_name}::#{variable_name}", "#{reason}#{location}")
637
646
  return nil
@@ -751,7 +760,7 @@ class Puppet::Parser::Scope
751
760
  raise Puppet::ParseError.new(_("Cannot assign to a numeric match result variable '$%{name}'") % { name: name }) # unless options[:ephemeral]
752
761
  end
753
762
  unless name.is_a? String
754
- raise Puppet::ParseError, _("Scope variable name %{value0} is a %{value1}, not a string") % { value0: name.inspect, value1: name.class }
763
+ raise Puppet::ParseError, _("Scope variable name %{name} is a %{class_type}, not a string") % { name: name.inspect, class_type: name.class }
755
764
  end
756
765
 
757
766
  # Check for reserved variable names
@@ -986,17 +995,17 @@ class Puppet::Parser::Scope
986
995
 
987
996
  # @api private
988
997
  def find_resource_type(type)
989
- raise Puppet::DevError, "Scope#find_resource_type() is no longer supported, use Puppet::Pops::Evaluator::Runtime3ResourceSupport instead"
998
+ raise Puppet::DevError, _("Scope#find_resource_type() is no longer supported, use Puppet::Pops::Evaluator::Runtime3ResourceSupport instead")
990
999
  end
991
1000
 
992
1001
  # @api private
993
1002
  def find_builtin_resource_type(type)
994
- raise Puppet::DevError, "Scope#find_builtin_resource_type() is no longer supported, use Puppet::Pops::Evaluator::Runtime3ResourceSupport instead"
1003
+ raise Puppet::DevError, _("Scope#find_builtin_resource_type() is no longer supported, use Puppet::Pops::Evaluator::Runtime3ResourceSupport instead")
995
1004
  end
996
1005
 
997
1006
  # @api private
998
1007
  def find_defined_resource_type(type)
999
- raise Puppet::DevError, "Scope#find_defined_resource_type() is no longer supported, use Puppet::Pops::Evaluator::Runtime3ResourceSupport instead"
1008
+ raise Puppet::DevError, _("Scope#find_defined_resource_type() is no longer supported, use Puppet::Pops::Evaluator::Runtime3ResourceSupport instead")
1000
1009
  end
1001
1010
 
1002
1011
 
@@ -1010,14 +1019,14 @@ class Puppet::Parser::Scope
1010
1019
  if respond_to? method
1011
1020
  send(method, *args)
1012
1021
  else
1013
- raise Puppet::DevError, "Function #{name} not defined despite being loaded!"
1022
+ raise Puppet::DevError, _("Function %{name} not defined despite being loaded!") % { name: name }
1014
1023
  end
1015
1024
  end
1016
1025
 
1017
1026
  # To be removed when enough time has passed after puppet 5.0.0
1018
1027
  # @api private
1019
1028
  def resolve_type_and_titles(type, titles)
1020
- raise Puppet::DevError, "Scope#resolve_type_and_title() is no longer supported, use Puppet::Pops::Evaluator::Runtime3ResourceSupport instead"
1029
+ raise Puppet::DevError, _("Scope#resolve_type_and_title() is no longer supported, use Puppet::Pops::Evaluator::Runtime3ResourceSupport instead")
1021
1030
  end
1022
1031
 
1023
1032
  # Transforms references to classes to the form suitable for
@@ -62,7 +62,7 @@ class Puppet::Parser::TemplateWrapper
62
62
  # @api private
63
63
  def file=(filename)
64
64
  unless @__file__ = Puppet::Parser::Files.find_template(filename, scope.compiler.environment)
65
- raise Puppet::ParseError, "Could not find template '#{filename}'"
65
+ raise Puppet::ParseError, _("Could not find template '%{filename}'") % { filename: filename }
66
66
  end
67
67
  end
68
68
 
@@ -78,7 +78,8 @@ class Puppet::Parser::TemplateWrapper
78
78
  # Expose all the variables in our scope as instance variables of the
79
79
  # current object, making it possible to access them without conflict
80
80
  # to the regular methods.
81
- benchmark(:debug, _("Bound template variables for %{template_source}") % { template_source: template_source }) do
81
+ escaped_template_source = template_source.gsub(/%/, '%%')
82
+ benchmark(:debug, _("Bound template variables for %{template_source} in %%{seconds} seconds") % { template_source: escaped_template_source }) do
82
83
  scope.to_hash.each do |name, value|
83
84
  realname = name.gsub(/[^\w]/, "_")
84
85
  instance_variable_set("@#{realname}", value)
@@ -86,7 +87,7 @@ class Puppet::Parser::TemplateWrapper
86
87
  end
87
88
 
88
89
  result = nil
89
- benchmark(:debug, _("Interpolated template %{template_source}") % { template_source: template_source }) do
90
+ benchmark(:debug, _("Interpolated template %{template_source} in %%{seconds} seconds") % { template_source: escaped_template_source }) do
90
91
  template = ERB.new(string, 0, "-")
91
92
  template.filename = @__file__
92
93
  result = template.result(binding)
@@ -10,7 +10,8 @@ class CollectorTransformer
10
10
  end
11
11
 
12
12
  def transform(o, scope)
13
- raise ArgumentError, "Expected CollectExpression" unless o.is_a? Model::CollectExpression
13
+ #TRANSLATORS 'CollectExpression' is a class name and should not be translated
14
+ raise ArgumentError, _("Expected CollectExpression") unless o.is_a? Model::CollectExpression
14
15
 
15
16
  raise "LHS is not a type" unless o.type_expr.is_a? Model::QualifiedReference
16
17
  type = o.type_expr.value().downcase()
@@ -27,7 +27,7 @@ class Puppet::Pops::Evaluator::Collectors::AbstractCollector
27
27
  @scope = scope
28
28
 
29
29
  if !(overrides.nil? || overrides[:parameters])
30
- raise ArgumentError, "Exported resource try to override without parameters"
30
+ raise ArgumentError, _("Exported resource try to override without parameters")
31
31
  end
32
32
 
33
33
  @overrides = overrides
@@ -4,7 +4,9 @@ class Puppet::Pops::Evaluator::EppEvaluator
4
4
 
5
5
  def self.inline_epp(scope, epp_source, template_args = nil)
6
6
  unless epp_source.is_a?(String)
7
- raise ArgumentError, "inline_epp(): the first argument must be a String with the epp source text, got a #{epp_source.class}"
7
+ #TRANSLATORS 'inline_epp()' is a method name and 'epp' refers to 'Embedded Puppet (EPP) template' and should not be translated
8
+ raise ArgumentError, _("inline_epp(): the first argument must be a String with the epp source text, got a %{class_name}") %
9
+ { class_name: epp_source.class }
8
10
  end
9
11
 
10
12
  # Parse and validate the source
@@ -12,7 +14,8 @@ class Puppet::Pops::Evaluator::EppEvaluator
12
14
  begin
13
15
  result = parser.parse_string(epp_source, 'inlined-epp-text')
14
16
  rescue Puppet::ParseError => e
15
- raise ArgumentError, "inline_epp(): Invalid EPP: #{e.message}"
17
+ #TRANSLATORS 'inline_epp()' is a method name and 'EPP' refers to 'Embedded Puppet (EPP) template' and should not be translated
18
+ raise ArgumentError, _("inline_epp(): Invalid EPP: %{detail}") % { detail: e.message }
16
19
  end
17
20
 
18
21
  # Evaluate (and check template_args)
@@ -21,7 +24,8 @@ class Puppet::Pops::Evaluator::EppEvaluator
21
24
 
22
25
  def self.epp(scope, file, env_name, template_args = nil)
23
26
  unless file.is_a?(String)
24
- raise ArgumentError, "epp(): the first argument must be a String with the filename, got a #{file.class}"
27
+ #TRANSLATORS 'epp()' is a method name and should not be translated
28
+ raise ArgumentError, _("epp(): the first argument must be a String with the filename, got a %{class_name}") % { class_name: file.class }
25
29
  end
26
30
 
27
31
  unless Puppet::FileSystem.exist?(file)
@@ -41,7 +45,8 @@ class Puppet::Pops::Evaluator::EppEvaluator
41
45
  begin
42
46
  result = parser.parse_file(template_file)
43
47
  rescue Puppet::ParseError => e
44
- raise ArgumentError, "epp(): Invalid EPP: #{e.message}"
48
+ #TRANSLATORS 'epp()' is a method name and 'EPP' refers to 'Embedded Puppet (EPP) template' and should not be translated
49
+ raise ArgumentError, _("epp(): Invalid EPP: %{detail}") % { detail: e.message }
45
50
  end
46
51
 
47
52
  # Evaluate (and check template_args)
@@ -55,13 +60,19 @@ class Puppet::Pops::Evaluator::EppEvaluator
55
60
 
56
61
  body = parse_result.body
57
62
  unless body.is_a?(Puppet::Pops::Model::LambdaExpression)
58
- raise ArgumentError, "#{func_name}(): the parser did not produce a LambdaExpression, got '#{body.class}'"
63
+ #TRANSLATORS 'LambdaExpression' is a class name and should not be translated
64
+ raise ArgumentError, _("%{function_name}(): the parser did not produce a LambdaExpression, got '%{class_name}'") %
65
+ { function_name: func_name, class_name: body.class }
59
66
  end
60
67
  unless body.body.is_a?(Puppet::Pops::Model::EppExpression)
61
- raise ArgumentError, "#{func_name}(): the parser did not produce an EppExpression, got '#{body.body.class}'"
68
+ #TRANSLATORS 'EppExpression' is a class name and should not be translated
69
+ raise ArgumentError, _("%{function_name}(): the parser did not produce an EppExpression, got '%{class_name}'") %
70
+ { function_name: func_name, class_name: body.body.class }
62
71
  end
63
72
  unless parse_result.definitions.empty?
64
- raise ArgumentError, "#{func_name}(): The EPP template contains illegal expressions (definitions)"
73
+ #TRANSLATORS 'EPP' refers to 'Embedded Puppet (EPP) template'
74
+ raise ArgumentError, _("%{function_name}(): The EPP template contains illegal expressions (definitions)") %
75
+ { function_name: func_name }
65
76
  end
66
77
 
67
78
  parameters_specified = body.body.parameters_specified
@@ -86,7 +97,9 @@ class Puppet::Pops::Evaluator::EppEvaluator
86
97
  [{}, false]
87
98
  else
88
99
  unless template_args.is_a?(Hash)
89
- raise ArgumentError, "#{func_name}(): the template_args must be a Hash, got a #{template_args.class}"
100
+ #TRANSLATORS 'template_args' is a variable name and should not be translated
101
+ raise ArgumentError, _("%{function_name}(): the template_args must be a Hash, got a %{class_name}") %
102
+ { function_name: func_name, class_name: template_args.class }
90
103
  end
91
104
  [template_args, true]
92
105
  end
@@ -724,7 +724,8 @@ class EvaluatorImpl
724
724
  #evaluate(o.body, scope)
725
725
  rescue Puppet::Pops::Evaluator::PuppetStopIteration => ex
726
726
  # breaking out of a file level program is not allowed
727
- raise Puppet::ParseError.new("break() from context where this is illegal", ex.file, ex.line)
727
+ #TRANSLATOR break() is a method that should not be translated
728
+ raise Puppet::ParseError.new(_("break() from context where this is illegal"), ex.file, ex.line)
728
729
  end
729
730
  end
730
731
 
@@ -19,7 +19,7 @@ module Puppet::Pops::Evaluator::ExternalSyntaxSupport
19
19
  if acceptor.error_count > 0
20
20
  checker_message = "Invalid produced text having syntax: '#{syntax}'."
21
21
  Puppet::Pops::IssueReporter.assert_and_report(acceptor, :message => checker_message)
22
- raise ArgumentError, "Internal Error: Configuration of runtime error handling wrong: should have raised exception"
22
+ raise ArgumentError, _("Internal Error: Configuration of runtime error handling wrong: should have raised exception")
23
23
  end
24
24
  end
25
25
 
@@ -143,7 +143,9 @@ class Runtime3Converter
143
143
  [type_name.nil? ? nil : type_name.sub(/^::/, '').downcase, title.nil? ? '' : title]
144
144
  end
145
145
  else
146
- raise ArgumentError, "Cannot split the type #{catalog_type.class}, it represents neither a PClassType, nor a PResourceType."
146
+ #TRANSLATORS 'PClassType' and 'PResourceType' are Puppet types and should not be translated
147
+ raise ArgumentError, _("Cannot split the type %{class_name}, it represents neither a PClassType, nor a PResourceType.") %
148
+ { class_name: catalog_type.class }
147
149
  end
148
150
  end
149
151
 
@@ -28,7 +28,7 @@ module Runtime3ResourceSupport
28
28
  # from the raised exception. (It may be good enough).
29
29
  unless resolved_type
30
30
  # TODO: do this the right way
31
- raise ArgumentError, "Unknown resource type: '#{type_name}'"
31
+ raise ArgumentError, _("Unknown resource type: '%{type}'") % { type: type_name }
32
32
  end
33
33
 
34
34
  # Build a resource for each title - use the resolved *type* as opposed to a reference
@@ -20,7 +20,7 @@ module Runtime3Support
20
20
  def fail(issue, semantic, options={}, except=nil)
21
21
  optionally_fail(issue, semantic, options, except)
22
22
  # an error should have been raised since fail always fails
23
- raise ArgumentError, "Internal Error: Configuration of runtime error handling wrong: should have raised exception"
23
+ raise ArgumentError, _("Internal Error: Configuration of runtime error handling wrong: should have raised exception")
24
24
  end
25
25
 
26
26
  # Optionally (based on severity) Fails the evaluation of _semantic_ with a given issue
@@ -150,7 +150,7 @@ module Runtime3Support
150
150
  # case - it is just wrong, the error should be reported by the caller who knows in more detail where it
151
151
  # is in the source.
152
152
  #
153
- raise ArgumentError, "Internal error - attempt to create a local scope without a hash" unless hash.is_a?(Hash)
153
+ raise ArgumentError, _("Internal error - attempt to create a local scope without a hash") unless hash.is_a?(Hash)
154
154
  scope.ephemeral_from(hash)
155
155
  end
156
156
 
@@ -288,7 +288,7 @@ module Runtime3Support
288
288
  end
289
289
 
290
290
  # Call via 3x API if function exists there
291
- raise ArgumentError, "Unknown function '#{name}'" unless Puppet::Parser::Functions.function(name)
291
+ raise ArgumentError, _("Unknown function '%{name}'") % { name: name } unless Puppet::Parser::Functions.function(name)
292
292
 
293
293
  # Arguments must be mapped since functions are unaware of the new and magical creatures in 4x.
294
294
  # NOTE: Passing an empty string last converts nil/:undef to empty string
@@ -526,7 +526,7 @@ module Runtime3Support
526
526
  :exception_class => Puppet::PreformattedError
527
527
  })
528
528
  if errors?
529
- raise ArgumentError, "Internal Error: Configuration of runtime error handling wrong: should have raised exception"
529
+ raise ArgumentError, _("Internal Error: Configuration of runtime error handling wrong: should have raised exception")
530
530
  end
531
531
  end
532
532
  end
@@ -79,7 +79,7 @@ class Dispatch < Evaluator::CallableSignature
79
79
  # currently only supports :scope injection
80
80
  scope
81
81
  else
82
- raise_error ArgumentError, "Unknown injection #{injection_data[3]}"
82
+ raise_error ArgumentError, _("Unknown injection %{detail}") % { detail: injection_data[3] }
83
83
  end
84
84
  else
85
85
  # Careful so no new nil arguments are added since they would override default
@@ -108,7 +108,10 @@ class Puppet::Pops::Functions::Function
108
108
  def internal_call_function(scope, function_name, args, &block)
109
109
 
110
110
  the_loader = loader
111
- raise ArgumentError, "Function #{self.class.name}(): cannot call function '#{function_name}' - no loader specified" unless the_loader
111
+ unless the_loader
112
+ raise ArgumentError, _("Function %{class_name}(): cannot call function '%{function_name}' - no loader specified") %
113
+ { class_name: self.class.name, function_name: function_name }
114
+ end
112
115
 
113
116
  func = the_loader.load(:function, function_name)
114
117
  if func
@@ -121,7 +124,10 @@ class Puppet::Pops::Functions::Function
121
124
  # about where in a puppet manifest this error originates. (Such information is not available here).
122
125
  loader_scope = closure_scope
123
126
  func_3x = Puppet::Parser::Functions.function(function_name, loader_scope.environment) if loader_scope.is_a?(Puppet::Parser::Scope)
124
- raise ArgumentError, "Function #{self.class.name}(): Unknown function: '#{function_name}'" unless func_3x
127
+ unless func_3x
128
+ raise ArgumentError, _("Function %{class_name}(): Unknown function: '%{function_name}'") %
129
+ { class_name: self.class.name, function_name: function_name }
130
+ end
125
131
 
126
132
  # Call via 3x API
127
133
  # Arguments must be mapped since functions are unaware of the new and magical creatures in 4x.
@@ -68,8 +68,13 @@ class IssueReporter
68
68
  emitted += 1
69
69
  break if emitted >= max_errors
70
70
  end
71
- warnings_message = (emit_warnings && warnings.size > 0) ? ", and #{warnings.size} warnings" : ""
72
- giving_up_message = "Language validation logged #{errors.size} errors#{warnings_message}. Giving up"
71
+ giving_up_message = if (emit_warnings && warnings.size > 0)
72
+ _("Language validation logged %{error_count} errors, and %{warning_count} warnings. Giving up") %
73
+ { error_count: errors.size, warning_count: warnings.size }
74
+ else
75
+ _("Language validation logged %{error_count} errors. Giving up") %
76
+ { error_count: errors.size }
77
+ end
73
78
  exception = emit_exception.new(giving_up_message)
74
79
  exception.file = errors[0].file
75
80
  raise exception
@@ -774,9 +774,12 @@ module Issues
774
774
  end
775
775
 
776
776
  HIERA_BACKEND_MULTIPLY_DEFINED = hard_issue :HIERA_BACKEND_MULTIPLY_DEFINED, :name, :first_line do
777
- msg = _("Backend '%{name}' is defined more than once") % { name: name }
777
+ msg = _("Backend '%{name}' is defined more than once.") % { name: name }
778
778
  fl = first_line
779
- fl ? _("%{msg}. First defined at line %{line}") % { msg: msg, line: fl } : msg
779
+ if fl
780
+ msg += ' ' + _("First defined at %{error_location}") % { error_location: Puppet::Util::Errors.error_location(nil, fl) }
781
+ end
782
+ msg
780
783
  end
781
784
 
782
785
  HIERA_NO_PROVIDER_FOR_BACKEND = hard_issue :HIERA_NO_PROVIDER_FOR_BACKEND, :name do
@@ -784,9 +787,12 @@ module Issues
784
787
  end
785
788
 
786
789
  HIERA_HIERARCHY_NAME_MULTIPLY_DEFINED = hard_issue :HIERA_HIERARCHY_NAME_MULTIPLY_DEFINED, :name, :first_line do
787
- msg = _("Hierarchy name '%{name}' defined more than once") % { name: name }
790
+ msg = _("Hierarchy name '%{name}' defined more than once.") % { name: name }
788
791
  fl = first_line
789
- fl ? _("%{msg}. First defined at line %{line}") % { msg: msg, line: fl } : msg
792
+ if fl
793
+ msg += ' ' + _("First defined at %{error_location}") % { error_location: Puppet::Util::Errors.error_location(nil, fl) }
794
+ end
795
+ msg
790
796
  end
791
797
 
792
798
  HIERA_V3_BACKEND_NOT_GLOBAL = hard_issue :HIERA_V3_BACKEND_NOT_GLOBAL do
@@ -73,7 +73,7 @@ module Puppet::Pops::LabelProvider
73
73
  end
74
74
 
75
75
  if char == ""
76
- raise Puppet::DevError, "<#{string}> does not appear to contain a word"
76
+ raise Puppet::DevError, _("<%{string}> does not appear to contain a word") % { string: string }
77
77
  end
78
78
 
79
79
  char
@@ -98,7 +98,8 @@ module ModuleLoaders
98
98
  @loaders = loaders
99
99
  @loadables = loadables
100
100
  unless (loadables - LOADABLE_KINDS).empty?
101
- raise ArgumentError, 'given loadables are not of supported loadable kind'
101
+ #TRANSLATORS 'loadables' is a variable containing loadable modules and should not be translated
102
+ raise ArgumentError, _('given loadables are not of supported loadable kind')
102
103
  end
103
104
  loaders.add_loader_by_name(self)
104
105
  end
@@ -149,7 +150,9 @@ module ModuleLoaders
149
150
  return set_entry(typed_name, value, origin)
150
151
  end
151
152
 
152
- raise ArgumentError,"The code loaded from #{origin} does not define the TypeSet '#{module_name.capitalize}'"
153
+ #TRANSLATORS 'TypeSet' should not be translated
154
+ raise ArgumentError, _("The code loaded from %{origin} does not define the TypeSet '%{module_name}'") %
155
+ { origin: origin, module_name: module_name.capitalize }
153
156
  end
154
157
  else
155
158
  # anything else cannot possibly be in this module
@@ -6,7 +6,7 @@ module Loader
6
6
  class StaticLoader < Loader
7
7
 
8
8
  BUILTIN_TYPE_NAMES = %w{
9
- Auegas
9
+ Augeas
10
10
  Component
11
11
  Computer
12
12
  Cron
@@ -152,7 +152,7 @@ class Loaders
152
152
  # @api private
153
153
  def self.loaders
154
154
  loaders = Puppet.lookup(:loaders) { nil }
155
- raise Puppet::ParseError, "Internal Error: Puppet Context ':loaders' missing" if loaders.nil?
155
+ raise Puppet::ParseError, _("Internal Error: Puppet Context ':loaders' missing") if loaders.nil?
156
156
  loaders
157
157
  end
158
158
 
@@ -186,7 +186,9 @@ class Loaders
186
186
  # TODO : Later check if definition is private, and then add it to private_loader_for_module
187
187
  #
188
188
  loader = public_loader_for_module(module_name)
189
- raise Puppet::ParseError, "Internal Error: did not find public loader for module: '#{module_name}'" if loader.nil?
189
+ if loader.nil?
190
+ raise Puppet::ParseError, _("Internal Error: did not find public loader for module: '%{module_name}'") % { module_name: module_name }
191
+ end
190
192
  loader
191
193
  end
192
194
  end
@@ -225,7 +227,9 @@ class Loaders
225
227
 
226
228
  def add_loader_by_name(loader)
227
229
  name = loader.loader_name
228
- raise Puppet::ParseError, "Internal Error: Attempt to redefine loader named '#{name}'" if @loaders_by_name.include?(name)
230
+ if @loaders_by_name.include?(name)
231
+ raise Puppet::ParseError, _("Internal Error: Attempt to redefine loader named '%{name}'") % { name: name }
232
+ end
229
233
  @loaders_by_name[name] = loader
230
234
  end
231
235
 
@@ -491,7 +491,8 @@ module Lookup
491
491
  when :invalid_key
492
492
  ExplainInvalidKey.new(@current, qualifier)
493
493
  else
494
- raise ArgumentError, "Unknown Explain type #{qualifier_type}"
494
+ #TRANSLATORS 'Explain' is referring to the 'Explainer' class and should not be translated
495
+ raise ArgumentError, _("Unknown Explain type %{qualifier_type}") % { qualifier_type: qualifier_type }
495
496
  end
496
497
  @current.branches << node
497
498
  @current = node