bolt 0.11.0 → 0.12.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 (165) hide show
  1. checksums.yaml +4 -4
  2. data/lib/bolt/cli.rb +127 -31
  3. data/lib/bolt/config.rb +39 -6
  4. data/lib/bolt/execution_result.rb +109 -0
  5. data/lib/bolt/executor.rb +4 -1
  6. data/lib/bolt/node.rb +6 -1
  7. data/lib/bolt/node/orch.rb +20 -2
  8. data/lib/bolt/node/winrm.rb +22 -10
  9. data/lib/bolt/node_uri.rb +5 -7
  10. data/lib/bolt/outputter/human.rb +60 -1
  11. data/lib/bolt/outputter/json.rb +11 -0
  12. data/lib/bolt/target.rb +32 -0
  13. data/lib/bolt/version.rb +1 -1
  14. data/modules/boltlib/lib/puppet/datatypes/executionresult.rb +30 -0
  15. data/modules/boltlib/lib/puppet/datatypes/target.rb +12 -0
  16. data/modules/boltlib/lib/puppet/functions/file_upload.rb +3 -3
  17. data/modules/boltlib/lib/puppet/functions/run_command.rb +3 -3
  18. data/modules/boltlib/lib/puppet/functions/run_script.rb +3 -3
  19. data/modules/boltlib/lib/puppet/functions/run_task.rb +10 -2
  20. data/vendored/puppet/lib/puppet/application/describe.rb +0 -1
  21. data/vendored/puppet/lib/puppet/configurer.rb +1 -1
  22. data/vendored/puppet/lib/puppet/configurer/plugin_handler.rb +15 -9
  23. data/vendored/puppet/lib/puppet/datatypes.rb +213 -0
  24. data/vendored/puppet/lib/puppet/datatypes/error.rb +19 -0
  25. data/vendored/puppet/lib/puppet/datatypes/impl/error.rb +42 -0
  26. data/vendored/puppet/lib/puppet/error.rb +1 -1
  27. data/vendored/puppet/lib/puppet/face/catalog.rb +1 -1
  28. data/vendored/puppet/lib/puppet/face/epp.rb +3 -3
  29. data/vendored/puppet/lib/puppet/face/help.rb +12 -14
  30. data/vendored/puppet/lib/puppet/face/man.rb +1 -0
  31. data/vendored/puppet/lib/puppet/face/module/search.rb +1 -1
  32. data/vendored/puppet/lib/puppet/face/node.rb +1 -0
  33. data/vendored/puppet/lib/puppet/face/parser.rb +0 -1
  34. data/vendored/puppet/lib/puppet/face/status.rb +1 -0
  35. data/vendored/puppet/lib/puppet/feature/base.rb +1 -1
  36. data/vendored/puppet/lib/puppet/file_bucket/dipper.rb +0 -1
  37. data/vendored/puppet/lib/puppet/file_system/uniquefile.rb +2 -2
  38. data/vendored/puppet/lib/puppet/forge/errors.rb +21 -29
  39. data/vendored/puppet/lib/puppet/functions.rb +64 -84
  40. data/vendored/puppet/lib/puppet/functions/defined.rb +0 -3
  41. data/vendored/puppet/lib/puppet/functions/find_file.rb +0 -1
  42. data/vendored/puppet/lib/puppet/functions/map.rb +0 -1
  43. data/vendored/puppet/lib/puppet/functions/regsubst.rb +1 -1
  44. data/vendored/puppet/lib/puppet/graph/simple_graph.rb +6 -10
  45. data/vendored/puppet/lib/puppet/indirector/catalog/compiler.rb +37 -25
  46. data/vendored/puppet/lib/puppet/indirector/file_server.rb +1 -1
  47. data/vendored/puppet/lib/puppet/indirector/indirection.rb +0 -2
  48. data/vendored/puppet/lib/puppet/indirector/rest.rb +9 -8
  49. data/vendored/puppet/lib/puppet/info_service/class_information_service.rb +1 -1
  50. data/vendored/puppet/lib/puppet/interface/option_manager.rb +1 -1
  51. data/vendored/puppet/lib/puppet/loaders.rb +1 -0
  52. data/vendored/puppet/lib/puppet/module.rb +6 -2
  53. data/vendored/puppet/lib/puppet/module_tool/applications/unpacker.rb +1 -1
  54. data/vendored/puppet/lib/puppet/module_tool/errors/installer.rb +29 -41
  55. data/vendored/puppet/lib/puppet/module_tool/errors/shared.rb +63 -138
  56. data/vendored/puppet/lib/puppet/module_tool/errors/uninstaller.rb +15 -37
  57. data/vendored/puppet/lib/puppet/module_tool/errors/upgrader.rb +18 -30
  58. data/vendored/puppet/lib/puppet/module_tool/installed_modules.rb +1 -1
  59. data/vendored/puppet/lib/puppet/module_tool/metadata.rb +0 -1
  60. data/vendored/puppet/lib/puppet/network/http/api/indirected_routes.rb +1 -1
  61. data/vendored/puppet/lib/puppet/network/rights.rb +1 -1
  62. data/vendored/puppet/lib/puppet/node.rb +1 -1
  63. data/vendored/puppet/lib/puppet/node/environment.rb +1 -1
  64. data/vendored/puppet/lib/puppet/parameter/value_collection.rb +4 -17
  65. data/vendored/puppet/lib/puppet/parser/compiler.rb +1 -0
  66. data/vendored/puppet/lib/puppet/parser/functions.rb +0 -1
  67. data/vendored/puppet/lib/puppet/parser/functions/scanf.rb +1 -1
  68. data/vendored/puppet/lib/puppet/parser/scope.rb +4 -3
  69. data/vendored/puppet/lib/puppet/parser/script_compiler.rb +1 -0
  70. data/vendored/puppet/lib/puppet/parser/templatewrapper.rb +3 -2
  71. data/vendored/puppet/lib/puppet/parser/type_loader.rb +1 -1
  72. data/vendored/puppet/lib/puppet/pops.rb +1 -0
  73. data/vendored/puppet/lib/puppet/pops/evaluator/access_operator.rb +3 -2
  74. data/vendored/puppet/lib/puppet/pops/evaluator/closure.rb +1 -1
  75. data/vendored/puppet/lib/puppet/pops/evaluator/evaluator_impl.rb +2 -2
  76. data/vendored/puppet/lib/puppet/pops/functions/dispatch.rb +6 -5
  77. data/vendored/puppet/lib/puppet/pops/functions/function.rb +2 -2
  78. data/vendored/puppet/lib/puppet/pops/loader/loader.rb +1 -1
  79. data/vendored/puppet/lib/puppet/pops/loader/loader_paths.rb +40 -4
  80. data/vendored/puppet/lib/puppet/pops/loader/module_loaders.rb +6 -2
  81. data/vendored/puppet/lib/puppet/pops/loader/puppet_resource_type_impl_instantiator.rb +8 -8
  82. data/vendored/puppet/lib/puppet/pops/loader/ruby_data_type_instantiator.rb +40 -0
  83. data/vendored/puppet/lib/puppet/pops/loader/static_loader.rb +6 -26
  84. data/vendored/puppet/lib/puppet/pops/loaders.rb +11 -2
  85. data/vendored/puppet/lib/puppet/pops/lookup/data_dig_function_provider.rb +1 -1
  86. data/vendored/puppet/lib/puppet/pops/lookup/lookup_adapter.rb +4 -14
  87. data/vendored/puppet/lib/puppet/pops/model/model_tree_dumper.rb +1 -1
  88. data/vendored/puppet/lib/puppet/pops/parser/code_merger.rb +2 -2
  89. data/vendored/puppet/lib/puppet/pops/parser/eparser.rb +1471 -1501
  90. data/vendored/puppet/lib/puppet/pops/parser/epp_support.rb +0 -2
  91. data/vendored/puppet/lib/puppet/pops/parser/evaluating_parser.rb +1 -1
  92. data/vendored/puppet/lib/puppet/pops/parser/interpolation_support.rb +1 -1
  93. data/vendored/puppet/lib/puppet/pops/parser/lexer2.rb +2 -26
  94. data/vendored/puppet/lib/puppet/pops/parser/locator.rb +5 -7
  95. data/vendored/puppet/lib/puppet/pops/parser/parser_support.rb +2 -2
  96. data/vendored/puppet/lib/puppet/pops/parser/slurp_support.rb +0 -3
  97. data/vendored/puppet/lib/puppet/pops/pcore.rb +0 -11
  98. data/vendored/puppet/lib/puppet/pops/serialization/object.rb +3 -4
  99. data/vendored/puppet/lib/puppet/pops/serialization/to_data_converter.rb +1 -1
  100. data/vendored/puppet/lib/puppet/pops/time/timespan.rb +1 -1
  101. data/vendored/puppet/lib/puppet/pops/types/iterable.rb +14 -7
  102. data/vendored/puppet/lib/puppet/pops/types/p_object_type.rb +38 -7
  103. data/vendored/puppet/lib/puppet/pops/types/p_object_type_extension.rb +21 -22
  104. data/vendored/puppet/lib/puppet/pops/types/p_sem_ver_range_type.rb +0 -1
  105. data/vendored/puppet/lib/puppet/pops/types/p_type_set_type.rb +0 -1
  106. data/vendored/puppet/lib/puppet/pops/types/p_uri_type.rb +0 -1
  107. data/vendored/puppet/lib/puppet/pops/types/puppet_object.rb +1 -1
  108. data/vendored/puppet/lib/puppet/pops/types/string_converter.rb +5 -1
  109. data/vendored/puppet/lib/puppet/pops/types/type_calculator.rb +5 -1
  110. data/vendored/puppet/lib/puppet/pops/types/type_factory.rb +1 -5
  111. data/vendored/puppet/lib/puppet/pops/types/type_formatter.rb +21 -0
  112. data/vendored/puppet/lib/puppet/pops/types/types.rb +2 -7
  113. data/vendored/puppet/lib/puppet/pops/validation/checker4_0.rb +1 -3
  114. data/vendored/puppet/lib/puppet/property.rb +1 -1
  115. data/vendored/puppet/lib/puppet/provider/augeas/augeas.rb +3 -4
  116. data/vendored/puppet/lib/puppet/provider/exec.rb +0 -2
  117. data/vendored/puppet/lib/puppet/provider/nameservice.rb +6 -1
  118. data/vendored/puppet/lib/puppet/provider/nameservice/directoryservice.rb +3 -3
  119. data/vendored/puppet/lib/puppet/provider/package/appdmg.rb +0 -1
  120. data/vendored/puppet/lib/puppet/provider/package/apple.rb +0 -1
  121. data/vendored/puppet/lib/puppet/provider/package/macports.rb +2 -2
  122. data/vendored/puppet/lib/puppet/provider/package/pkgdmg.rb +0 -1
  123. data/vendored/puppet/lib/puppet/provider/package/portage.rb +0 -1
  124. data/vendored/puppet/lib/puppet/provider/package/zypper.rb +2 -2
  125. data/vendored/puppet/lib/puppet/provider/scheduled_task/win32_taskscheduler.rb +2 -2
  126. data/vendored/puppet/lib/puppet/provider/service/init.rb +1 -0
  127. data/vendored/puppet/lib/puppet/provider/service/launchd.rb +3 -3
  128. data/vendored/puppet/lib/puppet/provider/user/aix.rb +1 -1
  129. data/vendored/puppet/lib/puppet/provider/user/openbsd.rb +1 -1
  130. data/vendored/puppet/lib/puppet/provider/user/pw.rb +1 -1
  131. data/vendored/puppet/lib/puppet/provider/yumrepo/inifile.rb +2 -4
  132. data/vendored/puppet/lib/puppet/provider/zfs/zfs.rb +1 -1
  133. data/vendored/puppet/lib/puppet/provider/zpool/zpool.rb +1 -1
  134. data/vendored/puppet/lib/puppet/reference/type.rb +0 -1
  135. data/vendored/puppet/lib/puppet/resource.rb +1 -2
  136. data/vendored/puppet/lib/puppet/resource/status.rb +0 -1
  137. data/vendored/puppet/lib/puppet/resource/type.rb +3 -3
  138. data/vendored/puppet/lib/puppet/resource/type_collection.rb +1 -1
  139. data/vendored/puppet/lib/puppet/settings/environment_conf.rb +0 -1
  140. data/vendored/puppet/lib/puppet/ssl/host.rb +1 -1
  141. data/vendored/puppet/lib/puppet/syntax_checkers/base64.rb +1 -1
  142. data/vendored/puppet/lib/puppet/transaction/persistence.rb +1 -1
  143. data/vendored/puppet/lib/puppet/type.rb +17 -4
  144. data/vendored/puppet/lib/puppet/type/file.rb +3 -3
  145. data/vendored/puppet/lib/puppet/type/mount.rb +9 -0
  146. data/vendored/puppet/lib/puppet/type/schedule.rb +25 -13
  147. data/vendored/puppet/lib/puppet/type/tidy.rb +2 -2
  148. data/vendored/puppet/lib/puppet/type/user.rb +1 -1
  149. data/vendored/puppet/lib/puppet/util.rb +19 -14
  150. data/vendored/puppet/lib/puppet/util/filetype.rb +2 -2
  151. data/vendored/puppet/lib/puppet/util/json_lockfile.rb +1 -1
  152. data/vendored/puppet/lib/puppet/util/log.rb +5 -3
  153. data/vendored/puppet/lib/puppet/util/log/destinations.rb +0 -1
  154. data/vendored/puppet/lib/puppet/util/monkey_patches.rb +1 -1
  155. data/vendored/puppet/lib/puppet/util/network_device/config.rb +2 -2
  156. data/vendored/puppet/lib/puppet/util/plist.rb +6 -4
  157. data/vendored/puppet/lib/puppet/util/rdoc/generators/puppet_generator.rb +1 -1
  158. data/vendored/puppet/lib/puppet/util/rdoc/parser/puppet_parser_rdoc2.rb +1 -1
  159. data/vendored/puppet/lib/puppet/util/storage.rb +2 -2
  160. data/vendored/puppet/lib/puppet/util/windows/registry.rb +2 -2
  161. data/vendored/puppet/lib/puppet/util/windows/sid.rb +0 -2
  162. data/vendored/puppet/lib/puppet/version.rb +1 -1
  163. data/vendored/puppet/lib/puppet_pal.rb +30 -17
  164. metadata +28 -7
  165. data/vendored/puppet/lib/puppet/pops/types/execution_result.rb +0 -137
@@ -37,7 +37,6 @@ class Formatter
37
37
  def scrub(text)
38
38
  # For text with no carriage returns, there's nothing to do.
39
39
  return text if text !~ /\n/
40
- indent = nil
41
40
 
42
41
  # If we can match an indentation, then just remove that same level of
43
42
  # indent from every line.
@@ -170,7 +170,7 @@ class Puppet::Configurer
170
170
  begin
171
171
  report.configuration_version = catalog.version
172
172
 
173
- benchmark(:notice, _("Applied catalog")) do
173
+ benchmark(:notice, _("Applied catalog in %{seconds} seconds")) do
174
174
  catalog.apply(options)
175
175
  end
176
176
  ensure
@@ -4,7 +4,8 @@
4
4
  require 'puppet/configurer'
5
5
 
6
6
  class Puppet::Configurer::PluginHandler
7
- # Retrieve facts from the central server.
7
+ SUPPORTED_LOCALES_MOUNT_AGENT_VERSION = Gem::Version.new("5.3.4")
8
+
8
9
  def download_plugins(environment)
9
10
  source_permissions = Puppet.features.microsoft_windows? ? :ignore : :use
10
11
 
@@ -23,18 +24,23 @@ class Puppet::Configurer::PluginHandler
23
24
  environment,
24
25
  source_permissions
25
26
  )
26
- locales_downloader = Puppet::Configurer::Downloader.new(
27
- "locales",
28
- Puppet[:localedest],
29
- Puppet[:localesource],
30
- Puppet[:localeignore],
31
- environment
32
- )
33
27
 
34
28
  result = []
35
29
  result += plugin_fact_downloader.evaluate
36
30
  result += plugin_downloader.evaluate
37
- result += locales_downloader.evaluate
31
+
32
+ server_agent_version = Puppet.lookup(:server_agent_version) { "0.0" }
33
+ if Gem::Version.new(server_agent_version) >= SUPPORTED_LOCALES_MOUNT_AGENT_VERSION
34
+ locales_downloader = Puppet::Configurer::Downloader.new(
35
+ "locales",
36
+ Puppet[:localedest],
37
+ Puppet[:localesource],
38
+ Puppet[:localeignore],
39
+ environment
40
+ )
41
+ result += locales_downloader.evaluate
42
+ end
43
+
38
44
 
39
45
  Puppet::Util::Autoload.reload_changed
40
46
 
@@ -0,0 +1,213 @@
1
+ # Data types in the Puppet Language can have implementations written in Ruby
2
+ # and distributed in puppet modules. A data type can be declared together with
3
+ # its implementation by creating a file in 'lib/puppet/functions/<modulename>'.
4
+ # The name of the file must be the downcased name of the data type followed by
5
+ # the extension '.rb'.
6
+ #
7
+ # A data type is created by calling {Puppet::DataTypes.create_type(<type name>)}
8
+ # and passing it a block that defines the data type interface and implementation.
9
+ #
10
+ # Data types are namespaced inside the modules that contains them. The name of the
11
+ # data type is prefixed with the name of the module. As with all type names, each
12
+ # segment of the name must start with an uppercase letter.
13
+ #
14
+ # @example A simple data type
15
+ # Puppet::DataTypes.create_type('Auth::User') do
16
+ # interface <<-PUPPET
17
+ # attributes => {
18
+ # name => String,
19
+ # email => String
20
+ # }
21
+ # PUPPET
22
+ # end
23
+ #
24
+ # The above example does not declare an implementation which makes it equivalent
25
+ # to adding the following contents in a file named 'user.pp' under the 'types' directory
26
+ # of the module root.
27
+ #
28
+ # type Auth::User = Object[
29
+ # attributes => {
30
+ # name => String,
31
+ # email => String
32
+ # }]
33
+ #
34
+ # Both declarations are valid and will be found by the module loader.
35
+ #
36
+ # Structure of a data type
37
+ # ---
38
+ #
39
+ # A Data Type consists of an interface and an implementation. Unless a registered implementation
40
+ # is found, the type system will automatically generate one. An automatically generated
41
+ # implementation is all that is needed when the interface fully defines the behaviour (for
42
+ # example in the common case when the data type has no other behaviour than having attributes).
43
+ #
44
+ # When the automatically generated implementation is not sufficient, one must be implemented and
45
+ # registered. The implementation can either be done next to the interface definition by passing
46
+ # a block to `implementation`, or map to an existing implementation class by passing the class
47
+ # as an argument to `implementation_class`. An implementation class does not have to be special
48
+ # in other respects than that it must implemented the type's interface. This makes it possible
49
+ # to use existing Ruby data types as data types in the puppet language.
50
+ #
51
+ # Note that when using `implementation_class` there can only be one such implementation across
52
+ # all environments managed by one puppet server and you must handle and install these
53
+ # implementations as if they are part of the puppet platform. In contrast; the type
54
+ # implementations that are done inside of the type's definition are safe to use in different
55
+ # versions in different environments (given that they do not need additional external logic to
56
+ # be loaded).
57
+ #
58
+ # When using an `implementation_class` it is sometimes desirable to load this class from the
59
+ # 'lib' directory of the module. The method `load_file` is provided to facilitate such a load.
60
+ # The `load_file` will use the `Puppet::Util::Autoload` to search for the given file in the 'lib'
61
+ # directory of the current environment and the 'lib' directory in each included module.
62
+ #
63
+ # @example Adding implementation on top of the generated type using `implementation`
64
+ # Puppet::DataTypes.create_type('Auth::User') do
65
+ # interface <<-PUPPET
66
+ # attributes => {
67
+ # name => String,
68
+ # email => String,
69
+ # year_of_birth => Integer,
70
+ # age => { type => Integer, kind => derived }
71
+ # }
72
+ # PUPPET
73
+ #
74
+ # implementation do
75
+ # def age
76
+ # DateTime.now.year - @year_of_birth
77
+ # end
78
+ # end
79
+ # end
80
+ #
81
+ # @example Appointing an already existing implementation class
82
+ #
83
+ # Assumes the following class is declared under 'lib/puppetx/auth' in the module:
84
+ #
85
+ # class PuppetX::Auth::User
86
+ # attr_reader :name, :year_of_birth
87
+ # def initialize(name, year_of_birth)
88
+ # @name = name
89
+ # @year_of_birth = year_of_birth
90
+ # end
91
+ #
92
+ # def age
93
+ # DateTime.now.year - @year_of_birth
94
+ # end
95
+ #
96
+ # def send_text(sender, text)
97
+ # sender.send_text_from(@name, text)
98
+ # end
99
+ # end
100
+ #
101
+ # Then the type declaration can look like this:
102
+ #
103
+ # Puppet::DataTypes.create_type('Auth::User') do
104
+ # interface <<-PUPPET
105
+ # attributes => {
106
+ # name => String,
107
+ # email => String,
108
+ # year_of_birth => Integer,
109
+ # age => { type => Integer, kind => derived }
110
+ # },
111
+ # functions => {
112
+ # send_text => Callable[Sender, String[1]]
113
+ # }
114
+ # PUPPET
115
+ #
116
+ # # This load_file is optional and only needed in case
117
+ # # the implementation is not loaded by other means.
118
+ # load_file 'puppetx/auth/user'
119
+ #
120
+ # implementation_class PuppetX::Auth::User
121
+ # end
122
+ #
123
+ module Puppet::DataTypes
124
+ def self.create_type(type_name, &block)
125
+ # Ruby < 2.1.0 does not have method on Binding, can only do eval
126
+ # and it will fail unless protected with an if defined? if the local
127
+ # variable does not exist in the block's binder.
128
+ #
129
+ begin
130
+ loader = block.binding.eval('loader_injected_arg if defined?(loader_injected_arg)')
131
+ create_loaded_type(type_name, loader, &block)
132
+ rescue StandardError => e
133
+ raise ArgumentError, _("Data Type Load Error for type '%{type_name}': %{message}") % {type_name: type_name, message: e.message}
134
+ end
135
+
136
+ end
137
+
138
+ def self.create_loaded_type(type_name, loader, &block)
139
+ builder = TypeBuilder.new(type_name.to_s)
140
+ api = TypeBuilderAPI.new(builder).freeze
141
+ api.instance_eval(&block)
142
+ builder.create_type(loader)
143
+ end
144
+
145
+ # @api private
146
+ class TypeBuilder
147
+ attr_accessor :interface, :implementation, :implementation_class
148
+
149
+ def initialize(type_name)
150
+ @type_name = type_name
151
+ @implementation = nil
152
+ @implementation_class = nil
153
+ end
154
+
155
+ def create_type(loader)
156
+ raise ArgumentError, _('a data type must have an interface') unless @interface.is_a?(String)
157
+ created_type = Puppet::Pops::Types::PObjectType.new(
158
+ @type_name,
159
+ Puppet::Pops::Parser::EvaluatingParser.new.parse_string("{ #{@interface} }").body)
160
+
161
+ if !@implementation_class.nil?
162
+ if @implementation_class < Puppet::Pops::Types::PuppetObject
163
+ @implementation_class.instance_eval do
164
+ include Puppet::Pops::Types::PuppetObject
165
+ @_pcore_type = created_type
166
+
167
+ def self._pcore_type
168
+ @_pcore_type
169
+ end
170
+ end
171
+ else
172
+ Puppet::Pops::Loaders.implementation_registry.register_implementation(created_type, @implementation_class, loader)
173
+ end
174
+ created_type.implementation_class = @implementation_class
175
+ elsif !@implementation.nil?
176
+ created_type.implementation_override = @implementation
177
+ end
178
+ created_type
179
+ end
180
+
181
+ def has_implementation?
182
+ !(@implementation_class.nil? && @implementation.nil?)
183
+ end
184
+ end
185
+
186
+ # The TypeBuilderAPI class exposes only those methods that the builder API provides
187
+ # @api public
188
+ class TypeBuilderAPI
189
+ # @api private
190
+ def initialize(type_builder)
191
+ @type_builder = type_builder
192
+ end
193
+
194
+ def interface(type_string)
195
+ raise ArgumentError, _('a data type can only have one interface') unless @type_builder.interface.nil?
196
+ @type_builder.interface = type_string
197
+ end
198
+
199
+ def implementation(&block)
200
+ raise ArgumentError, _('a data type can only have one implementation') if @type_builder.has_implementation?
201
+ @type_builder.implementation = block
202
+ end
203
+
204
+ def implementation_class(ruby_class)
205
+ raise ArgumentError, _('a data type can only have one implementation') if @type_builder.has_implementation?
206
+ @type_builder.implementation_class = ruby_class
207
+ end
208
+
209
+ def load_file(file_name)
210
+ Puppet::Util::Autoload.load_file(file_name, nil)
211
+ end
212
+ end
213
+ end
@@ -0,0 +1,19 @@
1
+ Puppet::DataTypes.create_type('Error') do
2
+ interface <<-PUPPET
3
+ type_parameters => {
4
+ kind => Optional[Variant[String,Regexp,Type[Enum],Type[Pattern],Type[NotUndef],Type[Undef]]],
5
+ issue_code => Optional[Variant[String,Regexp,Type[Enum],Type[Pattern],Type[NotUndef],Type[Undef]]]
6
+ },
7
+ attributes => {
8
+ message => String[1],
9
+ kind => { type => Optional[String[1]], value => undef },
10
+ issue_code => { type => Optional[String[1]], value => undef },
11
+ partial_result => { type => Data, value => undef },
12
+ details => { type => Optional[Hash[String[1],Data]], value => undef },
13
+ }
14
+ PUPPET
15
+
16
+ require 'puppet/datatypes/impl/error'
17
+
18
+ implementation_class Puppet::DataTypes::Error
19
+ end
@@ -0,0 +1,42 @@
1
+ class Puppet::DataTypes::Error
2
+ attr_reader :message, :kind, :issue_code, :partial_result, :details
3
+
4
+ def self.from_asserted_hash(hash)
5
+ new(hash['message'], hash['kind'], hash['issue_code'], hash['partial_result'], hash['details'])
6
+ end
7
+
8
+ def _pcore_init_hash
9
+ result = { 'message' => @message }
10
+ result['kind'] = @kind unless @kind.nil?
11
+ result['issue_code'] = @issue_code unless @issue_code.nil?
12
+ result['partial_result'] = @partial_result unless @partial_result.nil?
13
+ result['details'] = @details unless @details.nil?
14
+ result
15
+ end
16
+
17
+ def initialize(message, kind = nil, issue_code = nil, partial_result = nil, details = nil)
18
+ @message = message
19
+ @kind = kind
20
+ @issue_code = issue_code
21
+ @partial_result = partial_result
22
+ @details = details
23
+ end
24
+
25
+ def eql?(o)
26
+ self.class.equal?(o.class) &&
27
+ @message == o.message &&
28
+ @kind == o.kind &&
29
+ @issue_code == o.issue_code &&
30
+ @partial_result == o.partial_result &&
31
+ @details == o.details
32
+ end
33
+ alias == eql?
34
+
35
+ def hash
36
+ @message.hash ^ @kind.hash ^ @issue_code.hash
37
+ end
38
+
39
+ def to_s
40
+ Puppet::Pops::Types::StringConverter.singleton.convert(self)
41
+ end
42
+ end
@@ -84,7 +84,7 @@ module Puppet
84
84
  if stacktrace.size > 0
85
85
  filename, line = stacktrace[0]
86
86
  else
87
- file = nil
87
+ filename = nil
88
88
  line = nil
89
89
  end
90
90
  self.new(
@@ -71,7 +71,7 @@ Puppet::Indirector::Face.define(:catalog, '0.0.1') do
71
71
  Puppet::Util::Log.newdestination(report)
72
72
 
73
73
  begin
74
- benchmark(:notice, "Finished catalog run") do
74
+ benchmark(:notice, "Finished catalog run in %{seconds} seconds") do
75
75
  catalog.apply(:report => report)
76
76
  end
77
77
  rescue => detail
@@ -63,7 +63,7 @@ Puppet::Face.define(:epp, '0.0.1') do
63
63
  when_invoked do |*args|
64
64
  options = args.pop
65
65
  # pass a dummy node, as facts are not needed for validation
66
- options[:node] = node = Puppet::Node.new("testnode", :facts => Puppet::Node::Facts.new("facts", {}))
66
+ options[:node] = Puppet::Node.new("testnode", :facts => Puppet::Node::Facts.new("facts", {}))
67
67
  compiler = create_compiler(options)
68
68
 
69
69
  status = true # no validation error yet
@@ -145,7 +145,7 @@ Puppet::Face.define(:epp, '0.0.1') do
145
145
  require 'puppet/pops'
146
146
  options = args.pop
147
147
  # pass a dummy node, as facts are not needed for dump
148
- options[:node] = node = Puppet::Node.new("testnode", :facts => Puppet::Node::Facts.new("facts", {}))
148
+ options[:node] = Puppet::Node.new("testnode", :facts => Puppet::Node::Facts.new("facts", {}))
149
149
  options[:header] = options[:header].nil? ? true : options[:header]
150
150
  options[:validate] = options[:validate].nil? ? true : options[:validate]
151
151
 
@@ -176,7 +176,7 @@ Puppet::Face.define(:epp, '0.0.1') do
176
176
  end
177
177
 
178
178
  show_filename = templates.count > 1
179
- dumps = templates.each do |file|
179
+ templates.each do |file|
180
180
  buffer.print dump_parse(Puppet::FileSystem.read(file, :encoding => 'utf-8'), file, options, show_filename)
181
181
  end
182
182
 
@@ -78,26 +78,24 @@ Puppet::Face.define(:help, '0.0.1') do
78
78
  def render_application_help(applicationname)
79
79
  return Puppet::Application[applicationname].help
80
80
  rescue StandardError, LoadError => detail
81
- msg = _(<<-MSG) % { applicationname: applicationname, detail: detail.message }
82
- Could not load help for the application %{applicationname}.
83
- Please check the error logs for more information.
84
-
85
- Detail: "%{detail}"
86
- MSG
87
- fail ArgumentError, msg, detail.backtrace
81
+ message = []
82
+ message << _('Could not load help for the application %{application_name}.') % { application_name: applicationname }
83
+ message << _('Please check the error logs for more information.')
84
+ message << ''
85
+ message << _('Detail: "%{detail}"') % { detail: detail.message }
86
+ fail ArgumentError, message.join("\n"), detail.backtrace
88
87
  end
89
88
 
90
89
  def render_face_help(facename, actionname, version)
91
90
  face, action = load_face_help(facename, actionname, version)
92
91
  return template_for(face, action).result(binding)
93
92
  rescue StandardError, LoadError => detail
94
- msg = _(<<-MSG) % { facename: facename, detail: detail.message }
95
- Could not load help for the face %{facename}.
96
- Please check the error logs for more information.
97
-
98
- Detail: "%{detail}"
99
- MSG
100
- fail ArgumentError, msg, detail.backtrace
93
+ message = []
94
+ message << _('Could not load help for the face %{face_name}.') % { face_name: facename }
95
+ message << _('Please check the error logs for more information.')
96
+ message << ''
97
+ message << _('Detail: "%{detail}"') % { detail: detail.message }
98
+ fail ArgumentError, message.join("\n"), detail.backtrace
101
99
  end
102
100
 
103
101
  def load_face_help(facename, actionname, version)
@@ -25,6 +25,7 @@ Puppet::Face.define(:man, '0.0.1') do
25
25
  action(:man) do
26
26
  summary _("Display the manual page for a Puppet subcommand.")
27
27
  arguments _("<subcommand>")
28
+ #TRANSLATORS '--render-as s' is a command line option and should not be translated
28
29
  returns _(<<-'EOT')
29
30
  The man data, in Markdown format, suitable for consumption by Ronn.
30
31
 
@@ -44,7 +44,7 @@ Puppet::Face.define(:module, '1.0.0') do
44
44
  min_widths = Hash[ *headers.map { |k,v| [k, v.length] }.flatten ]
45
45
  min_widths['full_name'] = min_widths['author'] = 12
46
46
 
47
- min_width = min_widths.inject(0) { |sum,pair| sum += pair.last } + (padding.length * (headers.length - 1))
47
+ min_width = min_widths.inject(0) { |sum,pair| sum + pair.last } + (padding.length * (headers.length - 1))
48
48
 
49
49
  terminal_width = [Puppet::Util::Terminal.width, min_width].max
50
50
 
@@ -17,6 +17,7 @@ Puppet::Indirector::Face.define(:node, '0.0.1') do
17
17
  find = get_action(:find)
18
18
  find.summary _("Retrieve a node object.")
19
19
  find.arguments _("<host>")
20
+ #TRANSLATORS the following are specific names and should not be translated `classes`, `environment`, `expiration`, `name`, `parameters`, Puppet::Node
20
21
  find.returns _(<<-'EOT')
21
22
  A hash containing the node's `classes`, `environment`, `expiration`, `name`,
22
23
  `parameters` (its facts, combined with any ENC-set parameters), and `time`.