bolt 0.8.0 → 0.9.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 (90) hide show
  1. checksums.yaml +4 -4
  2. data/lib/bolt/cli.rb +31 -21
  3. data/lib/bolt/config.rb +1 -0
  4. data/lib/bolt/error.rb +28 -0
  5. data/lib/bolt/executor.rb +10 -6
  6. data/lib/bolt/node.rb +7 -5
  7. data/lib/bolt/node/errors.rb +25 -3
  8. data/lib/bolt/node/orch.rb +7 -16
  9. data/lib/bolt/node/output.rb +17 -0
  10. data/lib/bolt/node/ssh.rb +101 -44
  11. data/lib/bolt/node/winrm.rb +86 -40
  12. data/lib/bolt/outputter/human.rb +65 -8
  13. data/lib/bolt/outputter/json.rb +8 -1
  14. data/lib/bolt/result.rb +74 -124
  15. data/lib/bolt/version.rb +1 -1
  16. data/{vendored/puppet → modules/boltlib}/lib/puppet/functions/file_upload.rb +9 -7
  17. data/{vendored/puppet → modules/boltlib}/lib/puppet/functions/run_command.rb +8 -9
  18. data/{vendored/puppet → modules/boltlib}/lib/puppet/functions/run_plan.rb +8 -12
  19. data/{vendored/puppet → modules/boltlib}/lib/puppet/functions/run_script.rb +12 -8
  20. data/{vendored/puppet → modules/boltlib}/lib/puppet/functions/run_task.rb +10 -10
  21. data/vendored/puppet/lib/puppet/agent.rb +1 -1
  22. data/vendored/puppet/lib/puppet/application/lookup.rb +1 -3
  23. data/vendored/puppet/lib/puppet/configurer.rb +2 -3
  24. data/vendored/puppet/lib/puppet/configurer/plugin_handler.rb +25 -7
  25. data/vendored/puppet/lib/puppet/defaults.rb +9 -1
  26. data/vendored/puppet/lib/puppet/face/epp.rb +4 -2
  27. data/vendored/puppet/lib/puppet/face/module/build.rb +1 -1
  28. data/vendored/puppet/lib/puppet/face/module/list.rb +5 -16
  29. data/vendored/puppet/lib/puppet/face/module/uninstall.rb +14 -3
  30. data/vendored/puppet/lib/puppet/face/plugin.rb +1 -3
  31. data/vendored/puppet/lib/puppet/forge/errors.rb +17 -7
  32. data/vendored/puppet/lib/puppet/functions.rb +8 -6
  33. data/vendored/puppet/lib/puppet/functions/each.rb +10 -4
  34. data/vendored/puppet/lib/puppet/functions/lookup.rb +2 -2
  35. data/vendored/puppet/lib/puppet/functions/map.rb +12 -2
  36. data/vendored/puppet/lib/puppet/functions/slice.rb +2 -3
  37. data/vendored/puppet/lib/puppet/graph/simple_graph.rb +9 -5
  38. data/vendored/puppet/lib/puppet/interface.rb +1 -0
  39. data/vendored/puppet/lib/puppet/module_tool/errors/installer.rb +27 -17
  40. data/vendored/puppet/lib/puppet/module_tool/errors/shared.rb +143 -63
  41. data/vendored/puppet/lib/puppet/module_tool/errors/uninstaller.rb +37 -14
  42. data/vendored/puppet/lib/puppet/module_tool/errors/upgrader.rb +30 -18
  43. data/vendored/puppet/lib/puppet/network/auth_config_parser.rb +8 -8
  44. data/vendored/puppet/lib/puppet/network/http/error.rb +7 -7
  45. data/vendored/puppet/lib/puppet/network/http/rack.rb +2 -2
  46. data/vendored/puppet/lib/puppet/network/http/webrick.rb +1 -1
  47. data/vendored/puppet/lib/puppet/node.rb +10 -0
  48. data/vendored/puppet/lib/puppet/node/facts.rb +9 -0
  49. data/vendored/puppet/lib/puppet/parameter/value_collection.rb +16 -6
  50. data/vendored/puppet/lib/puppet/parser/resource.rb +103 -31
  51. data/vendored/puppet/lib/puppet/pops/evaluator/access_operator.rb +13 -0
  52. data/vendored/puppet/lib/puppet/pops/evaluator/evaluator_impl.rb +22 -6
  53. data/vendored/puppet/lib/puppet/pops/loader/static_loader.rb +1 -1
  54. data/vendored/puppet/lib/puppet/pops/lookup/lookup_adapter.rb +13 -4
  55. data/vendored/puppet/lib/puppet/pops/model/ast_transformer.rb +1 -1
  56. data/vendored/puppet/lib/puppet/pops/parser/eparser.rb +527 -529
  57. data/vendored/puppet/lib/puppet/pops/serialization/abstract_reader.rb +4 -0
  58. data/vendored/puppet/lib/puppet/pops/serialization/abstract_writer.rb +6 -0
  59. data/vendored/puppet/lib/puppet/pops/serialization/extension.rb +1 -0
  60. data/vendored/puppet/lib/puppet/pops/serialization/serializer.rb +2 -1
  61. data/vendored/puppet/lib/puppet/pops/types/execution_result.rb +8 -0
  62. data/vendored/puppet/lib/puppet/pops/types/iterable.rb +2 -0
  63. data/vendored/puppet/lib/puppet/pops/types/p_object_type.rb +3 -0
  64. data/vendored/puppet/lib/puppet/pops/types/p_object_type_extension.rb +6 -0
  65. data/vendored/puppet/lib/puppet/pops/types/p_uri_type.rb +191 -0
  66. data/vendored/puppet/lib/puppet/pops/types/string_converter.rb +17 -0
  67. data/vendored/puppet/lib/puppet/pops/types/type_calculator.rb +5 -0
  68. data/vendored/puppet/lib/puppet/pops/types/type_factory.rb +7 -0
  69. data/vendored/puppet/lib/puppet/pops/types/type_formatter.rb +16 -18
  70. data/vendored/puppet/lib/puppet/pops/types/type_mismatch_describer.rb +15 -5
  71. data/vendored/puppet/lib/puppet/pops/types/type_parser.rb +6 -0
  72. data/vendored/puppet/lib/puppet/pops/types/type_with_members.rb +43 -0
  73. data/vendored/puppet/lib/puppet/pops/types/types.rb +3 -0
  74. data/vendored/puppet/lib/puppet/provider/package/gem.rb +1 -1
  75. data/vendored/puppet/lib/puppet/provider/package/nim.rb +7 -8
  76. data/vendored/puppet/lib/puppet/provider/package/opkg.rb +1 -1
  77. data/vendored/puppet/lib/puppet/provider/package/pkg.rb +6 -4
  78. data/vendored/puppet/lib/puppet/provider/package/pkgutil.rb +3 -3
  79. data/vendored/puppet/lib/puppet/provider/service/init.rb +1 -1
  80. data/vendored/puppet/lib/puppet/syntax_checkers/base64.rb +5 -6
  81. data/vendored/puppet/lib/puppet/transaction.rb +1 -1
  82. data/vendored/puppet/lib/puppet/type.rb +1 -9
  83. data/vendored/puppet/lib/puppet/type/schedule.rb +1 -1
  84. data/vendored/puppet/lib/puppet/util/log.rb +2 -3
  85. data/vendored/puppet/lib/puppet/util/plist.rb +1 -1
  86. data/vendored/puppet/lib/puppet/util/reference.rb +2 -3
  87. data/vendored/puppet/lib/puppet_pal.rb +326 -53
  88. metadata +28 -12
  89. data/lib/bolt/node/result.rb +0 -115
  90. data/vendored/puppet/lib/puppet/configurer/downloader_factory.rb +0 -44
@@ -63,7 +63,13 @@ Puppet::Face.define(:module, '1.0.0') do
63
63
  name = name.gsub('/', '-')
64
64
 
65
65
  Puppet::ModuleTool.set_option_defaults options
66
- Puppet.notice _("Preparing to uninstall '%{name}'") % { name: name } << (options[:version] ? " (#{colorize(:cyan, options[:version].sub(/^(?=\d)/, 'v'))})" : '') << " ..."
66
+ message = if options[:version]
67
+ module_version = colorize(:cyan, options[:version].sub(/^(?=\d)/, 'v'))
68
+ _("Preparing to uninstall '%{name}' (%{module_version}) ...") % { name: name, module_version: module_version }
69
+ else
70
+ _("Preparing to uninstall '%{name}' ...") % { name: name }
71
+ end
72
+ Puppet.notice message
67
73
  Puppet::ModuleTool::Applications::Uninstaller.run(name, options)
68
74
  end
69
75
 
@@ -73,8 +79,13 @@ Puppet::Face.define(:module, '1.0.0') do
73
79
  exit 1
74
80
  else
75
81
  mod = return_value[:affected_modules].first
76
- module_version = mod.version ? " (#{colorize(:cyan, mod.version.to_s.sub(/^(?=\d)/, 'v'))})" : ''
77
- _("Removed '%{name}'%{module_version} from %{path}") % { name: return_value[:module_name], module_version: module_version, path: mod.modulepath }
82
+ message = if mod.version
83
+ module_version = colorize(:cyan, mod.version.to_s.sub(/^(?=\d)/, 'v'))
84
+ _("Removed '%{name}' (%{module_version}) from %{path}") % { name: return_value[:module_name], module_version: module_version, path: mod.modulepath }
85
+ else
86
+ _("Removed '%{name}' from %{path}") % { name: return_value[:module_name], path: mod.modulepath }
87
+ end
88
+ message
78
89
  end
79
90
  end
80
91
  end
@@ -1,5 +1,4 @@
1
1
  require 'puppet/face'
2
- require 'puppet/configurer/downloader_factory'
3
2
  require 'puppet/configurer/plugin_handler'
4
3
 
5
4
  Puppet::Face.define(:plugin, '0.0.1') do
@@ -42,8 +41,7 @@ Puppet::Face.define(:plugin, '0.0.1') do
42
41
  when_invoked do |options|
43
42
  remote_environment_for_plugins = Puppet::Node::Environment.remote(Puppet[:environment])
44
43
 
45
- factory = Puppet::Configurer::DownloaderFactory.new
46
- handler = Puppet::Configurer::PluginHandler.new(factory)
44
+ handler = Puppet::Configurer::PluginHandler.new()
47
45
  handler.download_plugins(remote_environment_for_plugins)
48
46
  end
49
47
 
@@ -89,9 +89,12 @@ Could not connect to %{uri}
89
89
  rescue JSON::ParserError
90
90
  end
91
91
 
92
- message = _("Request to Puppet Forge failed. Detail: ")
93
- message << @message << " / " if @message
94
- message << @response << "."
92
+ message = if @message
93
+ _("Request to Puppet Forge failed. Detail: %{error_message} / %{http_response}.") %
94
+ { error_message: @message, http_response: @response }
95
+ else
96
+ _("Request to Puppet Forge failed. Detail: %{http_response}.") % { http_response: @response }
97
+ end
95
98
  super(message, original)
96
99
  end
97
100
 
@@ -99,13 +102,20 @@ Could not connect to %{uri}
99
102
  #
100
103
  # @return [String] the multiline version of the error message
101
104
  def multiline
102
- message = _(<<-EOS).chomp % { uri: @uri, response: @response }
105
+ if @message
106
+ _(<<-EOS).chomp % { uri: @uri, response: @response, message: @message }
103
107
  Request to Puppet Forge failed.
104
108
  The server being queried was %{uri}
105
109
  The HTTP response we received was '%{response}'
106
- EOS
107
- message << _("\n The message we received said '%{message}'") % { message: @message } if @message
108
- message
110
+ The message we received said '%{message}'
111
+ EOS
112
+ else
113
+ _(<<-EOS).chomp % { uri: @uri, response: @response }
114
+ Request to Puppet Forge failed.
115
+ The server being queried was %{uri}
116
+ The HTTP response we received was '%{response}'
117
+ EOS
118
+ end
109
119
  end
110
120
  end
111
121
 
@@ -474,8 +474,8 @@ module Puppet::Functions
474
474
  type = @all_callables
475
475
  name = type_and_name[0]
476
476
  when 2
477
- type_string, name = type_and_name
478
- type = Puppet::Pops::Types::TypeParser.singleton.parse(type_string, loader)
477
+ type, name = type_and_name
478
+ type = Puppet::Pops::Types::TypeParser.singleton.parse(type, loader) unless type.is_a?(Puppet::Pops::Types::PAnyType)
479
479
  else
480
480
  raise ArgumentError, _("block_param accepts max 2 arguments (type, name), got %{size}.") % { size: type_and_name.size }
481
481
  end
@@ -513,7 +513,9 @@ module Puppet::Functions
513
513
  #
514
514
  # @api public
515
515
  def return_type(type)
516
- raise ArgumentError, _("Argument to 'return_type' must be a String reference to a Puppet Data Type. Got %{type_class}") % { type_class: type.class } unless type.is_a?(String)
516
+ unless type.is_a?(String) || type.is_a?(Puppet::Pops::Types::PAnyType)
517
+ raise ArgumentError, _("Argument to 'return_type' must be a String reference to a Puppet Data Type. Got %{type_class}") % { type_class: type.class }
518
+ end
517
519
  @return_type = type
518
520
  end
519
521
 
@@ -528,7 +530,7 @@ module Puppet::Functions
528
530
  raise ArgumentError, _("Parameter name argument must be a Symbol. Got %{name_class}") % { name_class: name.class }
529
531
  end
530
532
 
531
- if type.is_a?(String)
533
+ if type.is_a?(String) || type.is_a?(Puppet::Pops::Types::PAnyType)
532
534
  @types << type
533
535
  @names << name
534
536
  # mark what should be picked for this position when dispatching
@@ -571,10 +573,10 @@ module Puppet::Functions
571
573
  # @api private
572
574
  def create_callable(types, block_type, return_type, from, to)
573
575
  mapped_types = types.map do |t|
574
- Puppet::Pops::Types::TypeParser.singleton.parse(t, loader)
576
+ t.is_a?(Puppet::Pops::Types::PAnyType) ? t : Puppet::Pops::Types::TypeParser.singleton.parse(t, loader)
575
577
  end
576
578
  param_types = Puppet::Pops::Types::PTupleType.new(mapped_types, from > 0 && from == to ? nil : Puppet::Pops::Types::PIntegerType.new(from, to))
577
- return_type = Puppet::Pops::Types::TypeParser.singleton.parse(return_type, loader) unless return_type.nil?
579
+ return_type = Puppet::Pops::Types::TypeParser.singleton.parse(return_type, loader) unless return_type.nil? || return_type.is_a?(Puppet::Pops::Types::PAnyType)
578
580
  Puppet::Pops::Types::PCallableType.new(param_types, block_type, return_type)
579
581
  end
580
582
  end
@@ -117,8 +117,11 @@ Puppet::Functions.create_function(:each) do
117
117
 
118
118
  def foreach_Hash_1(hash)
119
119
  enumerator = hash.each_pair
120
- hash.size.times do
121
- yield(enumerator.next)
120
+ begin
121
+ hash.size.times do
122
+ yield(enumerator.next)
123
+ end
124
+ rescue StopIteration
122
125
  end
123
126
  # produces the receiver
124
127
  hash
@@ -126,8 +129,11 @@ Puppet::Functions.create_function(:each) do
126
129
 
127
130
  def foreach_Hash_2(hash)
128
131
  enumerator = hash.each_pair
129
- hash.size.times do
130
- yield(*enumerator.next)
132
+ begin
133
+ hash.size.times do
134
+ yield(*enumerator.next)
135
+ end
136
+ rescue StopIteration
131
137
  end
132
138
  # produces the receiver
133
139
  hash
@@ -91,8 +91,8 @@
91
91
  # merged hash. If the same key exists in multiple source hashes, Puppet will
92
92
  # recursively merge hash or array values (with duplicate values removed from
93
93
  # arrays). For conflicting scalar values, the highest-priority value will win.
94
- # * `{'strategy' => 'first|unique|hash'}` --- Same as the string versions of these
95
- # merge behaviors.
94
+ # * `{'strategy' => 'first'}`, `{'strategy' => 'unique'}`,
95
+ # or `{'strategy' => 'hash'}` --- Same as the string versions of these merge behaviors.
96
96
  # * `{'strategy' => 'deep', <DEEP OPTION> => <VALUE>, ...}` --- Same as `'deep'`,
97
97
  # but can adjust the merge with additional options. The available options are:
98
98
  # * `'knockout_prefix'` (string or undef) --- A string prefix to indicate a
@@ -88,11 +88,21 @@ Puppet::Functions.create_function(:map) do
88
88
  end
89
89
 
90
90
  def map_Hash_1(hash)
91
- hash.map {|x, y| yield([x, y]) }
91
+ result = []
92
+ begin
93
+ hash.map {|x, y| result << yield([x, y]) }
94
+ rescue StopIteration
95
+ end
96
+ result
92
97
  end
93
98
 
94
99
  def map_Hash_2(hash)
95
- hash.map {|x, y| yield(x, y) }
100
+ result = []
101
+ begin
102
+ hash.map {|x, y| result << yield(x, y) }
103
+ rescue StopIteration
104
+ end
105
+ result
96
106
  end
97
107
 
98
108
  def map_Enumerable_1(enumerable)
@@ -102,9 +102,8 @@ Puppet::Functions.create_function(:slice) do
102
102
  raise ArgumentError, _("slice(): block must define at least one parameter. Block has 0.")
103
103
  end
104
104
  unless serving_size == 1 || serving_size == slice_size
105
- raise ArgumentError, _("slice(): block must define one parameter, or ") +
106
- _("the same number of parameters as the given size of the slice (%{slice_size}). Block has %{serving_size}; ") % { slice_size: slice_size, serving_size: serving_size }+
107
- pblock.parameter_names.join(', ')
105
+ raise ArgumentError, _("slice(): block must define one parameter, or the same number of parameters as the given size of the slice (%{slice_size}). Block has %{serving_size}; %{parameter_names}") %
106
+ { slice_size: slice_size, serving_size: serving_size, parameter_names: pblock.parameter_names.join(', ') }
108
107
  end
109
108
  serving_size
110
109
  end
@@ -228,19 +228,23 @@ class Puppet::Graph::SimpleGraph
228
228
  number_of_cycles = cycles.length
229
229
  return if number_of_cycles == 0
230
230
 
231
- message = n_("Found %{num} dependency cycle:\n", "Found %{num} dependency cycles:\n", number_of_cycles) % { num: number_of_cycles }
231
+ cycle_path_list = ''
232
232
  cycles.each do |cycle|
233
233
  paths = paths_in_cycle(cycle)
234
- message += paths.map{ |path| '(' + path.join(" => ") + ')'}.join("\n") + "\n"
234
+ cycle_path_list += paths.map{ |path| '(' + path.join(' => ') + ')'}.join('\n')
235
235
  end
236
236
 
237
237
  if Puppet[:graph] then
238
238
  filename = write_cycles_to_graph(cycles)
239
- message += _("Cycle graph written to %{filename}.") % { filename: filename }
239
+ message = n_("Found %{number_of_cycles} dependency cycle:\n%{cycle_path_list}\nCycle graph written to %{filename}.",
240
+ "Found %{number_of_cycles} dependency cycles:\n%{cycle_path_list}\nCycle graph written to %{filename}.", number_of_cycles) %
241
+ { number_of_cycles: number_of_cycles, cycle_path_list: cycle_path_list, filename: filename }
240
242
  else
241
- #TRANSLATORS "graph" refers to a command line option and should not be translated
243
+ #TRANSLATORS '--graph' refers to a command line option and should not be translated
242
244
  #TRANSLATORS OmniGraffle and GraphViz and program names and should not be translated
243
- message += _("Try the '--graph' option and opening the resulting '.dot' file in OmniGraffle or GraphViz")
245
+ message = n_("Found %{number_of_cycles} dependency cycle:\n%{cycle_path_list}\nTry the '--graph' option and opening the resulting '.dot' file in OmniGraffle or GraphViz",
246
+ "Found %{number_of_cycles} dependency cycles:\n%{cycle_path_list}\nTry the '--graph' option and opening the resulting '.dot' file in OmniGraffle or GraphViz", number_of_cycles) %
247
+ { number_of_cycles: number_of_cycles, cycle_path_list: cycle_path_list }
244
248
  end
245
249
  Puppet.err(message)
246
250
  cycles
@@ -178,6 +178,7 @@ class Puppet::Interface
178
178
  def to_s
179
179
  "Puppet::Face[#{name.inspect}, #{version.inspect}]"
180
180
  end
181
+ alias_method :inspect, :to_s
181
182
 
182
183
  # @return [void]
183
184
  def deprecate
@@ -12,13 +12,24 @@ module Puppet::ModuleTool::Errors
12
12
  end
13
13
 
14
14
  def multiline
15
- message = []
16
- message << _("Could not install module '%{module_name}' (%{version})") % { module_name: @module_name, version: @requested_version }
17
- message << _(" Module '%{module_name}' (%{version}) is already installed") % { module_name: @module_name, version: @installed_version }
18
- message << _(" Installed module has had changes made locally") unless @local_changes.empty?
19
- message << _(" Use `puppet module upgrade` to install a different version")
20
- message << _(" Use `puppet module install --force` to re-install only this module")
21
- message.join("\n")
15
+ if @local_changes.empty?
16
+ #TRANSLATORS `puppet module upgrade` and `puppet module upgrade` are a command line and should not be translated
17
+ _(<<-MSG).chomp % { module_name: @module_name, requested_version: @requested_version, installed_version: @installed_version }
18
+ Could not install module '%{module_name}' (%{requested_version})
19
+ Module '%{module_name}' (%{installed_version}) is already installed
20
+ Use `puppet module upgrade` to install a different version
21
+ Use `puppet module install --force` to re-install only this module
22
+ MSG
23
+ else
24
+ #TRANSLATORS `puppet module upgrade` and `puppet module upgrade` are a command line and should not be translated
25
+ _(<<-MSG).chomp % { module_name: @module_name, requested_version: @requested_version, installed_version: @installed_version }
26
+ Could not install module '%{module_name}' (%{requested_version})
27
+ Module '%{module_name}' (%{installed_version}) is already installed
28
+ Installed module has had changes made locally
29
+ Use `puppet module upgrade` to install a different version
30
+ Use `puppet module install --force` to re-install only this module
31
+ MSG
32
+ end
22
33
  end
23
34
  end
24
35
 
@@ -31,13 +42,11 @@ module Puppet::ModuleTool::Errors
31
42
  end
32
43
 
33
44
  def multiline
34
- message = []
35
- message << _("Could not install '%{requested_package}'") % { requested_package: @requested_package }
36
-
37
- message << _(" No releases are available from %{source}") % { source: @source }
38
- message << _(" Does '%{requested_package}' have at least one published release?") % { requested_package: @requested_package }
39
-
40
- message.join("\n")
45
+ _(<<-MSG).chomp % { requested_package: @requested_package, source: @source }
46
+ Could not install '%{requested_package}'
47
+ No releases are available from %{source}
48
+ Does '%{requested_package}' have at least one published release?
49
+ MSG
41
50
  end
42
51
  end
43
52
 
@@ -50,7 +59,8 @@ module Puppet::ModuleTool::Errors
50
59
  end
51
60
 
52
61
  def multiline
53
- _(<<-MSG).strip % { module_name: @requested_module, version: @requested_version, dir: @directory }
62
+ # TRANSLATORS "mkdir -p'%{dir}'" is a command line example and should not be translated
63
+ _(<<-MSG).chomp % { module_name: @requested_module, version: @requested_version, dir: @directory }
54
64
  Could not install module '%{module_name}' (%{version})
55
65
  Path '%{dir}' exists but is not a directory.
56
66
  A potential solution is to rename the path and then
@@ -68,7 +78,7 @@ Could not install module '%{module_name}' (%{version})
68
78
  end
69
79
 
70
80
  def multiline
71
- _(<<-MSG).strip % { module_name: @requested_module, version: @requested_version, dir: @directory }
81
+ _(<<-MSG).chomp % { module_name: @requested_module, version: @requested_version, dir: @directory }
72
82
  Could not install module '%{module_name}' (%{version})
73
83
  Permission is denied when trying to create directory '%{dir}'.
74
84
  A potential solution is to check the ownership and permissions of
@@ -85,7 +95,7 @@ Could not install module '%{module_name}' (%{version})
85
95
  end
86
96
 
87
97
  def multiline
88
- _(<<-MSG).strip % { path: @entry_path.inspect, dir: @directory.inspect }
98
+ _(<<-MSG).chomp % { path: @entry_path.inspect, dir: @directory.inspect }
89
99
  Could not install package with an invalid path.
90
100
  Package attempted to install file into
91
101
  %{path} under %{dir}.
@@ -12,12 +12,12 @@ module Puppet::ModuleTool::Errors
12
12
  end
13
13
 
14
14
  def multiline
15
- message = []
16
- message << _("Could not %{action} module '%{module_name}' (%{version})") % { action: @action, module_name: @requested_name, version: vstring }
17
- message << _(" No version of '%{module_name}' can satisfy all dependencies") % { module_name: @requested_name }
18
- message << _(" Use `puppet module %{action} --ignore-dependencies` to %{action} only this module") % { action: @action }
19
-
20
- message.join("\n")
15
+ #TRANSLATORS `puppet module %{action} --ignore-dependencies` is a command line and should not be translated
16
+ _(<<-EOM).chomp % { action: @action, module_name: @requested_name, version: vstring }
17
+ Could not %{action} module '%{module_name}' (%{version})
18
+ No version of '%{module_name}' can satisfy all dependencies
19
+ Use `puppet module %{action} --ignore-dependencies` to %{action} only this module
20
+ EOM
21
21
  end
22
22
  end
23
23
 
@@ -37,17 +37,18 @@ module Puppet::ModuleTool::Errors
37
37
  end
38
38
 
39
39
  def multiline
40
- message = []
41
- message << _("Could not %{action} '%{module_name}' (%{version})") % { action: @action, module_name: @module_name, version: vstring }
42
-
43
40
  if @requested_version == :latest
44
- message << _(" No releases are available from %{source}") % { source: @source }
45
- message << _(" Does '%{module_name}' have at least one published release?") % { module_name: @module_name }
41
+ _(<<-EOM).chomp % { action: @action, module_name: @module_name, version: vstring, source: @source }
42
+ Could not %{action} '%{module_name}' (%{version})
43
+ No releases are available from %{source}
44
+ Does '%{module_name}' have at least one published release?
45
+ EOM
46
46
  else
47
- message << _(" No releases matching '%{version}' are available from %{source}") % { version: @requested_version, source: @source }
47
+ _(<<-EOM).chomp % { action: @action, module_name: @module_name, version: vstring, requested_version: @requested_version, source: @source }
48
+ Could not %{action} '%{module_name}' (%{version})
49
+ No releases matching '%{requested_version}' are available from %{source}
50
+ EOM
48
51
  end
49
-
50
- message.join("\n")
51
52
  end
52
53
  end
53
54
 
@@ -62,26 +63,49 @@ module Puppet::ModuleTool::Errors
62
63
  end
63
64
 
64
65
  def multiline
65
- message = []
66
- message << _("Could not install module '%{module_name}' (%{version})") % { module_name: @requested_module, version: @requested_version }
67
-
68
66
  if @dependency
69
- message << _(" Dependency '%{name}' (%{version}) would overwrite %{dir}") % { name: @dependency[:name], version: v(@dependency[:version]), dir: @directory }
70
- else
71
- message << _(" Installation would overwrite %{dir}") % { dir: @directory }
72
- end
73
-
74
- if @metadata
75
- message << _(" Currently, '%{name}' (%{version}) is installed to that directory") % { name: @metadata["name"], version: v(@metadata["version"]) }
76
- end
67
+ if @metadata
68
+ msg_variables = { module_name: @requested_module, requested_version: @requested_version,
69
+ name: @dependency[:name], version: v(@dependency[:version]),
70
+ directory: @directory, current_name: @metadata["name"], current_version: v(@metadata["version"]) }
71
+ #TRANSLATORS `puppet module install --ignore-dependencies` is a command line and should not be translated
72
+ _(<<-EOM).chomp % msg_variables
73
+ Could not install module '%{module_name}' (%{requested_version})
74
+ Dependency '%{name}' (%{version}) would overwrite %{directory}
75
+ Currently, '%{current_name}' (%{current_version}) is installed to that directory
76
+ Use `puppet module install --ignore-dependencies` to install only this module
77
+ EOM
78
+ else
79
+ msg_variables = { module_name: @requested_module, requested_version: @requested_version,
80
+ name: @dependency[:name], version: v(@dependency[:version]), directory: @directory }
81
+ #TRANSLATORS `puppet module install --ignore-dependencies` is a command line and should not be translated
82
+ _(<<-EOM).chomp % msg_variables
83
+ Could not install module '%{module_name}' (%{requested_version})
84
+ Dependency '%{name}' (%{version}) would overwrite %{directory}
85
+ Use `puppet module install --ignore-dependencies` to install only this module
86
+ EOM
87
+ end
77
88
 
78
- if @dependency
79
- message << _(" Use `puppet module install --ignore-dependencies` to install only this module")
80
89
  else
81
- message << _(" Use `puppet module install --force` to install this module anyway")
90
+ if @metadata
91
+ msg_variables = { module_name: @requested_module, requested_version: @requested_version,
92
+ directory: @directory, current_name: @metadata["name"], current_version: v(@metadata["version"]) }
93
+ #TRANSLATORS `puppet module install --force` is a command line and should not be translated
94
+ _(<<-EOM).chomp % msg_variables
95
+ Could not install module '%{module_name}' (%{requested_version})
96
+ Installation would overwrite %{directory}
97
+ Currently, '%{current_name}' (%{current_version}) is installed to that directory
98
+ Use `puppet module install --force` to install this module anyway
99
+ EOM
100
+ else
101
+ #TRANSLATORS `puppet module install --force` is a command line and should not be translated
102
+ _(<<-EOM).chomp % { module_name: @requested_module, requested_version: @requested_version, directory: @directory }
103
+ Could not install module '%{module_name}' (%{requested_version})
104
+ Installation would overwrite %{directory}
105
+ Use `puppet module install --force` to install this module anyway
106
+ EOM
107
+ end
82
108
  end
83
-
84
- message.join("\n")
85
109
  end
86
110
  end
87
111
 
@@ -97,18 +121,33 @@ module Puppet::ModuleTool::Errors
97
121
  end
98
122
 
99
123
  def multiline
100
- trace = []
101
- trace << _("You specified '%{name}' (%{version})") % { name: @source.first[:name], version: v(@requested_version) }
102
- #TRANSLATORS Second half of "You specified a module..."
103
- trace += @source[1..-1].map { |m| _("which depends on '%{name}' (%{version})") % { name: m[:name], version: v(m[:version]) } }
104
-
105
- message = []
106
- message << _("Could not install module '%{module_name}' (%{version})") % { module_name: @requested_module, version: v(@requested_version) }
107
- message << _(" No version of '%{module_name}' will satisfy dependencies") % { module_name: @module_name }
108
- message << trace.map { |s| " #{s}".join(",\n") }
109
- message << _(" Use `puppet module install --force` to install this module anyway")
124
+ dependency_list = @source[1..-1].map do |m|
125
+ #TRANSLATORS This message repeats as separate lines as a list under the heading "You specified '%{name}' (%{version})\n"
126
+ _(" which depends on '%{name}' (%{version})") % { name: m[:name], version: v(m[:version]) }
127
+ end.join(",\n")
110
128
 
111
- message.join("\n")
129
+ if dependency_list.empty?
130
+ msg_variables = { requested_module_name: @requested_module, version: v(@requested_version), module_name: @module_name,
131
+ name: @source.first[:name] }
132
+ #TRANSLATORS `puppet module install --force` is a command line and should not be translated
133
+ _(<<-EOM).chomp % msg_variables
134
+ Could not install module '%{requested_module_name}' (%{version})
135
+ No version of '%{module_name}' will satisfy dependencies
136
+ You specified '%{name}' (%{version})
137
+ Use `puppet module install --force` to install this module anyway
138
+ EOM
139
+ else
140
+ msg_variables = { requested_module_name: @requested_module, version: v(@requested_version), module_name: @module_name,
141
+ name: @source.first[:name], dependency_list: dependency_list }
142
+ #TRANSLATORS `puppet module install --force` is a command line and should not be translated
143
+ _(<<-EOM).chomp % msg_variables
144
+ Could not install module '%{requested_module_name}' (%{version})
145
+ No version of '%{module_name}' will satisfy dependencies
146
+ You specified '%{name}' (%{version})
147
+ %{dependency_list}
148
+ Use `puppet module install --force` to install this module anyway
149
+ EOM
150
+ end
112
151
  end
113
152
  end
114
153
 
@@ -121,14 +160,41 @@ module Puppet::ModuleTool::Errors
121
160
  end
122
161
 
123
162
  def multiline
124
- message = []
125
- message << _("Could not %{action} module '%{module_name}'") % { action: @action, module_name: @module_name }
126
- message << _(" Module '%{module_name}' is not installed") % { module_name: @module_name }
127
- message += @suggestions.map do |suggestion|
163
+ suggestion_list = @suggestions.map do |suggestion|
128
164
  _(" You may have meant `puppet module %{action} %{suggestion}`") % { action: @action, suggestion: suggestion }
165
+ end.join("\n")
166
+
167
+ if @action == :upgrade
168
+ if suggestion_list.empty?
169
+ # TRANSLATORS `puppet module install` is a command line and should not be translated
170
+ _(<<-EOM).chomp % { action: @action, module_name: @module_name }
171
+ Could not %{action} module '%{module_name}'
172
+ Module '%{module_name}' is not installed
173
+ Use `puppet module install` to install this module
174
+ EOM
175
+ else
176
+ # TRANSLATORS `puppet module install` is a command line and should not be translated
177
+ _(<<-EOM).chomp % { action: @action, module_name: @module_name, suggestion_list: suggestion_list }
178
+ Could not %{action} module '%{module_name}'
179
+ Module '%{module_name}' is not installed
180
+ %{suggestion_list}
181
+ Use `puppet module install` to install this module
182
+ EOM
183
+ end
184
+ else
185
+ if suggestion_list.empty?
186
+ _(<<-EOM).chomp % { action: @action, module_name: @module_name }
187
+ Could not %{action} module '%{module_name}'
188
+ Module '%{module_name}' is not installed
189
+ EOM
190
+ else
191
+ _(<<-EOM).chomp % { action: @action, module_name: @module_name, suggestion_list: suggestion_list }
192
+ Could not %{action} module '%{module_name}'
193
+ Module '%{module_name}' is not installed
194
+ %{suggestion_list}
195
+ EOM
196
+ end
129
197
  end
130
- message << _(" Use `puppet module install` to install this module") if @action == :upgrade
131
- message.join("\n")
132
198
  end
133
199
  end
134
200
 
@@ -142,14 +208,27 @@ module Puppet::ModuleTool::Errors
142
208
  end
143
209
 
144
210
  def multiline
145
- message = []
146
- message << _("Could not %{action} module '%{module_name}'") % { action: @action, module_name: @module_name }
147
- message << _(" Module '%{module_name}' appears multiple places in the module path") % { module_name: @module_name }
148
- message += @modules.map do |mod|
211
+ module_path_list = @modules.map do |mod|
212
+ #TRANSLATORS This is repeats as separate lines as a list under "Module '%{module_name}' appears multiple places in the module path"
149
213
  _(" '%{module_name}' (%{version}) was found in %{path}") % { module_name: @module_name, version: v(mod.version), path: mod.modulepath }
214
+ end.join("\n")
215
+
216
+ if module_path_list.empty?
217
+ # TRANSLATORS `--modulepath` is command line option and should not be translated
218
+ _(<<-EOM).chomp % { action: @action, module_name: @module_name }
219
+ Could not %{action} module '%{module_name}'
220
+ Module '%{module_name}' appears multiple places in the module path
221
+ Use the `--modulepath` option to limit the search to specific directories
222
+ EOM
223
+ else
224
+ # TRANSLATORS `--modulepath` is command line option and should not be translated
225
+ _(<<-EOM).chomp % { action: @action, module_name: @module_name, module_path_list: module_path_list }
226
+ Could not %{action} module '%{module_name}'
227
+ Module '%{module_name}' appears multiple places in the module path
228
+ %{module_path_list}
229
+ Use the `--modulepath` option to limit the search to specific directories
230
+ EOM
150
231
  end
151
- message << _(" Use the `--modulepath` option to limit the search to specific directories")
152
- message.join("\n")
153
232
  end
154
233
  end
155
234
 
@@ -163,11 +242,12 @@ module Puppet::ModuleTool::Errors
163
242
  end
164
243
 
165
244
  def multiline
166
- message = []
167
- message << _("Could not %{action} module '%{module_name}' (%{version})") % { action: @action, module_name: @module_name, version: vstring }
168
- message << _(" Installed module has had changes made locally")
169
- message << _(" Use `puppet module %{action} --ignore-changes` to %{action} this module anyway") % { action: @action }
170
- message.join("\n")
245
+ #TRANSLATORS `puppet module %{action} --ignore-changes` is a command line and should not be translated
246
+ _(<<-EOM).chomp % { action: @action, module_name: @module_name, version: vstring }
247
+ Could not %{action} module '%{module_name}' (%{version})
248
+ Installed module has had changes made locally
249
+ Use `puppet module %{action} --ignore-changes` to %{action} this module anyway
250
+ EOM
171
251
  end
172
252
  end
173
253
 
@@ -180,11 +260,11 @@ module Puppet::ModuleTool::Errors
180
260
  end
181
261
 
182
262
  def multiline
183
- message = []
184
- message << _("Could not %{action} module '%{module_name}'") % { action: @action, module_name: @name }
185
- message << _(" Failure trying to parse metadata")
186
- message << _(" Original message was: %{message}") % { message: @error.message }
187
- message.join("\n")
263
+ _(<<-EOM).chomp % { action: @action, module_name: @name, message: @error.message }
264
+ Could not %{action} module '%{module_name}'
265
+ Failure trying to parse metadata
266
+ Original message was: %{message}
267
+ EOM
188
268
  end
189
269
  end
190
270
  end