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
@@ -13,6 +13,7 @@ Puppet::Indirector::Face.define(:status, '0.0.1') do
|
|
13
13
|
find = get_action(:find)
|
14
14
|
find.default = true
|
15
15
|
find.summary _("Check status of puppet master server.")
|
16
|
+
#TRANSLATORS the string 'Puppet::Status' is a Puppet language object and should not be translated
|
16
17
|
find.returns _(<<-'EOT')
|
17
18
|
A "true" response or a low-level connection error. When used from the Ruby
|
18
19
|
API: returns a Puppet::Status object.
|
@@ -144,7 +144,7 @@ class Puppet::FileSystem::Uniquefile < DelegateClass(File)
|
|
144
144
|
def try_convert_to_hash(h)
|
145
145
|
begin
|
146
146
|
h.to_hash
|
147
|
-
rescue NoMethodError
|
147
|
+
rescue NoMethodError
|
148
148
|
nil
|
149
149
|
end
|
150
150
|
end
|
@@ -154,7 +154,7 @@ class Puppet::FileSystem::Uniquefile < DelegateClass(File)
|
|
154
154
|
def tmpdir
|
155
155
|
tmp = '.'
|
156
156
|
if $SAFE > 0
|
157
|
-
|
157
|
+
@@systmpdir
|
158
158
|
else
|
159
159
|
for dir in [ Puppet::Util.get_env('TMPDIR'), Puppet::Util.get_env('TMP'), Puppet::Util.get_env('TEMP'), @@systmpdir, '/tmp']
|
160
160
|
if dir and stat = File.stat(dir) and stat.directory? and stat.writable?
|
@@ -32,12 +32,12 @@ module Puppet::Forge::Errors
|
|
32
32
|
#
|
33
33
|
# @return [String] the multiline version of the error message
|
34
34
|
def multiline
|
35
|
-
|
36
|
-
Could not connect via HTTPS to %{uri}
|
37
|
-
Unable to verify the SSL certificate
|
38
|
-
The certificate may not be signed by a valid CA
|
39
|
-
The CA bundle included with OpenSSL may not be valid or up to date
|
40
|
-
|
35
|
+
message = []
|
36
|
+
message << _('Could not connect via HTTPS to %{uri}') % { uri: @uri }
|
37
|
+
message << _(' Unable to verify the SSL certificate')
|
38
|
+
message << _(' The certificate may not be signed by a valid CA')
|
39
|
+
message << _(' The CA bundle included with OpenSSL may not be valid or up to date')
|
40
|
+
message.join("\n")
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
@@ -59,12 +59,12 @@ Could not connect via HTTPS to %{uri}
|
|
59
59
|
#
|
60
60
|
# @return [String] the multiline version of the error message
|
61
61
|
def multiline
|
62
|
-
|
63
|
-
Could not connect to %{uri}
|
64
|
-
There was a network communications problem
|
65
|
-
The error we caught said '%{detail}'
|
66
|
-
Check your network connection and try again
|
67
|
-
|
62
|
+
message = []
|
63
|
+
message << _('Could not connect to %{uri}') % { uri: @uri }
|
64
|
+
message << _(' There was a network communications problem')
|
65
|
+
message << _(" The error we caught said '%{detail}'") % { detail: @detail }
|
66
|
+
message << _(' Check your network connection and try again')
|
67
|
+
message.join("\n")
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
@@ -90,10 +90,9 @@ Could not connect to %{uri}
|
|
90
90
|
end
|
91
91
|
|
92
92
|
message = if @message
|
93
|
-
_("Request to Puppet Forge failed. Detail: %{
|
94
|
-
{ error_message: @message, http_response: @response }
|
93
|
+
_("Request to Puppet Forge failed.") + ' ' + _("Detail: %{detail}.") % { detail: "#{@message} / #{@response}" }
|
95
94
|
else
|
96
|
-
_("Request to Puppet Forge failed. Detail: %{
|
95
|
+
_("Request to Puppet Forge failed.") + ' ' + _("Detail: %{detail}.") % { detail: @response }
|
97
96
|
end
|
98
97
|
super(message, original)
|
99
98
|
end
|
@@ -102,20 +101,13 @@ Could not connect to %{uri}
|
|
102
101
|
#
|
103
102
|
# @return [String] the multiline version of the error message
|
104
103
|
def multiline
|
105
|
-
|
106
|
-
|
107
|
-
Request to Puppet Forge failed.
|
108
|
-
The server being queried was %{uri}
|
109
|
-
The HTTP response we received was '%{response}'
|
110
|
-
The message we received said '%{message}'
|
111
|
-
|
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
|
104
|
+
|
105
|
+
message = []
|
106
|
+
message << _('Request to Puppet Forge failed.')
|
107
|
+
message << _(' The server being queried was %{uri}') % { uri: @uri }
|
108
|
+
message << _(" The HTTP response we received was '%{response}'") % { response: @response }
|
109
|
+
message << _(" The message we received said '%{message}'") % { message: @message } if @message
|
110
|
+
message.join("\n")
|
119
111
|
end
|
120
112
|
end
|
121
113
|
|
@@ -186,8 +186,12 @@ module Puppet::Functions
|
|
186
186
|
# and it will fail unless protected with an if defined? if the local
|
187
187
|
# variable does not exist in the block's binder.
|
188
188
|
#
|
189
|
-
|
190
|
-
|
189
|
+
begin
|
190
|
+
loader = block.binding.eval('loader_injected_arg if defined?(loader_injected_arg)')
|
191
|
+
create_loaded_function(func_name, loader, function_base, &block)
|
192
|
+
rescue StandardError => e
|
193
|
+
raise ArgumentError, _("Function Load Error for function '%{function_name}': %{message}") % {function_name: func_name, message: e.message}
|
194
|
+
end
|
191
195
|
end
|
192
196
|
|
193
197
|
# Creates a function in, or in a local loader under the given loader.
|
@@ -573,14 +577,27 @@ module Puppet::Functions
|
|
573
577
|
# @api private
|
574
578
|
def create_callable(types, block_type, return_type, from, to)
|
575
579
|
mapped_types = types.map do |t|
|
576
|
-
t.is_a?(Puppet::Pops::Types::PAnyType) ? t :
|
580
|
+
t.is_a?(Puppet::Pops::Types::PAnyType) ? t : internal_type_parse(t, loader)
|
577
581
|
end
|
578
582
|
param_types = Puppet::Pops::Types::PTupleType.new(mapped_types, from > 0 && from == to ? nil : Puppet::Pops::Types::PIntegerType.new(from, to))
|
579
|
-
return_type =
|
583
|
+
return_type = internal_type_parse(return_type, loader) unless return_type.nil? || return_type.is_a?(Puppet::Pops::Types::PAnyType)
|
580
584
|
Puppet::Pops::Types::PCallableType.new(param_types, block_type, return_type)
|
581
585
|
end
|
586
|
+
|
587
|
+
def internal_type_parse(type_string, loader)
|
588
|
+
begin
|
589
|
+
Puppet::Pops::Types::TypeParser.singleton.parse(type_string, loader)
|
590
|
+
rescue StandardError => e
|
591
|
+
raise ArgumentError, _("Parsing of type string '\"%{type_string}\"' failed with message: <%{message}>.\n") % {
|
592
|
+
type_string: type_string,
|
593
|
+
message: e.message
|
594
|
+
}
|
595
|
+
end
|
596
|
+
end
|
597
|
+
private :internal_type_parse
|
582
598
|
end
|
583
599
|
|
600
|
+
|
584
601
|
# The LocalTypeAliasBuilder is used by the 'local_types' method to collect the individual
|
585
602
|
# type aliases given by the function's author.
|
586
603
|
#
|
@@ -603,9 +620,31 @@ module Puppet::Functions
|
|
603
620
|
# @api public
|
604
621
|
#
|
605
622
|
def type(assignment_string)
|
606
|
-
|
623
|
+
# Get location to use in case of error - this produces ruby filename and where call to 'type' occurred
|
624
|
+
# but strips off the rest of the internal "where" as it is not meaningful to user.
|
625
|
+
#
|
626
|
+
rb_location = caller[0]
|
627
|
+
|
628
|
+
begin
|
629
|
+
result = parser.parse_string("type #{assignment_string}", nil)
|
630
|
+
rescue StandardError => e
|
631
|
+
rb_location = rb_location.gsub(/:in.*$/, '')
|
632
|
+
# Create a meaningful location for parse errors - show both what went wrong with the parsing
|
633
|
+
# and in which ruby file it was found.
|
634
|
+
raise ArgumentError, _("Parsing of 'type \"%{assignment_string}\"' failed with message: <%{message}>.\n" +
|
635
|
+
"Called from <%{ruby_file_location}>") % {
|
636
|
+
assignment_string: assignment_string,
|
637
|
+
message: e.message,
|
638
|
+
ruby_file_location: rb_location
|
639
|
+
}
|
640
|
+
end
|
607
641
|
unless result.body.kind_of?(Puppet::Pops::Model::TypeAlias)
|
608
|
-
|
642
|
+
rb_location = rb_location.gsub(/:in.*$/, '')
|
643
|
+
raise ArgumentError, _("Expected a type alias assignment on the form 'AliasType = T', got '%{assignment_string}'.\n"+
|
644
|
+
"Called from <%{ruby_file_location}>") % {
|
645
|
+
assignment_string: assignment_string,
|
646
|
+
ruby_file_location: rb_location
|
647
|
+
}
|
609
648
|
end
|
610
649
|
@local_types << result.body
|
611
650
|
end
|
@@ -618,30 +657,7 @@ module Puppet::Functions
|
|
618
657
|
#
|
619
658
|
# This is a private, internal, system for creating functions. It supports
|
620
659
|
# everything that the public function definition system supports as well as a
|
621
|
-
# few extra features.
|
622
|
-
#
|
623
|
-
# Injection Support
|
624
|
-
# ===
|
625
|
-
# The Function API supports injection of data and services. It is possible to
|
626
|
-
# make injection that takes effect when the function is loaded (for services
|
627
|
-
# and runtime configuration that does not change depending on how/from where
|
628
|
-
# in what context the function is called. It is also possible to inject and
|
629
|
-
# weave argument values into a call.
|
630
|
-
#
|
631
|
-
# Injection of attributes
|
632
|
-
# ---
|
633
|
-
# Injection of attributes is performed by one of the methods `attr_injected`,
|
634
|
-
# and `attr_injected_producer`. The injected attributes are available via
|
635
|
-
# accessor method calls.
|
636
|
-
#
|
637
|
-
# @example using injected attributes
|
638
|
-
# Puppet::Functions.create_function('test') do
|
639
|
-
# attr_injected String, :larger, 'message_larger'
|
640
|
-
# attr_injected String, :smaller, 'message_smaller'
|
641
|
-
# def test(a, b)
|
642
|
-
# a > b ? larger() : smaller()
|
643
|
-
# end
|
644
|
-
# end
|
660
|
+
# few extra features such as injection of well known parameters.
|
645
661
|
#
|
646
662
|
# @api private
|
647
663
|
class InternalFunction < Function
|
@@ -665,26 +681,22 @@ module Puppet::Functions
|
|
665
681
|
end
|
666
682
|
end
|
667
683
|
|
668
|
-
# @note WARNING: This style of creating functions is not public. It is a system
|
669
|
-
# under development that will be used for creating "system" functions.
|
670
|
-
#
|
671
684
|
# Injection and Weaving of parameters
|
672
685
|
# ---
|
673
|
-
# It is possible to inject and weave parameters into a call.
|
674
|
-
# parameters are not part of the parameters passed from the Puppet
|
675
|
-
# they can not be overridden by parameters given as arguments in the
|
676
|
-
# They are invisible to the Puppet Language.
|
686
|
+
# It is possible to inject and weave a set of well known parameters into a call.
|
687
|
+
# These extra parameters are not part of the parameters passed from the Puppet
|
688
|
+
# logic, and they can not be overridden by parameters given as arguments in the
|
689
|
+
# call. They are invisible to the Puppet Language.
|
677
690
|
#
|
678
691
|
# @example using injected parameters
|
679
692
|
# Puppet::Functions.create_function('test') do
|
680
693
|
# dispatch :test do
|
681
694
|
# param 'Scalar', 'a'
|
682
695
|
# param 'Scalar', 'b'
|
683
|
-
#
|
684
|
-
# injected_param 'String', 'smaller', 'message_smaller'
|
696
|
+
# scope_param
|
685
697
|
# end
|
686
|
-
# def test(a, b,
|
687
|
-
# a > b ?
|
698
|
+
# def test(a, b, scope)
|
699
|
+
# a > b ? scope['a'] : scope['b']
|
688
700
|
# end
|
689
701
|
# end
|
690
702
|
#
|
@@ -692,54 +704,22 @@ module Puppet::Functions
|
|
692
704
|
#
|
693
705
|
# test(10, 20)
|
694
706
|
#
|
695
|
-
# Using injected value as default
|
696
|
-
# ---
|
697
|
-
# Default value assignment is handled by using the regular Ruby mechanism (a
|
698
|
-
# value is assigned to the variable). The dispatch simply indicates that the
|
699
|
-
# value is optional. If the default value should be injected, it can be
|
700
|
-
# handled different ways depending on what is desired:
|
701
|
-
#
|
702
|
-
# * by calling the accessor method for an injected Function class attribute.
|
703
|
-
# This is suitable if the value is constant across all instantiations of the
|
704
|
-
# function, and across all calls.
|
705
|
-
# * by injecting a parameter into the call
|
706
|
-
# to the left of the parameter, and then assigning that as the default value.
|
707
|
-
# * One of the above forms, but using an injected producer instead of a
|
708
|
-
# directly injected value.
|
709
|
-
#
|
710
|
-
# @example method with injected default values
|
711
|
-
# Puppet::Functions.create_function('test') do
|
712
|
-
# dispatch :test do
|
713
|
-
# injected_param String, 'b_default', 'b_default_value_key'
|
714
|
-
# param 'Scalar', 'a'
|
715
|
-
# param 'Scalar', 'b'
|
716
|
-
# end
|
717
|
-
# def test(b_default, a, b = b_default)
|
718
|
-
# # ...
|
719
|
-
# end
|
720
|
-
# end
|
721
|
-
#
|
722
707
|
# @api private
|
723
708
|
class InternalDispatchBuilder < DispatcherBuilder
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
@weaving << [@injections.size()-1]
|
709
|
+
# Inject parameter for `Puppet::Parser::Scope`
|
710
|
+
def scope_param
|
711
|
+
inject(:scope)
|
728
712
|
end
|
729
|
-
|
730
|
-
#
|
731
|
-
|
732
|
-
|
733
|
-
@injections << [type, name, injection_name]
|
734
|
-
# mark what should be picked for this position when dispatching
|
735
|
-
@weaving << [@injections.size() -1]
|
713
|
+
|
714
|
+
# Inject parameter for `Puppet::Pal::ScriptCompiler`
|
715
|
+
def script_compiler_param
|
716
|
+
inject(:pal_script_compiler)
|
736
717
|
end
|
737
718
|
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
@injections << [type, name, injection_name, :producer]
|
719
|
+
private
|
720
|
+
|
721
|
+
def inject(injection_name)
|
722
|
+
@injections << injection_name
|
743
723
|
# mark what should be picked for this position when dispatching
|
744
724
|
@weaving << [@injections.size()-1]
|
745
725
|
end
|
@@ -105,7 +105,6 @@ Puppet::Functions.create_function(:'defined', Puppet::Functions::InternalFunctio
|
|
105
105
|
end
|
106
106
|
|
107
107
|
def is_defined(scope, *vals)
|
108
|
-
env = scope.environment
|
109
108
|
vals.any? do |val|
|
110
109
|
case val
|
111
110
|
when String
|
@@ -120,7 +119,6 @@ Puppet::Functions.create_function(:'defined', Puppet::Functions::InternalFunctio
|
|
120
119
|
Puppet::Pops::Evaluator::Runtime3ResourceSupport.find_main_class(scope)
|
121
120
|
else
|
122
121
|
# Find a resource type, definition or class definition
|
123
|
-
krt = scope.environment.known_resource_types
|
124
122
|
Puppet::Pops::Evaluator::Runtime3ResourceSupport.find_resource_type_or_class(scope, val)
|
125
123
|
end
|
126
124
|
end
|
@@ -150,7 +148,6 @@ Puppet::Functions.create_function(:'defined', Puppet::Functions::InternalFunctio
|
|
150
148
|
#
|
151
149
|
raise ArgumentError, _('The given class type is a reference to all classes') if val.type.class_name.nil?
|
152
150
|
Puppet::Pops::Evaluator::Runtime3ResourceSupport.find_hostclass(scope, val.type.class_name)
|
153
|
-
#scope.environment.known_resource_types.find_hostclass(val.type.class_name)
|
154
151
|
end
|
155
152
|
else
|
156
153
|
raise ArgumentError, _("Invalid argument of type '%{value_class}' to 'defined'") % { value_class: val.class }
|
@@ -19,7 +19,6 @@ Puppet::Functions.create_function(:find_file, Puppet::Functions::InternalFunctio
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def find_file(scope, *args)
|
22
|
-
path = nil
|
23
22
|
args.each do |file|
|
24
23
|
found = Puppet::Parser::Files.find_file(file, scope.compiler.environment)
|
25
24
|
if found && Puppet::FileSystem.exist?(found)
|
@@ -66,7 +66,7 @@ Puppet::Functions.create_function(:regsubst) do
|
|
66
66
|
|
67
67
|
def regsubst_regexp(target, pattern, replacement, flags = nil)
|
68
68
|
pattern = (pattern.pattern || '') if pattern.is_a?(Puppet::Pops::Types::PRegexpType)
|
69
|
-
inner_regsubst(target, pattern, replacement,
|
69
|
+
inner_regsubst(target, pattern, replacement, flags == 'G' ? :gsub : :sub)
|
70
70
|
end
|
71
71
|
|
72
72
|
def inner_regsubst(target, re, replacement, op)
|
@@ -228,23 +228,19 @@ class Puppet::Graph::SimpleGraph
|
|
228
228
|
number_of_cycles = cycles.length
|
229
229
|
return if number_of_cycles == 0
|
230
230
|
|
231
|
-
|
231
|
+
message = n_("Found %{num} dependency cycle:\n", "Found %{num} dependency cycles:\n", number_of_cycles) % { num: number_of_cycles }
|
232
|
+
|
232
233
|
cycles.each do |cycle|
|
233
234
|
paths = paths_in_cycle(cycle)
|
234
|
-
|
235
|
+
message += paths.map{ |path| '(' + path.join(' => ') + ')'}.join('\n') + '\n'
|
235
236
|
end
|
236
237
|
|
237
238
|
if Puppet[:graph] then
|
238
239
|
filename = write_cycles_to_graph(cycles)
|
239
|
-
message
|
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
|
+
message += _("Cycle graph written to %{filename}.") % { filename: filename }
|
242
241
|
else
|
243
|
-
#TRANSLATORS '--graph' refers to a command line option and should not be translated
|
244
|
-
|
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 }
|
242
|
+
#TRANSLATORS '--graph' refers to a command line option and OmniGraffle and GraphViz are program names and should not be translated
|
243
|
+
message += _("Try the '--graph' option and opening the resulting '.dot' file in OmniGraffle or GraphViz")
|
248
244
|
end
|
249
245
|
Puppet.err(message)
|
250
246
|
cycles
|
@@ -178,7 +178,6 @@ class Puppet::Resource::Catalog::Compiler < Puppet::Indirector::Code
|
|
178
178
|
# TODO: get property/parameter defaults if entries are nil in the resource
|
179
179
|
# For now they're hard-coded to match the File type.
|
180
180
|
|
181
|
-
file_metadata = {}
|
182
181
|
list_of_resources.each do |resource|
|
183
182
|
sources = [resource[:source]].flatten.compact
|
184
183
|
next unless inlineable?(resource, sources)
|
@@ -277,24 +276,31 @@ class Puppet::Resource::Catalog::Compiler < Puppet::Indirector::Code
|
|
277
276
|
raise Puppet::Error, _("Unable to find a common checksum type between agent '%{agent_type}' and master '%{master_type}'.") % { agent_type: options[:checksum_type], master_type: known_checksum_types } unless checksum_type
|
278
277
|
end
|
279
278
|
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
279
|
+
escaped_node_name = node.name.gsub(/%/, '%%')
|
280
|
+
if checksum_type
|
281
|
+
if node.environment
|
282
|
+
escaped_node_environment = node.environment.to_s.gsub(/%/, '%%')
|
283
|
+
benchmark_str = _("Compiled static catalog for %{node} in environment %{environment} in %%{seconds} seconds") % { node: escaped_node_name, environment: escaped_node_environment }
|
284
|
+
profile_str = _("Compiled static catalog for %{node} in environment %{environment}") % { node: node.name, environment: node.environment }
|
285
|
+
else
|
286
|
+
benchmark_str = _("Compiled static catalog for %{node} in %%{seconds} seconds") % { node: escaped_node_name }
|
287
|
+
profile_str = _("Compiled static catalog for %{node}") % { node: node.name }
|
288
|
+
end
|
289
|
+
else
|
290
|
+
if node.environment
|
291
|
+
escaped_node_environment = node.environment.to_s.gsub(/%/, '%%')
|
292
|
+
benchmark_str = _("Compiled catalog for %{node} in environment %{environment} in %%{seconds} seconds") % { node: escaped_node_name, environment: escaped_node_environment }
|
293
|
+
profile_str = _("Compiled catalog for %{node} in environment %{environment}") % { node: node.name, environment: node.environment }
|
294
|
+
else
|
295
|
+
benchmark_str = _("Compiled catalog for %{node} in %%{seconds} seconds") % { node: escaped_node_name }
|
296
|
+
profile_str = _("Compiled catalog for %{node}") % { node: node.name }
|
297
|
+
end
|
298
|
+
end
|
293
299
|
config = nil
|
294
300
|
|
295
|
-
benchmark(:notice,
|
301
|
+
benchmark(:notice, benchmark_str) do
|
296
302
|
compile_type = checksum_type ? :static_compile : :compile
|
297
|
-
Puppet::Util::Profiler.profile(
|
303
|
+
Puppet::Util::Profiler.profile(profile_str, [:compiler, compile_type, node.environment, node.name]) do
|
298
304
|
begin
|
299
305
|
config = Puppet::Parser::Compiler.compile(node, options[:code_id])
|
300
306
|
rescue Puppet::Error => detail
|
@@ -305,15 +311,21 @@ class Puppet::Resource::Catalog::Compiler < Puppet::Indirector::Code
|
|
305
311
|
end
|
306
312
|
|
307
313
|
if checksum_type && config.is_a?(model)
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
314
|
+
escaped_node_name = node.name.gsub(/%/, '%%')
|
315
|
+
if node.environment
|
316
|
+
escaped_node_environment = node.environment.to_s.gsub(/%/, '%%')
|
317
|
+
#TRANSLATORS Inlined refers to adding additional metadata
|
318
|
+
benchmark_str = _("Inlined resource metadata into static catalog for %{node} in environment %{environment} in %%{seconds} seconds") % { node: escaped_node_name, environment: escaped_node_environment }
|
319
|
+
#TRANSLATORS Inlined refers to adding additional metadata
|
320
|
+
profile_str = _("Inlined resource metadata into static catalog for %{node} in environment %{environment}") % { node: node.name, environment: node.environment }
|
321
|
+
else
|
322
|
+
#TRANSLATORS Inlined refers to adding additional metadata
|
323
|
+
benchmark_str = _("Inlined resource metadata into static catalog for %{node} in %%{seconds} seconds") % { node: escaped_node_name }
|
324
|
+
#TRANSLATORS Inlined refers to adding additional metadata
|
325
|
+
profile_str = _("Inlined resource metadata into static catalog for %{node}") % { node: node.name }
|
326
|
+
end
|
327
|
+
benchmark(:notice, benchmark_str) do
|
328
|
+
Puppet::Util::Profiler.profile(profile_str, [:compiler, :static_compile_postprocessing, node.environment, node.name]) do
|
317
329
|
inline_metadata(config, checksum_type)
|
318
330
|
end
|
319
331
|
end
|