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.
- checksums.yaml +4 -4
- data/lib/bolt/cli.rb +127 -31
- data/lib/bolt/config.rb +39 -6
- data/lib/bolt/execution_result.rb +109 -0
- data/lib/bolt/executor.rb +4 -1
- data/lib/bolt/node.rb +6 -1
- data/lib/bolt/node/orch.rb +20 -2
- data/lib/bolt/node/winrm.rb +22 -10
- data/lib/bolt/node_uri.rb +5 -7
- data/lib/bolt/outputter/human.rb +60 -1
- data/lib/bolt/outputter/json.rb +11 -0
- data/lib/bolt/target.rb +32 -0
- data/lib/bolt/version.rb +1 -1
- data/modules/boltlib/lib/puppet/datatypes/executionresult.rb +30 -0
- data/modules/boltlib/lib/puppet/datatypes/target.rb +12 -0
- data/modules/boltlib/lib/puppet/functions/file_upload.rb +3 -3
- data/modules/boltlib/lib/puppet/functions/run_command.rb +3 -3
- data/modules/boltlib/lib/puppet/functions/run_script.rb +3 -3
- data/modules/boltlib/lib/puppet/functions/run_task.rb +10 -2
- data/vendored/puppet/lib/puppet/application/describe.rb +0 -1
- data/vendored/puppet/lib/puppet/configurer.rb +1 -1
- data/vendored/puppet/lib/puppet/configurer/plugin_handler.rb +15 -9
- data/vendored/puppet/lib/puppet/datatypes.rb +213 -0
- data/vendored/puppet/lib/puppet/datatypes/error.rb +19 -0
- data/vendored/puppet/lib/puppet/datatypes/impl/error.rb +42 -0
- data/vendored/puppet/lib/puppet/error.rb +1 -1
- data/vendored/puppet/lib/puppet/face/catalog.rb +1 -1
- data/vendored/puppet/lib/puppet/face/epp.rb +3 -3
- data/vendored/puppet/lib/puppet/face/help.rb +12 -14
- data/vendored/puppet/lib/puppet/face/man.rb +1 -0
- data/vendored/puppet/lib/puppet/face/module/search.rb +1 -1
- data/vendored/puppet/lib/puppet/face/node.rb +1 -0
- data/vendored/puppet/lib/puppet/face/parser.rb +0 -1
- data/vendored/puppet/lib/puppet/face/status.rb +1 -0
- data/vendored/puppet/lib/puppet/feature/base.rb +1 -1
- data/vendored/puppet/lib/puppet/file_bucket/dipper.rb +0 -1
- data/vendored/puppet/lib/puppet/file_system/uniquefile.rb +2 -2
- data/vendored/puppet/lib/puppet/forge/errors.rb +21 -29
- data/vendored/puppet/lib/puppet/functions.rb +64 -84
- data/vendored/puppet/lib/puppet/functions/defined.rb +0 -3
- data/vendored/puppet/lib/puppet/functions/find_file.rb +0 -1
- data/vendored/puppet/lib/puppet/functions/map.rb +0 -1
- data/vendored/puppet/lib/puppet/functions/regsubst.rb +1 -1
- data/vendored/puppet/lib/puppet/graph/simple_graph.rb +6 -10
- data/vendored/puppet/lib/puppet/indirector/catalog/compiler.rb +37 -25
- data/vendored/puppet/lib/puppet/indirector/file_server.rb +1 -1
- data/vendored/puppet/lib/puppet/indirector/indirection.rb +0 -2
- data/vendored/puppet/lib/puppet/indirector/rest.rb +9 -8
- data/vendored/puppet/lib/puppet/info_service/class_information_service.rb +1 -1
- data/vendored/puppet/lib/puppet/interface/option_manager.rb +1 -1
- data/vendored/puppet/lib/puppet/loaders.rb +1 -0
- data/vendored/puppet/lib/puppet/module.rb +6 -2
- data/vendored/puppet/lib/puppet/module_tool/applications/unpacker.rb +1 -1
- data/vendored/puppet/lib/puppet/module_tool/errors/installer.rb +29 -41
- data/vendored/puppet/lib/puppet/module_tool/errors/shared.rb +63 -138
- data/vendored/puppet/lib/puppet/module_tool/errors/uninstaller.rb +15 -37
- data/vendored/puppet/lib/puppet/module_tool/errors/upgrader.rb +18 -30
- data/vendored/puppet/lib/puppet/module_tool/installed_modules.rb +1 -1
- data/vendored/puppet/lib/puppet/module_tool/metadata.rb +0 -1
- data/vendored/puppet/lib/puppet/network/http/api/indirected_routes.rb +1 -1
- data/vendored/puppet/lib/puppet/network/rights.rb +1 -1
- data/vendored/puppet/lib/puppet/node.rb +1 -1
- data/vendored/puppet/lib/puppet/node/environment.rb +1 -1
- data/vendored/puppet/lib/puppet/parameter/value_collection.rb +4 -17
- data/vendored/puppet/lib/puppet/parser/compiler.rb +1 -0
- data/vendored/puppet/lib/puppet/parser/functions.rb +0 -1
- data/vendored/puppet/lib/puppet/parser/functions/scanf.rb +1 -1
- data/vendored/puppet/lib/puppet/parser/scope.rb +4 -3
- data/vendored/puppet/lib/puppet/parser/script_compiler.rb +1 -0
- data/vendored/puppet/lib/puppet/parser/templatewrapper.rb +3 -2
- data/vendored/puppet/lib/puppet/parser/type_loader.rb +1 -1
- data/vendored/puppet/lib/puppet/pops.rb +1 -0
- data/vendored/puppet/lib/puppet/pops/evaluator/access_operator.rb +3 -2
- data/vendored/puppet/lib/puppet/pops/evaluator/closure.rb +1 -1
- data/vendored/puppet/lib/puppet/pops/evaluator/evaluator_impl.rb +2 -2
- data/vendored/puppet/lib/puppet/pops/functions/dispatch.rb +6 -5
- data/vendored/puppet/lib/puppet/pops/functions/function.rb +2 -2
- data/vendored/puppet/lib/puppet/pops/loader/loader.rb +1 -1
- data/vendored/puppet/lib/puppet/pops/loader/loader_paths.rb +40 -4
- data/vendored/puppet/lib/puppet/pops/loader/module_loaders.rb +6 -2
- data/vendored/puppet/lib/puppet/pops/loader/puppet_resource_type_impl_instantiator.rb +8 -8
- data/vendored/puppet/lib/puppet/pops/loader/ruby_data_type_instantiator.rb +40 -0
- data/vendored/puppet/lib/puppet/pops/loader/static_loader.rb +6 -26
- data/vendored/puppet/lib/puppet/pops/loaders.rb +11 -2
- data/vendored/puppet/lib/puppet/pops/lookup/data_dig_function_provider.rb +1 -1
- data/vendored/puppet/lib/puppet/pops/lookup/lookup_adapter.rb +4 -14
- data/vendored/puppet/lib/puppet/pops/model/model_tree_dumper.rb +1 -1
- data/vendored/puppet/lib/puppet/pops/parser/code_merger.rb +2 -2
- data/vendored/puppet/lib/puppet/pops/parser/eparser.rb +1471 -1501
- data/vendored/puppet/lib/puppet/pops/parser/epp_support.rb +0 -2
- data/vendored/puppet/lib/puppet/pops/parser/evaluating_parser.rb +1 -1
- data/vendored/puppet/lib/puppet/pops/parser/interpolation_support.rb +1 -1
- data/vendored/puppet/lib/puppet/pops/parser/lexer2.rb +2 -26
- data/vendored/puppet/lib/puppet/pops/parser/locator.rb +5 -7
- data/vendored/puppet/lib/puppet/pops/parser/parser_support.rb +2 -2
- data/vendored/puppet/lib/puppet/pops/parser/slurp_support.rb +0 -3
- data/vendored/puppet/lib/puppet/pops/pcore.rb +0 -11
- data/vendored/puppet/lib/puppet/pops/serialization/object.rb +3 -4
- data/vendored/puppet/lib/puppet/pops/serialization/to_data_converter.rb +1 -1
- data/vendored/puppet/lib/puppet/pops/time/timespan.rb +1 -1
- data/vendored/puppet/lib/puppet/pops/types/iterable.rb +14 -7
- data/vendored/puppet/lib/puppet/pops/types/p_object_type.rb +38 -7
- data/vendored/puppet/lib/puppet/pops/types/p_object_type_extension.rb +21 -22
- data/vendored/puppet/lib/puppet/pops/types/p_sem_ver_range_type.rb +0 -1
- data/vendored/puppet/lib/puppet/pops/types/p_type_set_type.rb +0 -1
- data/vendored/puppet/lib/puppet/pops/types/p_uri_type.rb +0 -1
- data/vendored/puppet/lib/puppet/pops/types/puppet_object.rb +1 -1
- data/vendored/puppet/lib/puppet/pops/types/string_converter.rb +5 -1
- data/vendored/puppet/lib/puppet/pops/types/type_calculator.rb +5 -1
- data/vendored/puppet/lib/puppet/pops/types/type_factory.rb +1 -5
- data/vendored/puppet/lib/puppet/pops/types/type_formatter.rb +21 -0
- data/vendored/puppet/lib/puppet/pops/types/types.rb +2 -7
- data/vendored/puppet/lib/puppet/pops/validation/checker4_0.rb +1 -3
- data/vendored/puppet/lib/puppet/property.rb +1 -1
- data/vendored/puppet/lib/puppet/provider/augeas/augeas.rb +3 -4
- data/vendored/puppet/lib/puppet/provider/exec.rb +0 -2
- data/vendored/puppet/lib/puppet/provider/nameservice.rb +6 -1
- data/vendored/puppet/lib/puppet/provider/nameservice/directoryservice.rb +3 -3
- data/vendored/puppet/lib/puppet/provider/package/appdmg.rb +0 -1
- data/vendored/puppet/lib/puppet/provider/package/apple.rb +0 -1
- data/vendored/puppet/lib/puppet/provider/package/macports.rb +2 -2
- data/vendored/puppet/lib/puppet/provider/package/pkgdmg.rb +0 -1
- data/vendored/puppet/lib/puppet/provider/package/portage.rb +0 -1
- data/vendored/puppet/lib/puppet/provider/package/zypper.rb +2 -2
- data/vendored/puppet/lib/puppet/provider/scheduled_task/win32_taskscheduler.rb +2 -2
- data/vendored/puppet/lib/puppet/provider/service/init.rb +1 -0
- data/vendored/puppet/lib/puppet/provider/service/launchd.rb +3 -3
- data/vendored/puppet/lib/puppet/provider/user/aix.rb +1 -1
- data/vendored/puppet/lib/puppet/provider/user/openbsd.rb +1 -1
- data/vendored/puppet/lib/puppet/provider/user/pw.rb +1 -1
- data/vendored/puppet/lib/puppet/provider/yumrepo/inifile.rb +2 -4
- data/vendored/puppet/lib/puppet/provider/zfs/zfs.rb +1 -1
- data/vendored/puppet/lib/puppet/provider/zpool/zpool.rb +1 -1
- data/vendored/puppet/lib/puppet/reference/type.rb +0 -1
- data/vendored/puppet/lib/puppet/resource.rb +1 -2
- data/vendored/puppet/lib/puppet/resource/status.rb +0 -1
- data/vendored/puppet/lib/puppet/resource/type.rb +3 -3
- data/vendored/puppet/lib/puppet/resource/type_collection.rb +1 -1
- data/vendored/puppet/lib/puppet/settings/environment_conf.rb +0 -1
- data/vendored/puppet/lib/puppet/ssl/host.rb +1 -1
- data/vendored/puppet/lib/puppet/syntax_checkers/base64.rb +1 -1
- data/vendored/puppet/lib/puppet/transaction/persistence.rb +1 -1
- data/vendored/puppet/lib/puppet/type.rb +17 -4
- data/vendored/puppet/lib/puppet/type/file.rb +3 -3
- data/vendored/puppet/lib/puppet/type/mount.rb +9 -0
- data/vendored/puppet/lib/puppet/type/schedule.rb +25 -13
- data/vendored/puppet/lib/puppet/type/tidy.rb +2 -2
- data/vendored/puppet/lib/puppet/type/user.rb +1 -1
- data/vendored/puppet/lib/puppet/util.rb +19 -14
- data/vendored/puppet/lib/puppet/util/filetype.rb +2 -2
- data/vendored/puppet/lib/puppet/util/json_lockfile.rb +1 -1
- data/vendored/puppet/lib/puppet/util/log.rb +5 -3
- data/vendored/puppet/lib/puppet/util/log/destinations.rb +0 -1
- data/vendored/puppet/lib/puppet/util/monkey_patches.rb +1 -1
- data/vendored/puppet/lib/puppet/util/network_device/config.rb +2 -2
- data/vendored/puppet/lib/puppet/util/plist.rb +6 -4
- data/vendored/puppet/lib/puppet/util/rdoc/generators/puppet_generator.rb +1 -1
- data/vendored/puppet/lib/puppet/util/rdoc/parser/puppet_parser_rdoc2.rb +1 -1
- data/vendored/puppet/lib/puppet/util/storage.rb +2 -2
- data/vendored/puppet/lib/puppet/util/windows/registry.rb +2 -2
- data/vendored/puppet/lib/puppet/util/windows/sid.rb +0 -2
- data/vendored/puppet/lib/puppet/version.rb +1 -1
- data/vendored/puppet/lib/puppet_pal.rb +30 -17
- metadata +28 -7
- data/vendored/puppet/lib/puppet/pops/types/execution_result.rb +0 -137
@@ -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
|
-
|
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
|
-
|
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
|
@@ -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] =
|
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] =
|
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
|
-
|
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
|
-
|
82
|
-
Could not load help for the application %{applicationname}
|
83
|
-
Please check the error logs for more information.
|
84
|
-
|
85
|
-
Detail: "%{detail}"
|
86
|
-
|
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
|
-
|
95
|
-
Could not load help for the face %{facename}
|
96
|
-
Please check the error logs for more information.
|
97
|
-
|
98
|
-
Detail: "%{detail}"
|
99
|
-
|
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
|
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`.
|