puppet 5.3.3-x64-mingw32 → 5.3.4-x64-mingw32

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 +3445 -3416
  290. checksums.yaml +0 -7
  291. data/spec/unit/gettext_config_spec.rb +0 -57
@@ -67,9 +67,7 @@ module Puppet::Util::InstanceLoader
67
67
  unless instances.include? name
68
68
  if instance_loader(type).load(name)
69
69
  unless instances.include? name
70
- Puppet.warning(
71
- _("Loaded %{type} file for %{name} but %{type} was not defined") % { type: type, name: name }
72
- )
70
+ Puppet.warning(_("Loaded %{type} file for %{name} but %{type} was not defined") % { type: type, name: name })
73
71
  return nil
74
72
  end
75
73
  else
@@ -44,7 +44,8 @@ class Puppet::Util::Ldap::Manager
44
44
  # Open, yield, and close the connection. Cannot be left
45
45
  # open, at this point.
46
46
  def connect
47
- raise ArgumentError, "You must pass a block to #connect" unless block_given?
47
+ #TRANSLATORS '#connect' is a method name and and should not be translated, 'block' refers to a Ruby code block
48
+ raise ArgumentError, _("You must pass a block to #connect") unless block_given?
48
49
 
49
50
  unless @connection
50
51
  if Puppet[:ldaptls]
@@ -85,7 +86,8 @@ class Puppet::Util::Ldap::Manager
85
86
 
86
87
  # Convert an ldap-style entry hash to a provider-style hash.
87
88
  def entry2provider(entry)
88
- raise ArgumentError, "Could not get dn from ldap entry" unless entry["dn"]
89
+ #TRANSLATOR 'dn' refers to a 'distinguished name' in LDAP (Lightweight Directory Access Protocol) and they should not be translated
90
+ raise ArgumentError, _("Could not get dn from ldap entry") unless entry["dn"]
89
91
 
90
92
  # DN is always a single-entry array. Strip off the bits before the
91
93
  # first comma, then the bits after the remaining equal sign. This is the
@@ -137,7 +139,8 @@ class Puppet::Util::Ldap::Manager
137
139
 
138
140
  if generator.source
139
141
  unless value = values[generator.source]
140
- raise ArgumentError, "#{generator.source} must be defined to generate #{generator.name}"
142
+ raise ArgumentError, _("%{source} must be defined to generate %{name}") %
143
+ { source: generator.source, name: generator.name }
141
144
  end
142
145
  result = generator.generate(value)
143
146
  else
@@ -63,7 +63,8 @@ class Puppet::Util::Log
63
63
  destinations.keys.each { |dest|
64
64
  close(dest)
65
65
  }
66
- raise Puppet::DevError.new("Log.close_all failed to close #{@destinations.keys.inspect}") if !@destinations.empty?
66
+ #TRANSLATORS "Log.close_all" is a method name and should not be translated
67
+ raise Puppet::DevError.new(_("Log.close_all failed to close %{destinations}") % { destinations: @destinations.keys.inspect }) if !@destinations.empty?
67
68
  end
68
69
 
69
70
  # Flush any log destinations that support such operations.
@@ -82,8 +83,8 @@ class Puppet::Util::Log
82
83
  # Create a new log message. The primary role of this method is to
83
84
  # avoid creating log messages below the loglevel.
84
85
  def Log.create(hash)
85
- raise Puppet::DevError, "Logs require a level" unless hash.include?(:level)
86
- raise Puppet::DevError, "Invalid log level #{hash[:level]}" unless @levels.index(hash[:level])
86
+ raise Puppet::DevError, _("Logs require a level") unless hash.include?(:level)
87
+ raise Puppet::DevError, _("Invalid log level %{level}") % { level: hash[:level] } unless @levels.index(hash[:level])
87
88
  @levels.index(hash[:level]) >= @loglevel ? Puppet::Util::Log.new(hash) : nil
88
89
  end
89
90
 
@@ -105,7 +106,7 @@ class Puppet::Util::Log
105
106
  def Log.level=(level)
106
107
  level = level.intern unless level.is_a?(Symbol)
107
108
 
108
- raise Puppet::DevError, "Invalid loglevel #{level}" unless @levels.include?(level)
109
+ raise Puppet::DevError, _("Invalid loglevel %{level}") % { level: level } unless @levels.include?(level)
109
110
 
110
111
  @loglevel = @levels.index(level)
111
112
 
@@ -132,7 +133,7 @@ class Puppet::Util::Log
132
133
  return
133
134
  end
134
135
 
135
- raise Puppet::DevError, "Unknown destination type #{dest}" unless type
136
+ raise Puppet::DevError, _("Unknown destination type %{dest}") % { dest: dest} unless type
136
137
 
137
138
  begin
138
139
  if type.instance_method(:initialize).arity == 1
@@ -168,10 +169,11 @@ class Puppet::Util::Log
168
169
  def Log.coerce_string(str)
169
170
  return Puppet::Util::CharacterEncoding.convert_to_utf_8(str) if str.valid_encoding?
170
171
 
171
- annotated_string = _("Received a Log attribute with invalid encoding:")
172
- annotated_string << Puppet::Util::CharacterEncoding.convert_to_utf_8(str.dump) << "\n"
173
172
  # We only select the last 10 callers in the stack to avoid being spammy
174
- annotated_string << _("Backtrace:") << "\n" << caller[0..10].join("\n")
173
+ message = _("Received a Log attribute with invalid encoding:%{log_message}") %
174
+ { log_message: Puppet::Util::CharacterEncoding.convert_to_utf_8(str.dump)}
175
+ message += '\n' + _("Backtrace:\n%{backtrace}") % { backtrace: caller[0..10].join("\n") }
176
+ message
175
177
  end
176
178
 
177
179
  public
@@ -357,15 +359,18 @@ class Puppet::Util::Log
357
359
  end
358
360
 
359
361
  def message=(msg)
360
- raise ArgumentError, "Puppet::Util::Log requires a message" unless msg
362
+ #TRANSLATORS 'Puppet::Util::Log' refers to a Puppet source code class
363
+ raise ArgumentError, _("Puppet::Util::Log requires a message") unless msg
361
364
  @message = msg.to_s
362
365
  end
363
366
 
364
367
  def level=(level)
365
- raise ArgumentError, "Puppet::Util::Log requires a log level" unless level
366
- raise ArgumentError, "Puppet::Util::Log requires a symbol or string" unless level.respond_to? "to_sym"
368
+ #TRANSLATORS 'Puppet::Util::Log' refers to a Puppet source code class
369
+ raise ArgumentError, _("Puppet::Util::Log requires a log level") unless level
370
+ #TRANSLATORS 'Puppet::Util::Log' refers to a Puppet source code class
371
+ raise ArgumentError, _("Puppet::Util::Log requires a symbol or string") unless level.respond_to? "to_sym"
367
372
  @level = level.to_sym
368
- raise ArgumentError, "Invalid log level #{@level}" unless self.class.validlevel?(@level)
373
+ raise ArgumentError, _("Invalid log level %{level}") % { level: @level } unless self.class.validlevel?(@level)
369
374
 
370
375
  # Tag myself with my log level
371
376
  tag(level)
@@ -394,18 +399,8 @@ class Puppet::Util::Log
394
399
  # Issue based messages do not have details in the message. It
395
400
  # must be appended here
396
401
  unless issue_code.nil?
397
- msg = _("Could not parse for environment %{env}: %{msg}") % { env: environment, msg: msg } unless environment.nil?
398
- if file && line && pos
399
- msg = _("%{msg} at %{file}:%{line}:%{pos}") % { msg: msg, file: file, line: line, pos: pos }
400
- elsif file and line
401
- msg = _("%{msg} at %{file}:%{line}") % { msg: msg, file: file, line: line }
402
- elsif line && pos
403
- msg = _("%{msg} at line %{line}:%{pos}") % { msg: msg, line: line, pos: pos }
404
- elsif line
405
- msg = _("%{msg} at line %{line}") % { msg: msg, line: line }
406
- elsif file
407
- msg = _("%{msg} in %{file}") % { msg: msg, file: file }
408
- end
402
+ msg = _("Could not parse for environment %{environment}: %{msg}") % { environment: environment, msg: msg } unless environment.nil?
403
+ msg += Puppet::Util::Errors.error_location_with_space(file, line, pos)
409
404
  msg = _("%{msg} on node %{node}") % { msg: msg, node: node } unless node.nil?
410
405
  if @backtrace.is_a?(Array)
411
406
  msg += "\n"
@@ -1,7 +1,6 @@
1
1
  # A module to make logging a bit easier.
2
2
  require 'puppet/util/log'
3
3
  require 'puppet/error'
4
- require 'puppet/util/multi_match.rb'
5
4
 
6
5
  require 'facter'
7
6
 
@@ -146,16 +145,12 @@ module Logging
146
145
  key = options[:key]
147
146
  file = options[:file]
148
147
  line = options[:line]
149
- raise(Puppet::DevError, "Need either :file and :line, or :key") if (key.nil?) && (file.nil? || line.nil?)
148
+ #TRANSLATORS the literals ":file", ":line", and ":key" should not be translated
149
+ raise Puppet::DevError, _("Need either :file and :line, or :key") if (key.nil?) && (file.nil? || line.nil?)
150
150
 
151
151
  key ||= "#{file}:#{line}"
152
152
  issue_deprecation_warning(message, key, file, line, false)
153
153
  end
154
- MM = MultiMatch
155
- FILE_AND_LINE = MM::TUPLE
156
- FILE_NO_LINE = MM.new(MM::NOT_NIL, nil).freeze
157
- NO_FILE_LINE = MM.new(nil, MM::NOT_NIL).freeze
158
- SUPPRESS_FILE_LINE = MM.new(:default, :default).freeze
159
154
 
160
155
  # Logs a (non deprecation) warning once for a given key.
161
156
  #
@@ -175,19 +170,17 @@ module Logging
175
170
  if $unique_warnings.length < 100 then
176
171
  if (! $unique_warnings.has_key?(key)) then
177
172
  $unique_warnings[key] = message
178
- call_trace =
179
- case MM.new(file, line)
180
- when SUPPRESS_FILE_LINE
181
- ''
182
- when FILE_AND_LINE
183
- _("\n (at %{file}:%{line})") % { file: file, line: line }
184
- when FILE_NO_LINE
185
- _("\n (in %{file})") % { file: file }
186
- when NO_FILE_LINE
187
- _("\n (in unknown file, line %{line})") % { line: line }
188
- else
189
- _("\n (file & line not available)")
190
- end
173
+ call_trace = if file == :default and line == :default
174
+ # Suppress the file and line number output
175
+ ''
176
+ else
177
+ error_location_str = Puppet::Util::Errors.error_location(file, line)
178
+ if error_location_str.empty?
179
+ '\n ' + _('(file & line not available)')
180
+ else
181
+ "\n %{error_location}" % { error_location: error_location_str }
182
+ end
183
+ end
191
184
  send_log(level, "#{message}#{call_trace}")
192
185
  end
193
186
  end
@@ -279,17 +272,17 @@ module Logging
279
272
  def issue_deprecation_warning(message, key, file, line, use_caller)
280
273
  return if Puppet[:disable_warnings].include?('deprecations')
281
274
  $deprecation_warnings ||= {}
282
- if $deprecation_warnings.length < 100 then
275
+ if $deprecation_warnings.length < 100
283
276
  key ||= (offender = get_deprecation_offender)
284
- if (! $deprecation_warnings.has_key?(key)) then
277
+ unless $deprecation_warnings.has_key?(key)
285
278
  $deprecation_warnings[key] = message
286
279
  # split out to allow translation
287
- unknown = _('unknown')
288
- call_trace = use_caller ?
289
- (offender || get_deprecation_offender).join('; ') :
290
- "#{file || unknown}:#{line || unknown}"
291
- #TRANSLATORS error message with origin location
292
- warning(_("%{message}\n (at %{call_trace})") % { message: message, call_trace: call_trace })
280
+ call_trace = if use_caller
281
+ _("(location: %{location})") % { location: (offender || get_deprecation_offender).join('; ') }
282
+ else
283
+ Puppet::Util::Errors.error_location_with_unknowns(file, line)
284
+ end
285
+ warning("%{message}\n %{call_trace}" % { message: message, call_trace: call_trace })
293
286
  end
294
287
  end
295
288
  end
@@ -13,7 +13,7 @@ module Puppet::Util::MethodHelper
13
13
  if respond_to? method
14
14
  self.send(method, value)
15
15
  else
16
- raise ArgumentError, "Invalid parameter #{param} to object class #{self.class}"
16
+ raise ArgumentError, _("Invalid parameter %{parameter} to object class %{class_name}") % { parameter: param, class_name: self.class }
17
17
  end
18
18
  end
19
19
  end
@@ -9,7 +9,7 @@ module Puppet::Util::NagiosMaker
9
9
  name = name.to_sym
10
10
  full_name = ("nagios_#{name}").to_sym
11
11
 
12
- raise(Puppet::DevError, "No nagios type for #{name}") unless nagtype = Nagios::Base.type(name)
12
+ raise Puppet::DevError, _("No nagios type for %{name}") % { name: name } unless nagtype = Nagios::Base.type(name)
13
13
 
14
14
  type = Puppet::Type.newtype(full_name) do
15
15
 
@@ -39,34 +39,41 @@ class Puppet::Util::NetworkDevice::Config
39
39
  begin
40
40
  devices = {}
41
41
  device = nil
42
- File.open(@file) { |f|
43
- count = 1
44
- f.each { |line|
42
+ File.open(@file) do |f|
43
+ file_line_count = 1
44
+ f.each do |line|
45
45
  case line
46
46
  when /^\s*#/ # skip comments
47
- count += 1
47
+ file_line_count += 1
48
48
  next
49
49
  when /^\s*$/ # skip blank lines
50
- count += 1
50
+ file_line_count += 1
51
51
  next
52
52
  when /^\[([\w.-]+)\]\s*$/ # [device.fqdn]
53
53
  name = $1
54
54
  name.chomp!
55
- raise Puppet::Error, _("Duplicate device found at line %{count}, already found at %{line}") % { count: count, line: device.line } if devices.include?(name)
55
+ if devices.include?(name)
56
+ file_error_location = Puppet::Util::Errors.error_location(nil, file_line_count)
57
+ device_error_location = Puppet::Util::Errors.error_location(nil, device.line)
58
+ raise Puppet::Error, _("Duplicate device found at %{file_error_location}, already found at %{device_error_location}") %
59
+ { file_error_location: file_error_location, device_error_location: device_error_location }
60
+ end
56
61
  device = OpenStruct.new
57
62
  device.name = name
58
- device.line = count
63
+ device.line = file_line_count
59
64
  device.options = { :debug => false }
60
65
  Puppet.debug "found device: #{device.name} at #{device.line}"
61
66
  devices[name] = device
62
67
  when /^\s*(type|url|debug)(\s+(.+)\s*)*$/
63
- parse_directive(device, $1, $3, count)
68
+ parse_directive(device, $1, $3, file_line_count)
64
69
  else
65
- raise Puppet::Error, _("Invalid line %{count}: %{line}") % { count: count, line: line }
70
+ error_location_str = Puppet::Util::Errors.error_location(nil, file_line_count)
71
+ raise Puppet::Error, _("Invalid entry at %{error_location}: %{file_text}") %
72
+ { error_location: error_location_str, file_text: line }
66
73
  end
67
- count += 1
68
- }
69
- }
74
+ file_line_count += 1
75
+ end
76
+ end
70
77
  rescue Errno::EACCES => detail
71
78
  Puppet.err _("Configuration error: Cannot read %{file}; cannot serve") % { file: @file }
72
79
  #raise Puppet::Error, "Cannot read #{@config}"
@@ -91,7 +98,8 @@ class Puppet::Util::NetworkDevice::Config
91
98
  when "debug"
92
99
  device.options[:debug] = true
93
100
  else
94
- raise Puppet::Error, _("Invalid argument '%{var}' at line %{count}") % { var: var, count: count }
101
+ error_location_str = Puppet::Util::Errors.error_location(nil, count)
102
+ raise Puppet::Error, _("Invalid argument '%{var}' at %{error_location}") % { var: var, error_location: error_location_str }
95
103
  end
96
104
  end
97
105
 
@@ -45,7 +45,9 @@ module Puppet::Util::Plist
45
45
  {:failonfail => true, :combine => true})
46
46
  return parse_plist(plist)
47
47
  rescue Puppet::ExecutionFailure => detail
48
- Puppet.warning(_("Cannot read file %{file_path}; Puppet is skipping it.\n") % { file_path: file_path } + _("Details: %{detail}") % { detail: detail })
48
+ message = _("Cannot read file %{file_path}; Puppet is skipping it.") % { file_path: file_path }
49
+ message += '\n' + _("Details: %{detail}") % { detail: detail }
50
+ Puppet.warning(message)
49
51
  end
50
52
  end
51
53
  return nil
@@ -17,7 +17,7 @@ module Puppet::Util::POSIX
17
17
  # method search_posix_field in the gid and uid methods if a sanity check
18
18
  # fails
19
19
  def get_posix_field(space, field, id)
20
- raise Puppet::DevError, "Did not get id from caller" unless id
20
+ raise Puppet::DevError, _("Did not get id from caller") unless id
21
21
 
22
22
  if id.is_a?(Integer)
23
23
  if id > Puppet[:maximum_uid].to_i
@@ -63,7 +63,7 @@ module Puppet::Util::ProviderFeatures
63
63
  # @todo How methods that determine if the feature is present are specified.
64
64
  def feature(name, docs, hash = {})
65
65
  @features ||= {}
66
- raise(Puppet::DevError, "Feature #{name} is already defined") if @features.include?(name)
66
+ raise Puppet::DevError, _("Feature %{name} is already defined") % { name: name } if @features.include?(name)
67
67
  begin
68
68
  obj = ProviderFeature.new(name, docs, hash)
69
69
  @features[obj.name] = obj
@@ -245,7 +245,7 @@ module Generators
245
245
  end
246
246
  end
247
247
 
248
- def gen_composite_index(collection, template, filename)\
248
+ def gen_composite_index(collection, template, filename)
249
249
  return if Puppet::FileSystem.exist?(filename)
250
250
 
251
251
  template = TemplatePage.new(RDoc::Page::FR_INDEX_BODY, template)
@@ -13,8 +13,7 @@ class Puppet::Util::Reference
13
13
  instance_load(:reference, 'puppet/reference')
14
14
 
15
15
  def self.footer
16
- #TRANSLATORS message accompanied by date of generation
17
- "\n\n----------------\n\n*" + _("This page autogenerated on ") + "#{Time.now}*\n"
16
+ "\n\n----------------\n\n" + _("*This page autogenerated on %{current_time}*\n") % { current_time: Time.now.to_s }
18
17
  end
19
18
 
20
19
  def self.modes
@@ -113,7 +112,7 @@ class Puppet::Util::Reference
113
112
  # First the header
114
113
  text = markdown_header(@title, 1)
115
114
  #TRANSLATORS message accompanied by date of generation
116
- text << _("\n\n**This page is autogenerated; any changes will get overwritten** *(last generated on ") + "#{Time.now.to_s})*\n\n"
115
+ text << _("\n\n**This page is autogenerated; any changes will get overwritten** *(last generated on %{current_time})*\n\n") % { current_time: Time.now.to_s }
117
116
 
118
117
  text << @header
119
118
 
@@ -240,7 +240,7 @@ module Puppet::Util::SELinux
240
240
  # while we try and figure out what file-system the target lives on.
241
241
  path = Pathname(path).cleanpath
242
242
  unless path.absolute?
243
- raise Puppet::DevError, "got a relative path in SELinux find_fs: #{path}"
243
+ raise Puppet::DevError, _("got a relative path in SELinux find_fs: %{path}") % { path: path }
244
244
  end
245
245
 
246
246
  # Now, walk up the tree until we find a match for that path in the hash.
@@ -53,7 +53,7 @@ class Puppet::Util::Storage
53
53
  Puppet.warning(_("Checksumfile %{filename} is not a file, ignoring") % { filename: filename })
54
54
  return
55
55
  end
56
- Puppet::Util.benchmark(:debug, "Loaded state") do
56
+ Puppet::Util.benchmark(:debug, "Loaded state in %{seconds} seconds") do
57
57
  begin
58
58
  @@state = Puppet::Util::Yaml.load_file(filename)
59
59
  rescue Puppet::Util::Yaml::YamlLoadError => detail
@@ -82,7 +82,7 @@ class Puppet::Util::Storage
82
82
 
83
83
  Puppet.info _("Creating state file %{file}") % { file: Puppet[:statefile] } unless Puppet::FileSystem.exist?(Puppet[:statefile])
84
84
 
85
- Puppet::Util.benchmark(:debug, "Stored state") do
85
+ Puppet::Util.benchmark(:debug, "Stored state in %{seconds} seconds") do
86
86
  Puppet::Util::Yaml.dump(@@state, Puppet[:statefile])
87
87
  end
88
88
  end
@@ -31,7 +31,8 @@ class Puppet::Util::Windows::EventLog
31
31
  def initialize(source_name = 'Puppet')
32
32
  @eventlog_handle = RegisterEventSourceW(FFI::Pointer::NULL, wide_string(source_name))
33
33
  if @eventlog_handle == NULL_HANDLE
34
- raise EventLogError.new("RegisterEventSourceW failed to open Windows eventlog", FFI.errno)
34
+ #TRANSLATORS 'Windows' is the operating system and 'RegisterEventSourceW' is a API call and should not be translated
35
+ raise EventLogError.new(_("RegisterEventSourceW failed to open Windows eventlog"), FFI.errno)
35
36
  end
36
37
  end
37
38
 
@@ -55,7 +56,9 @@ class Puppet::Util::Windows::EventLog
55
56
  # @return [void]
56
57
  # @api public
57
58
  def report_event(args = {})
58
- raise ArgumentError, "data must be a string, not #{args[:data].class}" unless args[:data].is_a?(String)
59
+ unless args[:data].is_a?(String)
60
+ raise ArgumentError, _("data must be a string, not %{class_name}") % { class_name: args[:data].class }
61
+ end
59
62
  from_string_to_wide_string(args[:data]) do |message_ptr|
60
63
  FFI::MemoryPointer.new(:pointer) do |message_array_ptr|
61
64
  message_array_ptr.write_pointer(message_ptr)
@@ -69,7 +72,8 @@ class Puppet::Util::Windows::EventLog
69
72
  num_strings, raw_data_size, message_array_ptr, raw_data)
70
73
 
71
74
  if report_result == WIN32_FALSE
72
- raise EventLogError.new("ReportEventW failed to report event to Windows eventlog", FFI.errno)
75
+ #TRANSLATORS 'Windows' is the operating system and 'ReportEventW' is a API call and should not be translated
76
+ raise EventLogError.new(_("ReportEventW failed to report event to Windows eventlog"), FFI.errno)
73
77
  end
74
78
  end
75
79
  end
@@ -92,7 +96,7 @@ class Puppet::Util::Windows::EventLog
92
96
  when :err,:alert,:emerg,:crit
93
97
  [EVENTLOG_ERROR_TYPE, 0x03]
94
98
  else
95
- raise ArgumentError, "Invalid log level #{level}"
99
+ raise ArgumentError, _("Invalid log level %{level}") % { level: level }
96
100
  end
97
101
  end
98
102
  end
@@ -110,7 +114,8 @@ class Puppet::Util::Windows::EventLog
110
114
  else
111
115
  class EventLogError < RuntimeError
112
116
  def initialize(msg, code)
113
- super(msg + " (Win32 error: #{code})")
117
+ #TRANSLATORS 'Win32' is the Windows API and should not be translated
118
+ super(msg + ' ' + _("(Win32 error: %{detail})") % { detail: code})
114
119
  end
115
120
  end
116
121
  end
@@ -111,11 +111,15 @@ module Puppet::Util::Windows::File
111
111
 
112
112
  # return true if path exists and it's not a symlink
113
113
  # Other file attributes are ignored. https://msdn.microsoft.com/en-us/library/windows/desktop/gg258117(v=vs.85).aspx
114
- return true if (result & FILE_ATTRIBUTE_REPARSE_POINT) != FILE_ATTRIBUTE_REPARSE_POINT
115
-
116
- # walk the symlink and try again...
117
- seen_paths << path.downcase
118
- path = readlink(path)
114
+ reparse_point = (result & FILE_ATTRIBUTE_REPARSE_POINT) == FILE_ATTRIBUTE_REPARSE_POINT
115
+ if reparse_point && symlink_reparse_point?(path)
116
+ # walk the symlink and try again...
117
+ seen_paths << path.downcase
118
+ path = readlink(path)
119
+ else
120
+ # file was found and its not a symlink
121
+ return true
122
+ end
119
123
  end
120
124
 
121
125
  false
@@ -177,6 +181,18 @@ module Puppet::Util::Windows::File
177
181
  "#{flags_and_attributes.to_s(8)}, #{template_file_handle})")
178
182
  end
179
183
 
184
+ IO_REPARSE_TAG_MOUNT_POINT = 0xA0000003
185
+ IO_REPARSE_TAG_HSM = 0xC0000004
186
+ IO_REPARSE_TAG_HSM2 = 0x80000006
187
+ IO_REPARSE_TAG_SIS = 0x80000007
188
+ IO_REPARSE_TAG_WIM = 0x80000008
189
+ IO_REPARSE_TAG_CSV = 0x80000009
190
+ IO_REPARSE_TAG_DFS = 0x8000000A
191
+ IO_REPARSE_TAG_SYMLINK = 0xA000000C
192
+ IO_REPARSE_TAG_DFSR = 0x80000012
193
+ IO_REPARSE_TAG_DEDUP = 0x80000013
194
+ IO_REPARSE_TAG_NFS = 0x80000014
195
+
180
196
  def self.get_reparse_point_data(handle, &block)
181
197
  # must be multiple of 1024, min 10240
182
198
  FFI::MemoryPointer.new(MAXIMUM_REPARSE_DATA_BUFFER_SIZE) do |reparse_data_buffer_ptr|
@@ -184,11 +200,11 @@ module Puppet::Util::Windows::File
184
200
 
185
201
  reparse_tag = reparse_data_buffer_ptr.read_win32_ulong
186
202
  buffer_type = case reparse_tag
187
- when 0xA000000C
203
+ when IO_REPARSE_TAG_SYMLINK
188
204
  SYMLINK_REPARSE_DATA_BUFFER
189
- when 0xA0000003
205
+ when IO_REPARSE_TAG_MOUNT_POINT
190
206
  MOUNT_POINT_REPARSE_DATA_BUFFER
191
- when 0x80000014
207
+ when IO_REPARSE_TAG_NFS
192
208
  raise Puppet::Util::Windows::Error.new("Retrieving NFS reparse point data is unsupported")
193
209
  else
194
210
  raise Puppet::Util::Windows::Error.new("DeviceIoControl(#{handle}, " +
@@ -202,6 +218,20 @@ module Puppet::Util::Windows::File
202
218
  nil
203
219
  end
204
220
 
221
+ def self.get_reparse_point_tag(handle)
222
+ reparse_tag = nil
223
+
224
+ # must be multiple of 1024, min 10240
225
+ FFI::MemoryPointer.new(MAXIMUM_REPARSE_DATA_BUFFER_SIZE) do |reparse_data_buffer_ptr|
226
+ device_io_control(handle, FSCTL_GET_REPARSE_POINT, nil, reparse_data_buffer_ptr)
227
+
228
+ # DWORD ReparseTag is the first member of the struct
229
+ reparse_tag = reparse_data_buffer_ptr.read_win32_ulong
230
+ end
231
+
232
+ reparse_tag
233
+ end
234
+
205
235
  def self.device_io_control(handle, io_control_code, in_buffer = nil, out_buffer = nil)
206
236
  if out_buffer.nil?
207
237
  raise Puppet::Util::Windows::Error.new(_("out_buffer is required"))
@@ -229,12 +259,18 @@ module Puppet::Util::Windows::File
229
259
  end
230
260
 
231
261
  FILE_ATTRIBUTE_REPARSE_POINT = 0x400
232
- def symlink?(file_name)
262
+ def reparse_point?(file_name)
233
263
  attributes = get_attributes(file_name, false)
234
264
 
235
265
  return false if (attributes == INVALID_FILE_ATTRIBUTES)
236
266
  (attributes & FILE_ATTRIBUTE_REPARSE_POINT) == FILE_ATTRIBUTE_REPARSE_POINT
237
267
  end
268
+ module_function :reparse_point?
269
+
270
+ def symlink?(file_name)
271
+ # Puppet currently only handles mount point and symlink reparse points, ignores others
272
+ reparse_point?(file_name) && symlink_reparse_point?(file_name)
273
+ end
238
274
  module_function :symlink?
239
275
 
240
276
  GENERIC_READ = 0x80000000
@@ -375,6 +411,22 @@ module Puppet::Util::Windows::File
375
411
  path
376
412
  end
377
413
 
414
+ # these reparse point types are the only ones Puppet currently understands
415
+ # so rather than raising an exception in readlink, prefer to not consider
416
+ # the path a symlink when stat'ing later
417
+ def self.symlink_reparse_point?(path)
418
+ symlink = false
419
+
420
+ open_symlink(path) do |handle|
421
+ symlink = [
422
+ IO_REPARSE_TAG_SYMLINK,
423
+ IO_REPARSE_TAG_MOUNT_POINT
424
+ ].include?(get_reparse_point_tag(handle))
425
+ end
426
+
427
+ symlink
428
+ end
429
+
378
430
  ffi_convention :stdcall
379
431
 
380
432
  # https://msdn.microsoft.com/en-us/library/windows/desktop/aa365512(v=vs.85).aspx