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
@@ -10,7 +10,7 @@ class Puppet::Indirector::Ldap < Puppet::Indirector::Terminus
10
10
  # Process the found entry. We assume that we don't just want the
11
11
  # ldap object.
12
12
  def process(entry)
13
- raise Puppet::DevError, "The 'process' method has not been overridden for the LDAP terminus for #{self.name}"
13
+ raise Puppet::DevError, _("The 'process' method has not been overridden for the LDAP terminus for %{name}") % { name: self.name }
14
14
  end
15
15
 
16
16
  # Default to all attributes.
@@ -24,7 +24,7 @@ class Puppet::Indirector::Ldap < Puppet::Indirector::Terminus
24
24
 
25
25
  # The ldap search filter to use.
26
26
  def search_filter(name)
27
- raise Puppet::DevError, "No search string set for LDAP terminus for #{self.name}"
27
+ raise Puppet::DevError, _("No search string set for LDAP terminus for %{name}") % { name: self.name }
28
28
  end
29
29
 
30
30
  # Find the ldap node, return the class list and parent node specially,
@@ -12,7 +12,9 @@ require 'puppet/indirector/yaml'
12
12
  #
13
13
  class Puppet::Node::WriteOnlyYaml < Puppet::Indirector::Yaml
14
14
  def initialize
15
- Puppet.warn_once('deprecations', 'Puppet::Node::WriteOnlyYaml', _('Puppet::Node::WriteOnlyYaml is deprecated and will be removed in a future release of Puppet.'))
15
+ #TRANSLATORS 'Puppet::Node::WriteOnlyYaml' is a class and should not be translated
16
+ message = _('Puppet::Node::WriteOnlyYaml is deprecated and will be removed in a future release of Puppet.')
17
+ Puppet.warn_once('deprecations', 'Puppet::Node::WriteOnlyYaml', message)
16
18
  super
17
19
  end
18
20
 
@@ -266,7 +266,8 @@ class Puppet::Indirector::REST < Puppet::Indirector::Terminus
266
266
  Puppet.push_context({:server_agent_version => server_version})
267
267
  if SemanticPuppet::Version.parse(server_version).major < MAJOR_VERSION_JSON_DEFAULT &&
268
268
  Puppet[:preferred_serialization_format] != 'pson'
269
- Puppet.warning("Downgrading to PSON for future requests")
269
+ #TRANSLATORS "PSON" should not be translated
270
+ Puppet.warning(_("Downgrading to PSON for future requests"))
270
271
  Puppet[:preferred_serialization_format] = 'pson'
271
272
  end
272
273
  end
@@ -49,7 +49,7 @@ class Puppet::Indirector::SslFile < Puppet::Indirector::Terminus
49
49
  def initialize
50
50
  Puppet.settings.use(:main, :ssl)
51
51
 
52
- (collection_directory || file_location) or raise Puppet::DevError, "No file or directory setting provided; terminus #{self.class.name} cannot function"
52
+ (collection_directory || file_location) or raise Puppet::DevError, _("No file or directory setting provided; terminus %{class_name} cannot function") % { class_name: self.class.name }
53
53
  end
54
54
 
55
55
  def path(name)
@@ -190,7 +190,7 @@ class Puppet::Indirector::SslFile < Puppet::Indirector::Terminus
190
190
  raise Puppet::Error, _("Could not write %{path} to %{setting}: %{detail}") % { path: path, setting: setting, detail: detail }, detail.backtrace
191
191
  end
192
192
  else
193
- raise Puppet::DevError, "You must provide a setting to determine where the files are stored"
193
+ raise Puppet::DevError, _("You must provide a setting to determine where the files are stored")
194
194
  end
195
195
  end
196
196
  end
@@ -46,7 +46,7 @@ class Puppet::Indirector::Terminus
46
46
  def inherited(subclass)
47
47
  longname = subclass.to_s
48
48
  if longname =~ /#<Class/
49
- raise Puppet::DevError, "Terminus subclasses must have associated constants"
49
+ raise Puppet::DevError, _("Terminus subclasses must have associated constants")
50
50
  end
51
51
  names = longname.split("::")
52
52
 
@@ -71,7 +71,7 @@ class Puppet::Indirector::Terminus
71
71
  processed_name = names.pop.sub(/^[A-Z]/) { |i| i.downcase }.gsub(/[A-Z]/) { |i| "_#{i.downcase}" }
72
72
 
73
73
  if processed_name.empty?
74
- raise Puppet::DevError, "Could not discern indirection model from class constant"
74
+ raise Puppet::DevError, _("Could not discern indirection model from class constant")
75
75
  end
76
76
 
77
77
  # This will throw an exception if the indirection instance cannot be found.
@@ -129,7 +129,7 @@ class Puppet::Indirector::Terminus
129
129
  end
130
130
 
131
131
  def initialize
132
- raise Puppet::DevError, "Cannot create instances of abstract terminus types" if self.class.abstract_terminus?
132
+ raise Puppet::DevError, _("Cannot create instances of abstract terminus types") if self.class.abstract_terminus?
133
133
  end
134
134
 
135
135
  def model
@@ -149,7 +149,7 @@ class Puppet::Interface
149
149
  # @api private
150
150
  def initialize(name, version, &block)
151
151
  unless SemanticPuppet::Version.valid?(version)
152
- raise ArgumentError, "Cannot create face #{name.inspect} with invalid version number '#{version}'!"
152
+ raise ArgumentError, _("Cannot create face %{name} with invalid version number '%{version}'!") % { name: name.inspect, version: version }
153
153
  end
154
154
 
155
155
  @name = Puppet::Interface::FaceCollection.underscorize(name)
@@ -78,7 +78,7 @@ class Puppet::Interface::Action
78
78
  # @api private
79
79
  def when_rendering(type)
80
80
  unless type.is_a? Symbol
81
- raise ArgumentError, "The rendering format must be a symbol, not #{type.class.name}"
81
+ raise ArgumentError, _("The rendering format must be a symbol, not %{class_name}") % { class_name: type.class.name }
82
82
  end
83
83
  # Do we have a rendering hook for this name?
84
84
  return @when_rendering[type].bind(@face) if @when_rendering.has_key? type
@@ -94,28 +94,38 @@ class Puppet::Interface::Action
94
94
  # @api private
95
95
  def set_rendering_method_for(type, proc)
96
96
  unless proc.is_a? Proc
97
- msg = "The second argument to set_rendering_method_for must be a Proc"
98
- msg += ", not #{proc.class.name}" unless proc.nil?
97
+ msg = if proc.nil?
98
+ #TRANSLATORS 'set_rendering_method_for' and 'Proc' should not be translated
99
+ _("The second argument to set_rendering_method_for must be a Proc")
100
+ else
101
+ #TRANSLATORS 'set_rendering_method_for' and 'Proc' should not be translated
102
+ _("The second argument to set_rendering_method_for must be a Proc, not %{class_name}") %
103
+ { class_name: proc.class.name }
104
+ end
99
105
  raise ArgumentError, msg
100
106
  end
101
107
 
102
108
  if proc.arity != 1 and proc.arity != (@positional_arg_count + 1)
103
- msg = "the when_rendering method for the #{@face.name} face #{name} action "
104
- msg += "takes either just one argument, the result of when_invoked, "
105
- msg += "or the result plus the #{@positional_arg_count} arguments passed "
106
- msg += "to the when_invoked block, not "
107
- if proc.arity < 0 then
108
- msg += "a variable number"
109
- else
110
- msg += proc.arity.to_s
111
- end
109
+ msg = if proc.arity < 0 then
110
+ #TRANSLATORS 'when_rendering', 'when_invoked' are method names and should not be translated
111
+ _("The when_rendering method for the %{face} face %{name} action takes either just one argument,"\
112
+ " the result of when_invoked, or the result plus the %{arg_count} arguments passed to the"\
113
+ " when_invoked block, not a variable number") %
114
+ { face: @face.name, name: name, arg_count: @positional_arg_count }
115
+ else
116
+ #TRANSLATORS 'when_rendering', 'when_invoked' are method names and should not be translated
117
+ _("The when_rendering method for the %{face} face %{name} action takes either just one argument,"\
118
+ " the result of when_invoked, or the result plus the %{arg_count} arguments passed to the"\
119
+ " when_invoked block, not %{string}") %
120
+ { face: @face.name, name: name, arg_count: @positional_arg_count, string: proc.arity.to_s }
121
+ end
112
122
  raise ArgumentError, msg
113
123
  end
114
124
  unless type.is_a? Symbol
115
- raise ArgumentError, "The rendering format must be a symbol, not #{type.class.name}"
125
+ raise ArgumentError, _("The rendering format must be a symbol, not %{class_name}") % { class_name: type.class.name }
116
126
  end
117
127
  if @when_rendering.has_key? type then
118
- raise ArgumentError, "You can't define a rendering method for #{type} twice"
128
+ raise ArgumentError, _("You can't define a rendering method for %{type} twice") % { type: type }
119
129
  end
120
130
  # Now, the ugly bit. We add the method to our interface object, and
121
131
  # retrieve it, to rotate through the dance of getting a suitable method
@@ -213,7 +223,8 @@ class Puppet::Interface::Action
213
223
  # but will on 1.9.2, which treats it as "no arguments". Which bites,
214
224
  # because this just begs for us to wind up in the horrible situation
215
225
  # where a 1.8 vs 1.9 error bites our end users. --daniel 2011-04-19
216
- raise ArgumentError, "when_invoked requires at least one argument (options) for action #{@name}"
226
+ #TRANSLATORS 'when_invoked' should not be translated
227
+ raise ArgumentError, _("when_invoked requires at least one argument (options) for action %{name}") % { name: @name }
217
228
  elsif arity > 0 then
218
229
  range = Range.new(1, arity - 1)
219
230
  decl = range.map { |x| "arg#{x}" } << "options = {}"
@@ -259,9 +270,11 @@ WRAPPER
259
270
  def add_option(option)
260
271
  option.aliases.each do |name|
261
272
  if conflict = get_option(name) then
262
- raise ArgumentError, "Option #{option} conflicts with existing option #{conflict}"
273
+ raise ArgumentError, _("Option %{option} conflicts with existing option %{conflict}") %
274
+ { option: option, conflict: conflict }
263
275
  elsif conflict = @face.get_option(name) then
264
- raise ArgumentError, "Option #{option} conflicts with existing option #{conflict} on #{@face}"
276
+ raise ArgumentError, _("Option %{option} conflicts with existing option %{conflict} on %{face}") %
277
+ { option: option, conflict: conflict, face: @face }
265
278
  end
266
279
  end
267
280
 
@@ -285,7 +298,10 @@ WRAPPER
285
298
  def add_display_global_options(*args)
286
299
  @display_global_options ||= []
287
300
  [args].flatten.each do |refopt|
288
- raise ArgumentError, "Global option #{refopt} does not exist in Puppet.settings" unless Puppet.settings.include? refopt
301
+ unless Puppet.settings.include? refopt
302
+ #TRANSLATORS 'Puppet.settings' should not be translated
303
+ raise ArgumentError, _("Global option %{option} does not exist in Puppet.settings") % { option: refopt }
304
+ end
289
305
  @display_global_options << refopt
290
306
  end
291
307
  @display_global_options.uniq!
@@ -331,13 +347,14 @@ WRAPPER
331
347
  end
332
348
 
333
349
  unless overlap.empty?
334
- msg = overlap.map {|k, v| "(#{k}, #{v.sort.join(', ')})" }.join(", ")
335
- raise ArgumentError, "Multiple aliases for the same option passed: #{msg}"
350
+ overlap_list = overlap.map {|k, v| "(#{k}, #{v.sort.join(', ')})" }.join(", ")
351
+ raise ArgumentError, _("Multiple aliases for the same option passed: %{overlap_list}") %
352
+ { overlap_list: overlap_list }
336
353
  end
337
354
 
338
355
  unless unknown.empty?
339
- msg = unknown.sort.join(", ")
340
- raise ArgumentError, "Unknown options passed: #{msg}"
356
+ unknown_list = unknown.sort.join(", ")
357
+ raise ArgumentError, _("Unknown options passed: %{unknown_list}") % { unknown_list: unknown_list }
341
358
  end
342
359
 
343
360
  # Inject default arguments and check for missing mandating options.
@@ -354,8 +371,8 @@ WRAPPER
354
371
  end
355
372
 
356
373
  unless missing.empty?
357
- msg = missing.sort.join(', ')
358
- raise ArgumentError, "The following options are required: #{msg}"
374
+ missing_list = missing.sort.join(', ')
375
+ raise ArgumentError, _("The following options are required: %{missing_list}") % { missing_list: missing_list }
359
376
  end
360
377
 
361
378
  # All done.
@@ -49,10 +49,12 @@ class Puppet::Interface::ActionBuilder
49
49
  # @dsl Faces
50
50
  def when_rendering(type = nil, &block)
51
51
  if type.nil? then # the default error message sucks --daniel 2011-04-18
52
- raise ArgumentError, 'You must give a rendering format to when_rendering'
52
+ #TRANSLATORS 'when_rendering' is a method name and should not be translated
53
+ raise ArgumentError, _('You must give a rendering format to when_rendering')
53
54
  end
54
55
  if block.nil? then
55
- raise ArgumentError, 'You must give a block to when_rendering'
56
+ #TRANSLATORS 'when_rendering' is a method name and should not be translated
57
+ raise ArgumentError, _('You must give a block to when_rendering')
56
58
  end
57
59
  @action.set_rendering_method_for(type, block)
58
60
  end
@@ -111,11 +113,15 @@ class Puppet::Interface::ActionBuilder
111
113
  # Sets the default rendering format
112
114
  # @api private
113
115
  def render_as(value = nil)
114
- value.nil? and raise ArgumentError, "You must give a rendering format to render_as"
116
+ if value.nil?
117
+ #TRANSLATORS 'render_as' is a method name and should not be translated
118
+ raise ArgumentError, _("You must give a rendering format to render_as")
119
+ end
115
120
 
116
121
  formats = Puppet::Network::FormatHandler.formats
117
122
  unless formats.include? value
118
- raise ArgumentError, "#{value.inspect} is not a valid rendering format: #{formats.sort.join(", ")}"
123
+ raise ArgumentError, _("%{value} is not a valid rendering format: %{formats_list}") %
124
+ { value: value.inspect, formats_list: formats.sort.join(", ")}
119
125
  end
120
126
 
121
127
  @action.render_as = value
@@ -144,6 +150,9 @@ class Puppet::Interface::ActionBuilder
144
150
  @face = face
145
151
  @action = Puppet::Interface::Action.new(face, name)
146
152
  instance_eval(&block)
147
- @action.when_invoked or raise ArgumentError, "actions need to know what to do when_invoked; please add the block"
153
+ unless @action.when_invoked
154
+ #TRANSLATORS 'when_invoked' is a method name and should not be translated and 'block' is a Ruby code block
155
+ raise ArgumentError, _("actions need to know what to do when_invoked; please add the block")
156
+ end
148
157
  end
149
158
  end
@@ -17,7 +17,7 @@ module Puppet::Interface::ActionManager
17
17
  # @dsl Faces
18
18
  def action(name, &block)
19
19
  @actions ||= {}
20
- Puppet.warning "Redefining action #{name} for #{self}" if action?(name)
20
+ Puppet.warning _("Redefining action %{name} for %{self}") % { name: name, self: self } if action?(name)
21
21
 
22
22
  action = Puppet::Interface::ActionBuilder.build(self, name, &block)
23
23
 
@@ -56,7 +56,8 @@ class Puppet::Interface
56
56
  # @dsl Faces
57
57
  attr_doc :summary do |value|
58
58
  value =~ /\n/ and
59
- raise ArgumentError, "Face summary should be a single line; put the long text in 'description' instead."
59
+ #TRANSLATORS 'Face' refers to a programming API in Puppet, 'summary' and 'description' are specifc attribute names and should not be translated
60
+ raise ArgumentError, _("Face summary should be a single line; put the long text in 'description' instead.")
60
61
  value
61
62
  end
62
63
 
@@ -200,11 +201,13 @@ class Puppet::Interface
200
201
  def author(value = nil)
201
202
  unless value.nil? then
202
203
  unless value.is_a? String
203
- raise ArgumentError, 'author must be a string; use multiple statements for multiple authors'
204
+ #TRANSLATORS 'author' is an attribute name and should not be translated
205
+ raise ArgumentError, _('author must be a string; use multiple statements for multiple authors')
204
206
  end
205
207
 
206
208
  if value =~ /\n/ then
207
- raise ArgumentError, 'author should be a single line; use multiple statements for multiple authors'
209
+ #TRANSLATORS 'author' is an attribute name and should not be translated
210
+ raise ArgumentError, _('author should be a single line; use multiple statements for multiple authors')
208
211
  end
209
212
  @authors.push(Puppet::Interface::DocGen.strip_whitespace(value))
210
213
  end
@@ -223,7 +226,8 @@ class Puppet::Interface
223
226
  # I think it's a bug that this ends up being the exposed
224
227
  # version of `author` on ActionBuilder
225
228
  if Array(value).any? {|x| x =~ /\n/ } then
226
- raise ArgumentError, 'author should be a single line; use multiple statements'
229
+ #TRANSLATORS 'author' is an attribute name and should not be translated
230
+ raise ArgumentError, _('author should be a single line; use multiple statements')
227
231
  end
228
232
  @authors = Array(value).map{|x| Puppet::Interface::DocGen.strip_whitespace(x) }
229
233
  end
@@ -243,7 +247,8 @@ class Puppet::Interface
243
247
  # @dsl Faces
244
248
  def copyright(owner = nil, years = nil)
245
249
  if years.nil? and not owner.nil? then
246
- raise ArgumentError, 'copyright takes the owners names, then the years covered'
250
+ #TRANSLATORS 'copyright' is an attribute name and should not be translated
251
+ raise ArgumentError, _('copyright takes the owners names, then the years covered')
247
252
  end
248
253
  self.copyright_owner = owner unless owner.nil?
249
254
  self.copyright_years = years unless years.nil?
@@ -266,7 +271,8 @@ class Puppet::Interface
266
271
  when String then @copyright_owner = value
267
272
  when Array then @copyright_owner = value.join(", ")
268
273
  else
269
- raise ArgumentError, "copyright owner must be a string or an array of strings"
274
+ #TRANSLATORS 'copyright' is an attribute name and should not be translated
275
+ raise ArgumentError, _("copyright owner must be a string or an array of strings")
270
276
  end
271
277
  @copyright_owner
272
278
  end
@@ -302,7 +308,9 @@ class Puppet::Interface
302
308
  fault = "after #{future}"
303
309
  end
304
310
  if fault then
305
- raise ArgumentError, "copyright with a year #{fault} is very strange; did you accidentally add or subtract two years?"
311
+ #TRANSLATORS 'copyright' is an attribute name and should not be translated
312
+ raise ArgumentError, _("copyright with a year %{value} is very strange; did you accidentally add or subtract two years?") %
313
+ { value: fault }
306
314
  end
307
315
 
308
316
  input
@@ -314,11 +322,13 @@ class Puppet::Interface
314
322
  part.to_i
315
323
  elsif found = part.split(/-/) then
316
324
  unless found.length == 2 and found.all? {|x| x.strip =~ /^\d+$/ }
317
- raise ArgumentError, "#{part.inspect} is not a good copyright year or range"
325
+ #TRANSLATORS 'copyright' is an attribute name and should not be translated
326
+ raise ArgumentError, _("%{value} is not a good copyright year or range") % { value: part.inspect }
318
327
  end
319
328
  Range.new(found[0].to_i, found[1].to_i)
320
329
  else
321
- raise ArgumentError, "#{part.inspect} is not a good copyright year or range"
330
+ #TRANSLATORS 'copyright' is an attribute name and should not be translated
331
+ raise ArgumentError, _("%{value} is not a good copyright year or range") % { value: part.inspect }
322
332
  end
323
333
  end
324
334
 
@@ -335,7 +345,8 @@ class Puppet::Interface
335
345
  result
336
346
 
337
347
  else
338
- raise ArgumentError, "#{input.inspect} is not a good copyright year, set, or range"
348
+ #TRANSLATORS 'copyright' is an attribute name and should not be translated
349
+ raise ArgumentError, _("%{value} is not a good copyright year, set, or range") % { value: input.inspect }
339
350
  end
340
351
  end
341
352
  end
@@ -111,7 +111,7 @@ module Puppet::Interface::FaceCollection
111
111
  nil
112
112
  rescue SyntaxError => e
113
113
  raise unless e.message =~ %r{#{path}\.rb:\d+: }
114
- Puppet.err "Failed to load face #{name}:\n#{e}"
114
+ Puppet.err _("Failed to load face %{name}:\n%{detail}") % { name: name, detail: e }
115
115
  # ...but we just carry on after complaining.
116
116
  nil
117
117
  end
@@ -122,7 +122,9 @@ module Puppet::Interface::FaceCollection
122
122
 
123
123
  def self.underscorize(name)
124
124
  unless name.to_s =~ /^[-_a-z][-_a-z0-9]*$/i then
125
- raise ArgumentError, "#{name.inspect} (#{name.class}) is not a valid face name"
125
+ #TRANSLATORS 'face' refers to a programming API in Puppet
126
+ raise ArgumentError, _("%{name} (%{class_name}) is not a valid face name") %
127
+ { name: name.inspect, class_name: name.class }
126
128
  end
127
129
 
128
130
  name.to_s.downcase.split(/[-_]/).join('_').to_sym
@@ -18,7 +18,7 @@ class Puppet::Interface::Option
18
18
  declaration.each do |item|
19
19
  if item.is_a? String and item.to_s =~ /^-/ then
20
20
  unless item =~ /^-[a-z]\b/ or item =~ /^--[^-]/ then
21
- raise ArgumentError, "#{item.inspect}: long options need two dashes (--)"
21
+ raise ArgumentError, _("%{option}: long options need two dashes (--)") % { option: item.inspect }
22
22
  end
23
23
  @optparse << item
24
24
 
@@ -33,20 +33,21 @@ class Puppet::Interface::Option
33
33
  # jeffweiss 17 april 2012
34
34
  name = optparse_to_optionname(item)
35
35
  if Puppet.settings.include? name then
36
- raise ArgumentError, "#{item.inspect}: already defined in puppet"
36
+ raise ArgumentError, _("%{option}: already defined in puppet") % { option: item.inspect }
37
37
  end
38
38
  if dup = dups[name] then
39
- raise ArgumentError, "#{item.inspect}: duplicates existing alias #{dup.inspect} in #{@parent}"
39
+ raise ArgumentError, _("%{option}: duplicates existing alias %{duplicate} in %{parent}") %
40
+ { option: item.inspect, duplicate: dup.inspect, parent: @parent }
40
41
  else
41
42
  dups[name] = item
42
43
  end
43
44
  else
44
- raise ArgumentError, "#{item.inspect} is not valid for an option argument"
45
+ raise ArgumentError, _("%{option} is not valid for an option argument") % { option: item.inspect }
45
46
  end
46
47
  end
47
48
 
48
49
  if @optparse.empty? then
49
- raise ArgumentError, "No option declarations found while building"
50
+ raise ArgumentError, _("No option declarations found while building")
50
51
  end
51
52
 
52
53
  # Now, infer the name from the options; we prefer the first long option as
@@ -59,15 +60,17 @@ class Puppet::Interface::Option
59
60
  # relax this rule later if we find a valid use case for it. --daniel 2011-03-30
60
61
  @argument = @optparse.any? { |o| o =~ /[ =]/ }
61
62
  if @argument and not @optparse.all? { |o| o =~ /[ =]/ } then
62
- raise ArgumentError, "Option #{@name} is inconsistent about taking an argument"
63
+ raise ArgumentError, _("Option %{name} is inconsistent about taking an argument") % { name: @name }
63
64
  end
64
65
 
65
66
  # Is our argument optional? The rules about consistency apply here, also,
66
67
  # just like they do to taking arguments at all. --daniel 2011-03-30
67
68
  @optional_argument = @optparse.any? { |o| o=~/[ =]\[/ }
68
- @optional_argument and raise ArgumentError, "Options with optional arguments are not supported"
69
+ if @optional_argument
70
+ raise ArgumentError, _("Options with optional arguments are not supported")
71
+ end
69
72
  if @optional_argument and not @optparse.all? { |o| o=~/[ =]\[/ } then
70
- raise ArgumentError, "Option #{@name} is inconsistent about the argument being optional"
73
+ raise ArgumentError, _("Option %{name} is inconsistent about the argument being optional") % { name: @name }
71
74
  end
72
75
  end
73
76
 
@@ -82,7 +85,7 @@ class Puppet::Interface::Option
82
85
  # @api private
83
86
  def optparse_to_optionname(declaration)
84
87
  unless found = declaration.match(/^-+(?:\[no-\])?([^ =]+)/) then
85
- raise ArgumentError, "Can't find a name in the declaration #{declaration.inspect}"
88
+ raise ArgumentError, _("Can't find a name in the declaration %{declaration}") % { declaration: declaration.inspect }
86
89
  end
87
90
  found.captures.first
88
91
  end
@@ -90,7 +93,9 @@ class Puppet::Interface::Option
90
93
  # @api private
91
94
  def optparse_to_name(declaration)
92
95
  name = optparse_to_optionname(declaration).tr('-', '_')
93
- raise "#{name.inspect} is an invalid option name" unless name.to_s =~ /^[a-z]\w*$/
96
+ unless name.to_s =~ /^[a-z]\w*$/
97
+ raise _("%{name} is an invalid option name") % { name: name.inspect }
98
+ end
94
99
  name.to_sym
95
100
  end
96
101
 
@@ -110,8 +115,14 @@ class Puppet::Interface::Option
110
115
  end
111
116
 
112
117
  def default=(proc)
113
- required and raise ArgumentError, "#{self} can't be optional and have a default value"
114
- proc.is_a? Proc or raise ArgumentError, "default value for #{self} is a #{proc.class.name.inspect}, not a proc"
118
+ if required
119
+ raise ArgumentError, _("%{name} can't be optional and have a default value") % { name: self }
120
+ end
121
+ unless proc.is_a? Proc
122
+ #TRANSLATORS 'proc' is a Ruby block of code
123
+ raise ArgumentError, _("default value for %{name} is a %{class_name}, not a proc") %
124
+ { name: self, class_name: proc.class.name.inspect }
125
+ end
115
126
  @default = proc
116
127
  end
117
128
 
@@ -122,20 +133,30 @@ class Puppet::Interface::Option
122
133
  attr_reader :parent, :name, :aliases, :optparse
123
134
  attr_accessor :required
124
135
  def required=(value)
125
- has_default? and raise ArgumentError, "#{self} can't be optional and have a default value"
136
+ if has_default?
137
+ raise ArgumentError, _("%{name} can't be optional and have a default value") % { name: self }
138
+ end
126
139
  @required = value
127
140
  end
128
141
 
129
142
  attr_accessor :before_action
130
143
  def before_action=(proc)
131
- proc.is_a? Proc or raise ArgumentError, "before action hook for #{self} is a #{proc.class.name.inspect}, not a proc"
144
+ unless proc.is_a? Proc
145
+ #TRANSLATORS 'proc' is a Ruby block of code
146
+ raise ArgumentError, _("before action hook for %{name} is a %{class_name}, not a proc") %
147
+ { name: self, class_name: proc.class.name.inspect }
148
+ end
132
149
  @before_action =
133
150
  @parent.__send__(:__add_method, __decoration_name(:before), proc)
134
151
  end
135
152
 
136
153
  attr_accessor :after_action
137
154
  def after_action=(proc)
138
- proc.is_a? Proc or raise ArgumentError, "after action hook for #{self} is a #{proc.class.name.inspect}, not a proc"
155
+ unless proc.is_a? Proc
156
+ #TRANSLATORS 'proc' is a Ruby block of code
157
+ raise ArgumentError, _("after action hook for %{name} is a %{class_name}, not a proc") %
158
+ { name: self, class_name: proc.class.name.inspect }
159
+ end
139
160
  @after_action =
140
161
  @parent.__send__(:__add_method, __decoration_name(:after), proc)
141
162
  end