bolt 0.15.0 → 0.16.0

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 (205) hide show
  1. checksums.yaml +4 -4
  2. data/lib/bolt/cli.rb +30 -131
  3. data/lib/bolt/config.rb +35 -9
  4. data/lib/bolt/executor.rb +33 -7
  5. data/lib/bolt/node.rb +19 -2
  6. data/lib/bolt/node/orch.rb +4 -4
  7. data/lib/bolt/node/ssh.rb +46 -21
  8. data/lib/bolt/node/winrm.rb +12 -23
  9. data/lib/bolt/outputter.rb +9 -0
  10. data/lib/bolt/outputter/human.rb +33 -4
  11. data/lib/bolt/outputter/json.rb +6 -1
  12. data/lib/bolt/pal.rb +87 -20
  13. data/lib/bolt/version.rb +1 -1
  14. data/modules/boltlib/lib/puppet/functions/run_command.rb +1 -1
  15. data/modules/boltlib/lib/puppet/functions/run_plan.rb +18 -1
  16. data/modules/boltlib/lib/puppet/functions/run_script.rb +1 -1
  17. data/modules/boltlib/lib/puppet/functions/run_task.rb +2 -1
  18. data/vendored/facter/lib/facter/virtual.rb +2 -0
  19. data/vendored/hiera/lib/hiera/config.rb +2 -2
  20. data/vendored/hiera/lib/hiera/version.rb +1 -1
  21. data/vendored/puppet/lib/hiera/puppet_function.rb +5 -2
  22. data/vendored/puppet/lib/hiera_puppet.rb +3 -3
  23. data/vendored/puppet/lib/puppet/agent/locker.rb +6 -5
  24. data/vendored/puppet/lib/puppet/application/filebucket.rb +23 -6
  25. data/vendored/puppet/lib/puppet/daemon.rb +2 -2
  26. data/vendored/puppet/lib/puppet/defaults.rb +42 -10
  27. data/vendored/puppet/lib/puppet/error.rb +5 -15
  28. data/vendored/puppet/lib/puppet/external/pson/common.rb +2 -2
  29. data/vendored/puppet/lib/puppet/face/module/build.rb +1 -0
  30. data/vendored/puppet/lib/puppet/face/module/install.rb +1 -0
  31. data/vendored/puppet/lib/puppet/face/module/search.rb +2 -1
  32. data/vendored/puppet/lib/puppet/face/module/uninstall.rb +1 -0
  33. data/vendored/puppet/lib/puppet/face/module/upgrade.rb +1 -0
  34. data/vendored/puppet/lib/puppet/file_bucket/dipper.rb +1 -1
  35. data/vendored/puppet/lib/puppet/file_serving/base.rb +2 -1
  36. data/vendored/puppet/lib/puppet/file_serving/configuration/parser.rb +21 -9
  37. data/vendored/puppet/lib/puppet/file_serving/http_metadata.rb +1 -1
  38. data/vendored/puppet/lib/puppet/forge.rb +2 -1
  39. data/vendored/puppet/lib/puppet/functions/binary_file.rb +1 -0
  40. data/vendored/puppet/lib/puppet/functions/eyaml_lookup_key.rb +4 -2
  41. data/vendored/puppet/lib/puppet/functions/module_directory.rb +41 -0
  42. data/vendored/puppet/lib/puppet/functions/strftime.rb +1 -1
  43. data/vendored/puppet/lib/puppet/functions/unique.rb +1 -1
  44. data/vendored/puppet/lib/puppet/functions/yaml_data.rb +1 -1
  45. data/vendored/puppet/lib/puppet/gettext/config.rb +10 -5
  46. data/vendored/puppet/lib/puppet/graph/relationship_graph.rb +1 -1
  47. data/vendored/puppet/lib/puppet/indirector/catalog/compiler.rb +1 -1
  48. data/vendored/puppet/lib/puppet/indirector/exec.rb +1 -1
  49. data/vendored/puppet/lib/puppet/indirector/facts/facter.rb +3 -3
  50. data/vendored/puppet/lib/puppet/indirector/facts/network_device.rb +2 -2
  51. data/vendored/puppet/lib/puppet/indirector/file_bucket_file/file.rb +10 -3
  52. data/vendored/puppet/lib/puppet/indirector/indirection.rb +17 -9
  53. data/vendored/puppet/lib/puppet/indirector/ldap.rb +2 -2
  54. data/vendored/puppet/lib/puppet/indirector/node/write_only_yaml.rb +3 -1
  55. data/vendored/puppet/lib/puppet/indirector/rest.rb +2 -1
  56. data/vendored/puppet/lib/puppet/indirector/ssl_file.rb +2 -2
  57. data/vendored/puppet/lib/puppet/indirector/terminus.rb +3 -3
  58. data/vendored/puppet/lib/puppet/interface.rb +1 -1
  59. data/vendored/puppet/lib/puppet/interface/action.rb +41 -24
  60. data/vendored/puppet/lib/puppet/interface/action_builder.rb +14 -5
  61. data/vendored/puppet/lib/puppet/interface/action_manager.rb +1 -1
  62. data/vendored/puppet/lib/puppet/interface/documentation.rb +21 -10
  63. data/vendored/puppet/lib/puppet/interface/face_collection.rb +4 -2
  64. data/vendored/puppet/lib/puppet/interface/option.rb +36 -15
  65. data/vendored/puppet/lib/puppet/interface/option_builder.rb +23 -9
  66. data/vendored/puppet/lib/puppet/interface/option_manager.rb +8 -3
  67. data/vendored/puppet/lib/puppet/metatype/manager.rb +7 -3
  68. data/vendored/puppet/lib/puppet/module.rb +2 -1
  69. data/vendored/puppet/lib/puppet/module_tool/applications/builder.rb +4 -0
  70. data/vendored/puppet/lib/puppet/module_tool/applications/installer.rb +3 -0
  71. data/vendored/puppet/lib/puppet/module_tool/applications/uninstaller.rb +3 -0
  72. data/vendored/puppet/lib/puppet/module_tool/applications/upgrader.rb +3 -0
  73. data/vendored/puppet/lib/puppet/module_tool/errors/shared.rb +3 -3
  74. data/vendored/puppet/lib/puppet/network/auth_config_parser.rb +10 -5
  75. data/vendored/puppet/lib/puppet/network/authstore.rb +2 -2
  76. data/vendored/puppet/lib/puppet/network/client_request.rb +1 -1
  77. data/vendored/puppet/lib/puppet/network/format.rb +3 -3
  78. data/vendored/puppet/lib/puppet/network/http/api/indirection_type.rb +1 -1
  79. data/vendored/puppet/lib/puppet/network/http/api/master/v3/environment.rb +5 -2
  80. data/vendored/puppet/lib/puppet/network/http/webrick.rb +1 -3
  81. data/vendored/puppet/lib/puppet/node.rb +16 -7
  82. data/vendored/puppet/lib/puppet/parameter.rb +3 -3
  83. data/vendored/puppet/lib/puppet/parameter/value_collection.rb +5 -2
  84. data/vendored/puppet/lib/puppet/parser/ast/leaf.rb +1 -1
  85. data/vendored/puppet/lib/puppet/parser/ast/node.rb +2 -2
  86. data/vendored/puppet/lib/puppet/parser/compiler.rb +6 -5
  87. data/vendored/puppet/lib/puppet/parser/functions.rb +1 -1
  88. data/vendored/puppet/lib/puppet/parser/functions/fqdn_rand.rb +6 -2
  89. data/vendored/puppet/lib/puppet/parser/functions/generate.rb +2 -4
  90. data/vendored/puppet/lib/puppet/parser/functions/inline_template.rb +1 -2
  91. data/vendored/puppet/lib/puppet/parser/functions/sha256.rb +5 -0
  92. data/vendored/puppet/lib/puppet/parser/functions/template.rb +6 -2
  93. data/vendored/puppet/lib/puppet/parser/resource.rb +18 -91
  94. data/vendored/puppet/lib/puppet/parser/scope.rb +12 -11
  95. data/vendored/puppet/lib/puppet/parser/templatewrapper.rb +1 -1
  96. data/vendored/puppet/lib/puppet/pops/evaluator/collector_transformer.rb +2 -1
  97. data/vendored/puppet/lib/puppet/pops/evaluator/collectors/abstract_collector.rb +1 -1
  98. data/vendored/puppet/lib/puppet/pops/evaluator/epp_evaluator.rb +21 -8
  99. data/vendored/puppet/lib/puppet/pops/evaluator/evaluator_impl.rb +2 -1
  100. data/vendored/puppet/lib/puppet/pops/evaluator/external_syntax_support.rb +1 -1
  101. data/vendored/puppet/lib/puppet/pops/evaluator/runtime3_converter.rb +3 -1
  102. data/vendored/puppet/lib/puppet/pops/evaluator/runtime3_resource_support.rb +1 -1
  103. data/vendored/puppet/lib/puppet/pops/evaluator/runtime3_support.rb +5 -6
  104. data/vendored/puppet/lib/puppet/pops/functions/dispatch.rb +1 -1
  105. data/vendored/puppet/lib/puppet/pops/functions/function.rb +8 -2
  106. data/vendored/puppet/lib/puppet/pops/issue_reporter.rb +7 -2
  107. data/vendored/puppet/lib/puppet/pops/issues.rb +14 -4
  108. data/vendored/puppet/lib/puppet/pops/label_provider.rb +1 -1
  109. data/vendored/puppet/lib/puppet/pops/loader/base_loader.rb +2 -2
  110. data/vendored/puppet/lib/puppet/pops/loader/dependency_loader.rb +2 -2
  111. data/vendored/puppet/lib/puppet/pops/loader/loader.rb +6 -1
  112. data/vendored/puppet/lib/puppet/pops/loader/loader_paths.rb +2 -2
  113. data/vendored/puppet/lib/puppet/pops/loader/module_loaders.rb +27 -6
  114. data/vendored/puppet/lib/puppet/pops/loader/runtime3_type_loader.rb +2 -2
  115. data/vendored/puppet/lib/puppet/pops/loader/static_loader.rb +1 -1
  116. data/vendored/puppet/lib/puppet/pops/loaders.rb +7 -3
  117. data/vendored/puppet/lib/puppet/pops/lookup/explainer.rb +2 -1
  118. data/vendored/puppet/lib/puppet/pops/merge_strategy.rb +6 -3
  119. data/vendored/puppet/lib/puppet/pops/migration/migration_checker.rb +8 -8
  120. data/vendored/puppet/lib/puppet/pops/model/factory.rb +4 -2
  121. data/vendored/puppet/lib/puppet/pops/resource/resource_type_impl.rb +1 -1
  122. data/vendored/puppet/lib/puppet/pops/serialization/abstract_writer.rb +2 -1
  123. data/vendored/puppet/lib/puppet/pops/serialization/to_data_converter.rb +6 -2
  124. data/vendored/puppet/lib/puppet/pops/types/p_object_type.rb +36 -15
  125. data/vendored/puppet/lib/puppet/pops/types/type_calculator.rb +2 -1
  126. data/vendored/puppet/lib/puppet/pops/types/type_factory.rb +3 -1
  127. data/vendored/puppet/lib/puppet/pops/types/type_mismatch_describer.rb +4 -1
  128. data/vendored/puppet/lib/puppet/pops/types/type_parser.rb +75 -7
  129. data/vendored/puppet/lib/puppet/pops/types/types.rb +9 -5
  130. data/vendored/puppet/lib/puppet/pops/validation.rb +14 -12
  131. data/vendored/puppet/lib/puppet/property.rb +14 -6
  132. data/vendored/puppet/lib/puppet/property/ensure.rb +2 -2
  133. data/vendored/puppet/lib/puppet/provider.rb +4 -4
  134. data/vendored/puppet/lib/puppet/provider/group/aix.rb +4 -2
  135. data/vendored/puppet/lib/puppet/provider/group/groupadd.rb +25 -1
  136. data/vendored/puppet/lib/puppet/provider/ldap.rb +2 -2
  137. data/vendored/puppet/lib/puppet/provider/naginator.rb +1 -1
  138. data/vendored/puppet/lib/puppet/provider/nameservice.rb +7 -4
  139. data/vendored/puppet/lib/puppet/provider/nameservice/directoryservice.rb +4 -3
  140. data/vendored/puppet/lib/puppet/provider/nameservice/objectadd.rb +13 -24
  141. data/vendored/puppet/lib/puppet/provider/nameservice/pw.rb +14 -14
  142. data/vendored/puppet/lib/puppet/provider/package/aix.rb +1 -1
  143. data/vendored/puppet/lib/puppet/provider/package/pkg.rb +3 -2
  144. data/vendored/puppet/lib/puppet/provider/package/yum.rb +1 -1
  145. data/vendored/puppet/lib/puppet/provider/parsedfile.rb +4 -4
  146. data/vendored/puppet/lib/puppet/provider/service/base.rb +1 -1
  147. data/vendored/puppet/lib/puppet/provider/service/launchd.rb +2 -2
  148. data/vendored/puppet/lib/puppet/provider/service/runit.rb +2 -1
  149. data/vendored/puppet/lib/puppet/provider/service/systemd.rb +1 -0
  150. data/vendored/puppet/lib/puppet/provider/service/upstart.rb +1 -1
  151. data/vendored/puppet/lib/puppet/provider/user/aix.rb +13 -6
  152. data/vendored/puppet/lib/puppet/provider/user/openbsd.rb +2 -1
  153. data/vendored/puppet/lib/puppet/provider/user/useradd.rb +33 -4
  154. data/vendored/puppet/lib/puppet/provider/yumrepo/inifile.rb +2 -1
  155. data/vendored/puppet/lib/puppet/provider/zone/solaris.rb +2 -2
  156. data/vendored/puppet/lib/puppet/relationship.rb +2 -1
  157. data/vendored/puppet/lib/puppet/reports/store.rb +1 -1
  158. data/vendored/puppet/lib/puppet/resource.rb +7 -5
  159. data/vendored/puppet/lib/puppet/resource/capability_finder.rb +14 -11
  160. data/vendored/puppet/lib/puppet/resource/catalog.rb +33 -18
  161. data/vendored/puppet/lib/puppet/resource/type.rb +5 -5
  162. data/vendored/puppet/lib/puppet/settings.rb +19 -13
  163. data/vendored/puppet/lib/puppet/settings/base_setting.rb +23 -8
  164. data/vendored/puppet/lib/puppet/settings/config_file.rb +14 -4
  165. data/vendored/puppet/lib/puppet/settings/environment_conf.rb +5 -7
  166. data/vendored/puppet/lib/puppet/settings/ini_file.rb +4 -0
  167. data/vendored/puppet/lib/puppet/ssl/base.rb +9 -4
  168. data/vendored/puppet/lib/puppet/ssl/oids.rb +8 -2
  169. data/vendored/puppet/lib/puppet/transaction.rb +6 -2
  170. data/vendored/puppet/lib/puppet/transaction/persistence.rb +15 -0
  171. data/vendored/puppet/lib/puppet/transaction/report.rb +9 -1
  172. data/vendored/puppet/lib/puppet/type.rb +26 -26
  173. data/vendored/puppet/lib/puppet/type/file.rb +2 -1
  174. data/vendored/puppet/lib/puppet/type/file/data_sync.rb +2 -1
  175. data/vendored/puppet/lib/puppet/type/file/source.rb +1 -1
  176. data/vendored/puppet/lib/puppet/type/group.rb +4 -1
  177. data/vendored/puppet/lib/puppet/type/mount.rb +1 -1
  178. data/vendored/puppet/lib/puppet/type/resources.rb +1 -1
  179. data/vendored/puppet/lib/puppet/type/user.rb +12 -7
  180. data/vendored/puppet/lib/puppet/type/zone.rb +1 -1
  181. data/vendored/puppet/lib/puppet/util.rb +15 -21
  182. data/vendored/puppet/lib/puppet/util/at_fork/solaris.rb +6 -4
  183. data/vendored/puppet/lib/puppet/util/command_line/trollop.rb +6 -5
  184. data/vendored/puppet/lib/puppet/util/errors.rb +59 -8
  185. data/vendored/puppet/lib/puppet/util/fileparsing.rb +3 -5
  186. data/vendored/puppet/lib/puppet/util/http_proxy.rb +14 -6
  187. data/vendored/puppet/lib/puppet/util/instance_loader.rb +1 -3
  188. data/vendored/puppet/lib/puppet/util/ldap/manager.rb +6 -3
  189. data/vendored/puppet/lib/puppet/util/log.rb +15 -21
  190. data/vendored/puppet/lib/puppet/util/logging.rb +21 -28
  191. data/vendored/puppet/lib/puppet/util/methodhelper.rb +1 -1
  192. data/vendored/puppet/lib/puppet/util/nagios_maker.rb +1 -1
  193. data/vendored/puppet/lib/puppet/util/network_device/config.rb +20 -13
  194. data/vendored/puppet/lib/puppet/util/platform.rb +13 -0
  195. data/vendored/puppet/lib/puppet/util/posix.rb +1 -1
  196. data/vendored/puppet/lib/puppet/util/provider_features.rb +1 -1
  197. data/vendored/puppet/lib/puppet/util/rdoc/generators/puppet_generator.rb +1 -1
  198. data/vendored/puppet/lib/puppet/util/selinux.rb +1 -1
  199. data/vendored/puppet/lib/puppet/util/windows/eventlog.rb +10 -5
  200. data/vendored/puppet/lib/puppet/util/windows/file.rb +61 -9
  201. data/vendored/puppet/lib/puppet/util/windows/process.rb +1 -1
  202. data/vendored/puppet/lib/puppet/util/windows/taskscheduler.rb +2 -2
  203. data/vendored/puppet/lib/puppet/version.rb +1 -1
  204. data/vendored/puppet/lib/puppet_pal.rb +23 -22
  205. metadata +4 -2
@@ -727,7 +727,7 @@ Puppet::Type.newtype(:file) do
727
727
  if can_backup?(current_type)
728
728
  backup_existing
729
729
  else
730
- self.warning "Could not back up file of type #{current_type}"
730
+ self.warning _("Could not back up file of type %{current_type}") % { current_type: current_type }
731
731
  end
732
732
  end
733
733
 
@@ -752,6 +752,7 @@ Puppet::Type.newtype(:file) do
752
752
  # catalog validation (because that would be a breaking change from Puppet 4).
753
753
  if Puppet.features.microsoft_windows? && parameter(:source) &&
754
754
  [:use, :use_when_creating].include?(self[:source_permissions])
755
+ #TRANSLATORS "source_permissions => ignore" should not be translated
755
756
  err_msg = _("Copying owner/mode/group from the source file on Windows is not supported; use source_permissions => ignore.")
756
757
  if self[:owner] == nil || self[:group] == nil || self[:mode] == nil
757
758
  # Fail on Windows if source permissions are being used and the file resource
@@ -27,7 +27,8 @@ module Puppet
27
27
  return false if is == :absent
28
28
  else
29
29
  if resource[:ensure] == :present && has_contents && (s = resource.stat)
30
- resource.warning "Ensure set to :present but file type is #{s.ftype} so no content will be synced"
30
+ #TRANSLATORS 'Ensure' is an attribute and ':present' is a value and should not be translated
31
+ resource.warning _("Ensure set to :present but file type is %{file_type} so no content will be synced") % { file_type: s.ftype}
31
32
  end
32
33
  return true
33
34
  end
@@ -128,7 +128,7 @@ module Puppet
128
128
  # Look up (if necessary) and return local content.
129
129
  def content
130
130
  return @content if @content
131
- raise Puppet::DevError, "No source for content was stored with the metadata" unless metadata.source
131
+ raise Puppet::DevError, _("No source for content was stored with the metadata") unless metadata.source
132
132
 
133
133
  unless tmp = Puppet::FileServing::Content.indirection.find(metadata.source, :environment => resource.catalog.environment_instance, :links => resource[:links])
134
134
  self.fail "Could not find any content at %s" % metadata.source
@@ -36,6 +36,9 @@ module Puppet
36
36
  newvalue(:absent) do
37
37
  provider.delete
38
38
  end
39
+
40
+ defaultto :present
41
+
39
42
  end
40
43
 
41
44
  newproperty(:gid) do
@@ -54,7 +57,7 @@ module Puppet
54
57
 
55
58
  def sync
56
59
  if self.should == :absent
57
- raise Puppet::DevError, "GID cannot be deleted"
60
+ raise Puppet::DevError, _("GID cannot be deleted")
58
61
  else
59
62
  provider.gid = self.should
60
63
  end
@@ -115,7 +115,7 @@ module Puppet
115
115
  # Determine if there are any out-of-sync properties.
116
116
  oos = @resource.send(:properties).find_all do |prop|
117
117
  unless currentvalues.include?(prop)
118
- raise Puppet::DevError, "Parent has property %s but it doesn't appear in the current values", [prop.name]
118
+ raise Puppet::DevError, _("Parent has property %{name} but it doesn't appear in the current values") % { name: prop.name }
119
119
  end
120
120
  if prop.name == :ensure
121
121
  false
@@ -127,7 +127,7 @@ Puppet::Type.newtype(:resources) do
127
127
  def resource_type
128
128
  unless defined?(@resource_type)
129
129
  unless type = Puppet::Type.type(self[:name])
130
- raise Puppet::DevError, "Could not find resource type"
130
+ raise Puppet::DevError, _("Could not find resource type")
131
131
  end
132
132
  @resource_type = type
133
133
  end
@@ -386,9 +386,15 @@ module Puppet
386
386
  end
387
387
 
388
388
  newparam(:managehome, :boolean => true, :parent => Puppet::Parameter::Boolean) do
389
- desc "Whether to manage the home directory when managing the user.
390
- This will create the home directory when `ensure => present`, and
391
- delete the home directory when `ensure => absent`. Defaults to `false`."
389
+ desc "Whether to manage the home directory when Puppet creates or removes the user.
390
+ This creates the home directory if Puppet also creates the user account, and deletes the
391
+ home directory if Puppet also removes the user account. Defaults to `false`.
392
+
393
+ This parameter has no effect unless Puppet is also creating or removing the user in the
394
+ resource at the same time. For instance, Puppet creates a home directory for a managed
395
+ user if `ensure => present` and the user does not exist at the time of the Puppet run.
396
+ If the home directory is then deleted manually, Puppet will not recreate it on the next
397
+ run."
392
398
 
393
399
  defaultto false
394
400
 
@@ -400,10 +406,9 @@ module Puppet
400
406
  end
401
407
 
402
408
  newproperty(:expiry, :required_features => :manages_expiry) do
403
- desc "The expiry date for this user. Must be provided in
404
- a zero-padded YYYY-MM-DD format --- e.g. 2010-02-19.
405
- If you want to ensure the user account never expires,
406
- you can pass the special value `absent`."
409
+ desc "The expiry date for this user. Provide as either the special
410
+ value `absent` to ensure that the account never expires, or as
411
+ a zero-padded YYYY-MM-DD format -- for example, 2010-02-19."
407
412
 
408
413
  newvalues :absent
409
414
  newvalues /^\d{4}-\d{2}-\d{2}$/
@@ -115,7 +115,7 @@ end
115
115
  # everything between it and us.
116
116
  self.class.state_sequence(self.retrieve, self.should).each do |state|
117
117
  method = state[direction]
118
- raise Puppet::DevError, "Cannot move #{direction} from #{st[:name]}" unless method
118
+ raise Puppet::DevError, _("Cannot move %{direction} from %{name}") % { direction: direction, name: st[:name] } unless method
119
119
  provider_sync_send(method)
120
120
  end
121
121
 
@@ -219,10 +219,11 @@ module Util
219
219
  args.pop
220
220
  end
221
221
 
222
- raise Puppet::DevError, "Failed to provide level to :benchmark" unless level
222
+ #TRANSLATORS 'benchmark' is a method name and should not be translated
223
+ raise Puppet::DevError, _("Failed to provide level to benchmark") unless level
223
224
 
224
225
  unless level == :none or object.respond_to? level
225
- raise Puppet::DevError, "Benchmarked object does not respond to #{level}"
226
+ raise Puppet::DevError, _("Benchmarked object does not respond to %{value}") % { value: level }
226
227
  end
227
228
 
228
229
  # Only benchmark if our log level is high enough
@@ -306,7 +307,7 @@ module Util
306
307
  when :posix
307
308
  AbsolutePathPosix
308
309
  else
309
- raise Puppet::DevError, "unknown platform #{platform} in absolute_path"
310
+ raise Puppet::DevError, _("unknown platform %{platform} in absolute_path") % { platform: platform }
310
311
  end
311
312
 
312
313
  !! (path =~ regex)
@@ -444,7 +445,7 @@ module Util
444
445
  # query will encode + as %2B and space as %20
445
446
  # fragment behaves like query
446
447
  def uri_encode(path, opts = { :allow_fragment => false })
447
- raise ArgumentError.new('path may not be nil') if path.nil?
448
+ raise ArgumentError.new(_('path may not be nil')) if path.nil?
448
449
 
449
450
  # ensure string starts as UTF-8 for the sake of Ruby 1.9.3
450
451
  encoded = ''.encode!(Encoding::UTF_8)
@@ -562,11 +563,11 @@ module Util
562
563
  DEFAULT_WINDOWS_MODE = nil
563
564
 
564
565
  def replace_file(file, default_mode, &block)
565
- raise Puppet::DevError, "replace_file requires a block" unless block_given?
566
+ raise Puppet::DevError, _("replace_file requires a block") unless block_given?
566
567
 
567
568
  if default_mode
568
569
  unless valid_symbolic_mode?(default_mode)
569
- raise Puppet::DevError, "replace_file default_mode: #{default_mode} is invalid"
570
+ raise Puppet::DevError, _("replace_file default_mode: %{default_mode} is invalid") % { default_mode: default_mode }
570
571
  end
571
572
 
572
573
  mode = symbolic_mode_to_int(normalize_symbolic_mode(default_mode))
@@ -583,17 +584,10 @@ module Util
583
584
  # encoding for Uniquefile is not important here because the caller writes to it as it sees fit
584
585
  tempfile = Puppet::FileSystem::Uniquefile.new(Puppet::FileSystem.basename_string(file), Puppet::FileSystem.dir_string(file))
585
586
 
586
- # Set properties of the temporary file before we write the content, because
587
- # Tempfile doesn't promise to be safe from reading by other people, just
588
- # that it avoids races around creating the file.
589
- #
590
- # Our Windows emulation is pretty limited, and so we have to carefully
591
- # and specifically handle the platform, which has all sorts of magic.
592
- # So, unlike Unix, we don't pre-prep security; we use the default "quite
593
- # secure" tempfile permissions instead. Magic happens later.
587
+ effective_mode =
594
588
  if !Puppet.features.microsoft_windows?
595
589
  # Grab the current file mode, and fall back to the defaults.
596
- effective_mode =
590
+
597
591
  if Puppet::FileSystem.exist?(file)
598
592
  stat = Puppet::FileSystem.lstat(file)
599
593
  tempfile.chown(stat.uid, stat.gid)
@@ -601,17 +595,17 @@ module Util
601
595
  else
602
596
  mode
603
597
  end
604
-
605
- if effective_mode
606
- # We only care about the bottom four slots, which make the real mode,
607
- # and not the rest of the platform stat call fluff and stuff.
608
- tempfile.chmod(effective_mode & 07777)
609
- end
610
598
  end
611
599
 
612
600
  # OK, now allow the caller to write the content of the file.
613
601
  yield tempfile
614
602
 
603
+ if effective_mode
604
+ # We only care about the bottom four slots, which make the real mode,
605
+ # and not the rest of the platform stat call fluff and stuff.
606
+ tempfile.chmod(effective_mode & 07777)
607
+ end
608
+
615
609
  # Now, make sure the data (which includes the mode) is safe on disk.
616
610
  tempfile.flush
617
611
  begin
@@ -93,10 +93,12 @@ class Puppet::Util::AtFork::Solaris
93
93
  begin
94
94
  raise_if_error { ct_tmpl_clear(tmpl.fileno) }
95
95
  rescue => detail
96
- Puppet.log_exception(detail, parent \
97
- ? _('Failed to deactivate process contract template in the parent process')
98
- : _('Failed to deactivate process contract template in the child process')
99
- )
96
+ msg = if parent
97
+ _('Failed to deactivate process contract template in the parent process')
98
+ else
99
+ _('Failed to deactivate process contract template in the child process')
100
+ end
101
+ Puppet.log_exception(detail, msg)
100
102
  exit(1)
101
103
  ensure
102
104
  tmpl.close
@@ -165,11 +165,11 @@ class Parser
165
165
  when 'IO'; :io
166
166
  when 'Date'; :date
167
167
  else
168
- raise ArgumentError, "unsupported argument type '#{opts[:type].class.name}'"
168
+ raise ArgumentError, _("unsupported argument type '%{type}'") % { type: opts[:type].class.name }
169
169
  end
170
170
  when nil; nil
171
171
  else
172
- raise ArgumentError, "unsupported argument type '#{opts[:type]}'" unless TYPES.include?(opts[:type])
172
+ raise ArgumentError, _("unsupported argument type '%{type}'") % { type: opts[:type] } unless TYPES.include?(opts[:type])
173
173
  opts[:type]
174
174
  end
175
175
 
@@ -223,7 +223,7 @@ class Parser
223
223
  when /^[^-]/
224
224
  opts[:long]
225
225
  else
226
- raise ArgumentError, "invalid long option name #{opts[:long].inspect}"
226
+ raise ArgumentError, _("invalid long option name %{name}") % { name: opts[:long].inspect }
227
227
  end
228
228
  raise ArgumentError, _("long option name %{value0} is already taken; please specify a (different) :long") % { value0: opts[:long].inspect } if @long[opts[:long]]
229
229
 
@@ -232,7 +232,7 @@ class Parser
232
232
  opts[:short] = case opts[:short]
233
233
  when /^-(.)$/; $1
234
234
  when nil, :none, /^.$/; opts[:short]
235
- else raise ArgumentError, "invalid short option name '#{opts[:short].inspect}'"
235
+ else raise ArgumentError, _("invalid short option name '%{name}'") % { name: opts[:short].inspect }
236
236
  end
237
237
 
238
238
  if opts[:short]
@@ -812,7 +812,8 @@ def die arg, msg=nil
812
812
  if @last_parser
813
813
  @last_parser.die arg, msg
814
814
  else
815
- raise ArgumentError, "Trollop::die can only be called after Trollop::options"
815
+ #TRANSLATORS 'Trollop' is the name of a module and 'die' and 'options' are methods in it and should not be translated.
816
+ raise ArgumentError, _("Trollop::die can only be called after Trollop::options")
816
817
  end
817
818
  end
818
819
 
@@ -31,22 +31,73 @@ module Puppet::Util::Errors
31
31
  error
32
32
  end
33
33
 
34
- # Return a human-readable string of this object's file and line attributes,
34
+ # Return a human-readable string of this object's file, line, and pos attributes,
35
35
  # if set.
36
36
  #
37
- # @return [String] description of file and line
38
- def error_context
39
- if file and line
40
- _(" at %{file}:%{line}") % { file: file, line: line }
37
+ # @param file [String] the file path for the error (nil or "", for not known)
38
+ # @param line [String] the line number for the error (nil or "", for not known)
39
+ # @param column [String] the column number for the error (nil or "", for not known)
40
+ # @return [String] description of file, line, and column
41
+ #
42
+ def self.error_location(file, line=nil, column=nil)
43
+ file = nil if (file.is_a?(String) && file.empty?)
44
+ line = nil if (line.is_a?(String) && line.empty?)
45
+ column = nil if (column.is_a?(String) && column.empty?)
46
+ if file and line and column
47
+ _("(file: %{file}, line: %{line}, column: %{column})") % { file: file, line: line, column: column }
48
+ elsif file and line
49
+ _("(file: %{file}, line: %{line})") % { file: file, line: line }
50
+ elsif line and column
51
+ _("(line: %{line}, column: %{column})") % { line: line, column: column }
41
52
  elsif line
42
- _(" at line %{line}") % { line: line }
53
+ _("(line: %{line})") % { line: line }
43
54
  elsif file
44
- _(" in %{file}") % { file: file }
55
+ _("(file: %{file})") % { file: file }
56
+ else
57
+ ''
58
+ end
59
+ end
60
+
61
+ # Return a human-readable string of this object's file, line, and pos attributes,
62
+ # with a proceeding space in the output
63
+ # if set.
64
+ #
65
+ # @param file [String] the file path for the error (nil or "", for not known)
66
+ # @param line [String] the line number for the error (nil or "", for not known)
67
+ # @param column [String] the column number for the error (nil or "", for not known)
68
+ # @return [String] description of file, line, and column
69
+ #
70
+ def self.error_location_with_space(file, line=nil, column=nil)
71
+ error_location_str = error_location(file, line, column)
72
+ if error_location_str.empty?
73
+ ''
45
74
  else
46
- ""
75
+ ' ' + error_location_str
47
76
  end
48
77
  end
49
78
 
79
+ # Return a human-readable string of this object's file and line
80
+ # where unknown entries are listed as 'unknown'
81
+ #
82
+ # @param file [String] the file path for the error (nil or "", for not known)
83
+ # @param line [String] the line number for the error (nil or "", for not known)
84
+ # @return [String] description of file, and line
85
+ def self.error_location_with_unknowns(file, line)
86
+ file = nil if (file.is_a?(String) && file.empty?)
87
+ line = nil if (line.is_a?(String) && line.empty?)
88
+ file = _('unknown') unless file
89
+ line = _('unknown') unless line
90
+ error_location(file, line)
91
+ end
92
+
93
+ # Return a human-readable string of this object's file and line attributes,
94
+ # if set.
95
+ #
96
+ # @return [String] description of file and line with a leading space
97
+ def error_context
98
+ Puppet::Util::Errors.error_location_with_space(file, line)
99
+ end
100
+
50
101
  # Wrap a call in such a way that we always throw the right exception and keep
51
102
  # as much context as possible.
52
103
  #
@@ -151,8 +151,7 @@ module Puppet::Util::FileParsing
151
151
  if record.respond_to?(:process)
152
152
  if ret = record.send(:process, line.dup)
153
153
  unless ret.is_a?(Hash)
154
- raise Puppet::DevError,
155
- "Process record type #{record.name} returned non-hash"
154
+ raise Puppet::DevError, _("Process record type %{record_name} returned non-hash") % { record_name: record.name }
156
155
  end
157
156
  else
158
157
  return nil
@@ -236,7 +235,7 @@ module Puppet::Util::FileParsing
236
235
 
237
236
  # Handle parsing a single line.
238
237
  def parse_line(line)
239
- raise Puppet::DevError, "No record types defined; cannot parse lines" unless records?
238
+ raise Puppet::DevError, _("No record types defined; cannot parse lines") unless records?
240
239
 
241
240
  @record_order.each do |record|
242
241
  # These are basically either text or record lines.
@@ -247,8 +246,7 @@ module Puppet::Util::FileParsing
247
246
  return result
248
247
  end
249
248
  else
250
- raise Puppet::DevError,
251
- "Somehow got invalid line type #{record.type}"
249
+ raise Puppet::DevError, _("Somehow got invalid line type %{record_type}") % { record_type: record.type }
252
250
  end
253
251
  end
254
252
 
@@ -1,5 +1,6 @@
1
1
  require 'uri'
2
2
  require 'openssl'
3
+ require 'puppet/network/http'
3
4
 
4
5
  module Puppet::Util::HttpProxy
5
6
  def self.proxy(uri)
@@ -172,7 +173,13 @@ module Puppet::Util::HttpProxy
172
173
 
173
174
  0.upto(redirect_limit) do |redirection|
174
175
  proxy = get_http_object(current_uri)
175
- response = proxy.send(:head, current_uri.path)
176
+
177
+ headers = { 'Accept' => '*/*', 'User-Agent' => Puppet[:http_user_agent] }
178
+ if Puppet.features.zlib?
179
+ headers.merge!({"Accept-Encoding" => Puppet::Network::HTTP::Compression::ACCEPT_ENCODING})
180
+ end
181
+
182
+ response = proxy.send(:head, current_uri.path, headers)
176
183
 
177
184
  if [301, 302, 307].include?(response.code.to_i)
178
185
  # handle the redirection
@@ -180,11 +187,12 @@ module Puppet::Util::HttpProxy
180
187
  next
181
188
  end
182
189
 
183
- if block_given?
184
- headers = {'Accept' => 'binary', 'accept-encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3'}
185
- response = proxy.send("request_#{method}".to_sym, current_uri.path, headers, &block)
186
- else
187
- response = proxy.send(method, current_uri.path)
190
+ if method != :head
191
+ if block_given?
192
+ response = proxy.send("request_#{method}".to_sym, current_uri.path, headers, &block)
193
+ else
194
+ response = proxy.send(method, current_uri.path, headers)
195
+ end
188
196
  end
189
197
 
190
198
  Puppet.debug("HTTP #{method.to_s.upcase} request to #{current_uri} returned #{response.code} #{response.message}")
@@ -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