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
@@ -11,22 +11,13 @@ module Puppet::ModuleTool::Errors
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def multiline
|
14
|
-
|
14
|
+
message = []
|
15
|
+
message << _("Could not uninstall module '%{module_name}' (%{version})") % { module_name: @module_name, version: v(@version) }
|
16
|
+
message << _(" No installed version of '%{module_name}' matches (%{version})") % { module_name: @module_name, version: v(@version) }
|
17
|
+
message += @modules.map do |mod|
|
15
18
|
_(" '%{module_name}' (%{version}) is installed in %{path}") % { module_name: mod[:name], version: v(mod[:version]), path: mod[:path] }
|
16
|
-
end.join("\n")
|
17
|
-
|
18
|
-
if module_versions_list.empty?
|
19
|
-
_(<<-MSG).chomp % { module_name: @module_name, version: v(@version)}
|
20
|
-
Could not uninstall module '%{module_name}' (%{version})
|
21
|
-
No installed version of '%{module_name}' matches (%{version})
|
22
|
-
MSG
|
23
|
-
else
|
24
|
-
_(<<-MSG).chomp % { module_name: @module_name, version: v(@version), module_versions_list: module_versions_list }
|
25
|
-
Could not uninstall module '%{module_name}' (%{version})
|
26
|
-
No installed version of '%{module_name}' matches (%{version})
|
27
|
-
%{module_versions_list}
|
28
|
-
MSG
|
29
19
|
end
|
20
|
+
message.join("\n")
|
30
21
|
end
|
31
22
|
end
|
32
23
|
|
@@ -41,32 +32,19 @@ Could not uninstall module '%{module_name}' (%{version})
|
|
41
32
|
end
|
42
33
|
|
43
34
|
def multiline
|
44
|
-
|
45
|
-
module_requirements_list = @required_by.map do |mod|
|
46
|
-
msg_variables = { module_name: mod['name'], version: v(mod['version']), module_dependency: @module_name,
|
47
|
-
dependency_version: v(mod['version_requirement']) }
|
48
|
-
_(" '%{module_name}' (%{version}) requires '%{module_dependency}' (%{dependency_version})") % msg_variables
|
49
|
-
end.join("\n")
|
50
|
-
|
35
|
+
message = []
|
51
36
|
if @requested_version
|
52
|
-
|
53
|
-
module_requirements_list: module_requirements_list }
|
54
|
-
#TRANSLATORS `puppet module uninstall --force` is a command line option that should not be translated
|
55
|
-
_(<<-EOF).chomp % msg_variables
|
56
|
-
Could not uninstall module '%{module_name}' (v%{requested_version})
|
57
|
-
Other installed modules have dependencies on '%{module_name}' (%{version})
|
58
|
-
%{module_requirements_list}
|
59
|
-
Use `puppet module uninstall --force` to uninstall this module anyway
|
60
|
-
EOF
|
37
|
+
message << _("Could not uninstall module '%{module_name}' (v%{requested_version})") % { module_name: @module_name, requested_version: @requested_version }
|
61
38
|
else
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
%{
|
67
|
-
Use `puppet module uninstall --force` to uninstall this module anyway
|
68
|
-
EOF
|
39
|
+
message << _("Could not uninstall module '%{module_name}'") % { module_name: @module_name }
|
40
|
+
end
|
41
|
+
message << _(" Other installed modules have dependencies on '%{module_name}' (%{version})") % { module_name: @module_name, version: v(@installed_version) }
|
42
|
+
message += @required_by.map do |mod|
|
43
|
+
_(" '%{module_name}' (%{version}) requires '%{module_dep}' (%{dep_version})") % { module_name: mod['name'], version: v(mod['version']), module_dep: @module_name, dep_version: v(mod['version_requirement']) }
|
69
44
|
end
|
45
|
+
#TRANSLATORS `puppet module uninstall --force` is a command line option that should not be translated
|
46
|
+
message << _(" Use `puppet module uninstall --force` to uninstall this module anyway")
|
47
|
+
message.join("\n")
|
70
48
|
end
|
71
49
|
end
|
72
50
|
end
|
@@ -21,36 +21,24 @@ module Puppet::ModuleTool::Errors
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def multiline
|
24
|
+
message = []
|
25
|
+
message << _("Could not upgrade module '%{module_name}' (%{version})") % { module_name: @module_name, version: vstring }
|
24
26
|
if @newer_versions.empty?
|
25
|
-
|
26
|
-
_(<<-MSG).chomp % { module_name: @module_name, version: vstring }
|
27
|
-
Could not upgrade module '%{module_name}' (%{version})
|
28
|
-
The installed version is already the latest version matching %{version}
|
29
|
-
Use `puppet module upgrade --force` to upgrade only this module
|
30
|
-
MSG
|
27
|
+
message << _(" The installed version is already the latest version matching %{version}") % { version: vstring }
|
31
28
|
else
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
else
|
41
|
-
module_dependency_list = @possible_culprits.map {|name| " - #{name}"}.join("\n")
|
42
|
-
# TRANSLATORS `puppet module upgrade --force` is a command line option that should not be translated
|
43
|
-
_(<<-MSG).chomp % { module_name: @module_name, version: vstring, count: @newer_versions.length, module_dependency_list: module_dependency_list }
|
44
|
-
Could not upgrade module '%{module_name}' (%{version})
|
45
|
-
There are %{count} newer versions
|
46
|
-
No combination of dependency upgrades would satisfy all dependencies
|
47
|
-
Dependencies will not be automatically upgraded across major versions
|
48
|
-
Upgrading one or more of these modules may permit the upgrade to succeed:
|
49
|
-
%{module_dependency_list}
|
50
|
-
Use `puppet module upgrade --force` to upgrade only this module
|
51
|
-
MSG
|
29
|
+
message << _(" There are %{count} newer versions") % { count: @newer_versions.length }
|
30
|
+
message << _(" No combination of dependency upgrades would satisfy all dependencies")
|
31
|
+
unless @possible_culprits.empty?
|
32
|
+
message << _(" Dependencies will not be automatically upgraded across major versions")
|
33
|
+
message << _(" Upgrading one or more of these modules may permit the upgrade to succeed:")
|
34
|
+
@possible_culprits.each do |name|
|
35
|
+
message << " - #{name}"
|
36
|
+
end
|
52
37
|
end
|
53
38
|
end
|
39
|
+
#TRANSLATORS `puppet module upgrade --force` is a command line option that should not be translated
|
40
|
+
message << _(" Use `puppet module upgrade --force` to upgrade only this module")
|
41
|
+
message.join("\n")
|
54
42
|
end
|
55
43
|
end
|
56
44
|
|
@@ -66,10 +54,10 @@ Could not upgrade module '%{module_name}' (%{version})
|
|
66
54
|
end
|
67
55
|
|
68
56
|
def multiline
|
69
|
-
|
70
|
-
Could not %{action} module '%{module_name}' (%{version})
|
71
|
-
Downgrading is not allowed.
|
72
|
-
|
57
|
+
message = []
|
58
|
+
message << _("Could not %{action} module '%{module_name}' (%{version})") % { action: @action, module_name: @module_name, version: vstring }
|
59
|
+
message << _(" Downgrading is not allowed.")
|
60
|
+
message.join("\n")
|
73
61
|
end
|
74
62
|
end
|
75
63
|
end
|
@@ -60,7 +60,7 @@ module Puppet::ModuleTool
|
|
60
60
|
name = mod.forge_name.tr('/', '-')
|
61
61
|
begin
|
62
62
|
version = SemanticPuppet::Version.parse(mod.version)
|
63
|
-
rescue SemanticPuppet::Version::ValidationFailure
|
63
|
+
rescue SemanticPuppet::Version::ValidationFailure
|
64
64
|
Puppet.warning _("%{module_name} (%{path}) has an invalid version number (%{version}). The version has been set to 0.0.0. If you are the maintainer for this module, please update the metadata.json with a valid Semantic Version (http://semver.org).") % { module_name: mod.name, path: mod.path, version: mod.version }
|
65
65
|
version = SemanticPuppet::Version.parse("0.0.0")
|
66
66
|
end
|
@@ -34,7 +34,7 @@ class Rights
|
|
34
34
|
|
35
35
|
def is_forbidden_and_why?(name, args = {})
|
36
36
|
res = :nomatch
|
37
|
-
|
37
|
+
@rights.find do |acl|
|
38
38
|
found = false
|
39
39
|
# an acl can return :dunno, which means "I'm not qualified to answer your question,
|
40
40
|
# please ask someone else". This is used when for instance an acl matches, but not for the
|
@@ -30,7 +30,7 @@ class Puppet::Node
|
|
30
30
|
env_name = data['environment']
|
31
31
|
env_name = env_name.intern unless env_name.nil?
|
32
32
|
@environment_name = env_name
|
33
|
-
environment = env_name
|
33
|
+
environment = env_name # rubocop:disable Lint/UselessAssignment
|
34
34
|
end
|
35
35
|
|
36
36
|
def self.from_data_hash(data)
|
@@ -295,7 +295,7 @@ class Puppet::Node::Environment
|
|
295
295
|
# @param forge_name [String] The module name
|
296
296
|
# @return [Puppet::Module, nil] The module if found, else nil
|
297
297
|
def module_by_forge_name(forge_name)
|
298
|
-
|
298
|
+
_, modname = forge_name.split('/')
|
299
299
|
found_mod = self.module(modname)
|
300
300
|
found_mod and found_mod.forge_name == forge_name ?
|
301
301
|
found_mod :
|
@@ -180,23 +180,10 @@ class Puppet::Parameter::ValueCollection
|
|
180
180
|
def validate(value)
|
181
181
|
return if empty?
|
182
182
|
|
183
|
-
unless @values.detect {
|
184
|
-
str =
|
185
|
-
|
186
|
-
|
187
|
-
else
|
188
|
-
_("Invalid value %{value}. Valid values match %{patterns_list}.") %
|
189
|
-
{ value: value.inspect, patterns_list: regexes.join(", ") }
|
190
|
-
end
|
191
|
-
else
|
192
|
-
if regexes.empty?
|
193
|
-
_("Invalid value %{value}. Valid values are %{values_list}.") %
|
194
|
-
{ value: value.inspect, values_list: values.join(", ") }
|
195
|
-
else
|
196
|
-
_("Invalid value %{value}. Valid values are %{values_list}. Valid values match %{patterns_list}.") %
|
197
|
-
{ value: value.inspect, values_list: values.join(", "), patterns_list: regexes.join(", ") }
|
198
|
-
end
|
199
|
-
end
|
183
|
+
unless @values.detect {|name, v| v.match?(value)}
|
184
|
+
str = _("Invalid value %{value}.") % { value: value.inspect }
|
185
|
+
str += " " + _("Valid values are %{value_list}.") % { value_list: values.join(", ") } unless values.empty?
|
186
|
+
str += " " + _("Valid values match %{pattern}.") % { pattern: regexes.join(", ") } unless regexes.empty?
|
200
187
|
raise ArgumentError, str
|
201
188
|
end
|
202
189
|
end
|
@@ -720,6 +720,7 @@ class Puppet::Parser::Compiler
|
|
720
720
|
Puppet.override( @context_overrides , _("For initializing compiler")) do
|
721
721
|
# THE MAGIC STARTS HERE ! This triggers parsing, loading etc.
|
722
722
|
@catalog.version = environment.known_resource_types.version
|
723
|
+
@loaders.pre_load
|
723
724
|
end
|
724
725
|
|
725
726
|
@catalog.add_resource(Puppet::Parser::Resource.new("stage", :main, :scope => @topscope))
|
@@ -198,7 +198,6 @@ module Puppet::Parser::Functions
|
|
198
198
|
def self.function(name, environment = Puppet.lookup(:current_environment))
|
199
199
|
name = name.intern
|
200
200
|
|
201
|
-
func = nil
|
202
201
|
unless func = get_function(name, environment)
|
203
202
|
autoloader.load(name, environment)
|
204
203
|
func = get_function(name, environment)
|
@@ -884,11 +884,12 @@ class Puppet::Parser::Scope
|
|
884
884
|
path = detail[0]
|
885
885
|
env_path = nil
|
886
886
|
env_path = environment.configuration.path_to_env unless (environment.nil? || environment.configuration.nil?)
|
887
|
-
|
887
|
+
# check module paths first since they may be in the environment (i.e. they are longer)
|
888
|
+
if module_path = environment.full_modulepath.detect {|m_path| path.start_with?(m_path) }
|
889
|
+
path = "<module>" + path[module_path.length..-1]
|
890
|
+
elsif env_path && path && path.start_with?(env_path)
|
888
891
|
path = "<env>" + path[env_path.length..-1]
|
889
892
|
end
|
890
|
-
# TODO: also shorten module paths to <module>/name/...
|
891
|
-
|
892
893
|
# Make the output appear as "Scope(path, line)"
|
893
894
|
"Scope(#{[path, detail[1]].join(', ')})"
|
894
895
|
end
|
@@ -111,6 +111,7 @@ class Puppet::Parser::ScriptCompiler
|
|
111
111
|
|
112
112
|
# Find and evaluate the top level code.
|
113
113
|
def evaluate_main
|
114
|
+
@loaders.pre_load
|
114
115
|
program = @loaders.load_main_manifest
|
115
116
|
return program.nil? ? nil : Puppet::Pops::Parser::EvaluatingParser.singleton.evaluator.evaluate(program, @topscope)
|
116
117
|
end
|
@@ -78,7 +78,8 @@ class Puppet::Parser::TemplateWrapper
|
|
78
78
|
# Expose all the variables in our scope as instance variables of the
|
79
79
|
# current object, making it possible to access them without conflict
|
80
80
|
# to the regular methods.
|
81
|
-
|
81
|
+
escaped_template_source = template_source.gsub(/%/, '%%')
|
82
|
+
benchmark(:debug, _("Bound template variables for %{template_source} in %%{seconds} seconds") % { template_source: escaped_template_source }) do
|
82
83
|
scope.to_hash.each do |name, value|
|
83
84
|
realname = name.gsub(/[^\w]/, "_")
|
84
85
|
instance_variable_set("@#{realname}", value)
|
@@ -86,7 +87,7 @@ class Puppet::Parser::TemplateWrapper
|
|
86
87
|
end
|
87
88
|
|
88
89
|
result = nil
|
89
|
-
benchmark(:debug, _("Interpolated template %{template_source}") % { template_source:
|
90
|
+
benchmark(:debug, _("Interpolated template %{template_source} in %%{seconds} seconds") % { template_source: escaped_template_source }) do
|
90
91
|
template = ERB.new(string, 0, "-")
|
91
92
|
template.filename = @__file__
|
92
93
|
result = template.result(binding)
|
@@ -70,7 +70,7 @@ class Puppet::Parser::TypeLoader
|
|
70
70
|
Puppet.debug {"Automatically imported #{fqname} from #{filename} into #{environment}"}
|
71
71
|
return result
|
72
72
|
end
|
73
|
-
rescue TypeLoaderError
|
73
|
+
rescue TypeLoaderError
|
74
74
|
# I'm not convinced we should just drop these errors, but this
|
75
75
|
# preserves existing behaviours.
|
76
76
|
end
|
@@ -27,8 +27,9 @@ class AccessOperator
|
|
27
27
|
protected
|
28
28
|
|
29
29
|
def access_Object(o, scope, keys)
|
30
|
-
|
31
|
-
|
30
|
+
type = Puppet::Pops::Types::TypeCalculator.infer(o)
|
31
|
+
if type.is_a?(Puppet::Pops::Types::TypeWithMembers)
|
32
|
+
access_func = type['[]']
|
32
33
|
return access_func.invoke(o, scope, keys) unless access_func.nil?
|
33
34
|
end
|
34
35
|
fail(Issues::OPERATOR_NOT_APPLICABLE, @semantic.left_expr, :operator=>'[]', :left_value => o)
|
@@ -318,7 +318,7 @@ class Closure < CallableSignature
|
|
318
318
|
closure_scope = enclosing_scope
|
319
319
|
|
320
320
|
parameters.each do |param|
|
321
|
-
arg_type,
|
321
|
+
arg_type, _ = create_param_type(param, closure_scope)
|
322
322
|
key_type = type_factory.string(param.name.to_s)
|
323
323
|
key_type = type_factory.optional(key_type) unless param.value.nil?
|
324
324
|
members[key_type] = arg_type
|
@@ -442,9 +442,9 @@ class EvaluatorImpl
|
|
442
442
|
end
|
443
443
|
end
|
444
444
|
result = left.send(operator, right)
|
445
|
-
rescue NoMethodError
|
445
|
+
rescue NoMethodError
|
446
446
|
fail(Issues::OPERATOR_NOT_APPLICABLE, left_o, {:operator => operator, :left_value => left})
|
447
|
-
rescue ZeroDivisionError
|
447
|
+
rescue ZeroDivisionError
|
448
448
|
fail(Issues::DIV_BY_ZERO, bin_expr.right_expr)
|
449
449
|
end
|
450
450
|
case result
|
@@ -72,14 +72,15 @@ class Dispatch < Evaluator::CallableSignature
|
|
72
72
|
new_args = []
|
73
73
|
@weaving.each do |knit|
|
74
74
|
if knit.is_a?(Array)
|
75
|
-
|
75
|
+
injection_name = @injections[knit[0]]
|
76
76
|
new_args <<
|
77
|
-
case
|
78
|
-
when :
|
79
|
-
# currently only supports :scope injection
|
77
|
+
case injection_name
|
78
|
+
when :scope
|
80
79
|
scope
|
80
|
+
when :pal_script_compiler
|
81
|
+
Puppet.lookup(:pal_script_compiler)
|
81
82
|
else
|
82
|
-
|
83
|
+
raise ArgumentError, "Unknown injection #{injection_name}"
|
83
84
|
end
|
84
85
|
else
|
85
86
|
# Careful so no new nil arguments are added since they would override default
|
@@ -49,13 +49,13 @@ class Puppet::Pops::Functions::Function
|
|
49
49
|
rescue Puppet::Pops::Evaluator::Next => jumper
|
50
50
|
begin
|
51
51
|
throw :next, jumper.value
|
52
|
-
rescue Puppet::Parser::Scope::UNCAUGHT_THROW_EXCEPTION
|
52
|
+
rescue Puppet::Parser::Scope::UNCAUGHT_THROW_EXCEPTION
|
53
53
|
raise Puppet::ParseError.new("next() from context where this is illegal", jumper.file, jumper.line)
|
54
54
|
end
|
55
55
|
rescue Puppet::Pops::Evaluator::Return => jumper
|
56
56
|
begin
|
57
57
|
throw :return, jumper
|
58
|
-
rescue Puppet::Parser::Scope::UNCAUGHT_THROW_EXCEPTION
|
58
|
+
rescue Puppet::Parser::Scope::UNCAUGHT_THROW_EXCEPTION
|
59
59
|
raise Puppet::ParseError.new("return() from context where this is illegal", jumper.file, jumper.line)
|
60
60
|
end
|
61
61
|
end
|
@@ -29,7 +29,7 @@ class Loader
|
|
29
29
|
attr_reader :loader_name
|
30
30
|
|
31
31
|
# Describes the kinds of things that loaders can load
|
32
|
-
LOADABLE_KINDS = [:func_4x, :func_4xpp, :type_pp, :resource_type_pp, :plan, :task].freeze
|
32
|
+
LOADABLE_KINDS = [:func_4x, :func_4xpp, :datatype, :type_pp, :resource_type_pp, :plan, :task].freeze
|
33
33
|
|
34
34
|
# @param [String] name the name of the loader. Must be unique among all loaders maintained by a {Loader} instance
|
35
35
|
def initialize(loader_name)
|
@@ -31,6 +31,7 @@ module LoaderPaths
|
|
31
31
|
when :task
|
32
32
|
result << TaskPath.new(loader) if Puppet[:tasks] && loader.loadables.include?(:task)
|
33
33
|
when :type
|
34
|
+
result << DataTypePath.new(loader) if loader.loadables.include?(:datatype)
|
34
35
|
result << TypePathPP.new(loader) if loader.loadables.include?(:type_pp)
|
35
36
|
when :resource_type_pp
|
36
37
|
result << ResourceTypeImplPP.new(loader) if loader.loadables.include?(:resource_type_pp)
|
@@ -203,6 +204,19 @@ module LoaderPaths
|
|
203
204
|
end
|
204
205
|
end
|
205
206
|
|
207
|
+
class DataTypePath < RubySmartPath
|
208
|
+
SYSTEM_TYPE_PATH = File.join('puppet', 'datatypes').freeze
|
209
|
+
TYPE_PATH = File.join('lib', SYSTEM_TYPE_PATH).freeze
|
210
|
+
|
211
|
+
def relative_path
|
212
|
+
lib_root? ? SYSTEM_TYPE_PATH : TYPE_PATH
|
213
|
+
end
|
214
|
+
|
215
|
+
def instantiator
|
216
|
+
RubyDataTypeInstantiator
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
206
220
|
class TypePathPP < PuppetSmartPath
|
207
221
|
TYPE_PATH_PP = 'types'.freeze
|
208
222
|
|
@@ -240,11 +254,15 @@ module LoaderPaths
|
|
240
254
|
# Remove extension regardless of what it is. A task name cannot contain dots
|
241
255
|
relative_path = relative_path.sub(/\.[^\/]*\z/, '')
|
242
256
|
|
243
|
-
relative_path
|
244
|
-
|
245
|
-
|
257
|
+
if relative_path == 'init' && !(module_name.nil? || module_name.empty?)
|
258
|
+
TypedName.new(type, module_name, name_authority)
|
259
|
+
else
|
260
|
+
relative_path.split('/').each do |segment|
|
261
|
+
n << '::' if n.size > 0
|
262
|
+
n << segment
|
263
|
+
end
|
264
|
+
TypedName.new(type, n, name_authority)
|
246
265
|
end
|
247
|
-
TypedName.new(type, n, name_authority)
|
248
266
|
end
|
249
267
|
|
250
268
|
def instantiator
|
@@ -302,6 +320,24 @@ module LoaderPaths
|
|
302
320
|
def instantiator()
|
303
321
|
Puppet::Pops::Loader::PuppetPlanInstantiator
|
304
322
|
end
|
323
|
+
|
324
|
+
def typed_name(type, name_authority, relative_path, module_name)
|
325
|
+
if relative_path == 'init.pp' && !(module_name.nil? || module_name.empty?)
|
326
|
+
TypedName.new(type, module_name, name_authority)
|
327
|
+
else
|
328
|
+
n = ''
|
329
|
+
n << module_name unless module_name.nil?
|
330
|
+
unless extension.empty?
|
331
|
+
# Remove extension
|
332
|
+
relative_path = relative_path[0..-(extension.length+1)]
|
333
|
+
end
|
334
|
+
relative_path.split('/').each do |segment|
|
335
|
+
n << '::' if n.size > 0
|
336
|
+
n << segment
|
337
|
+
end
|
338
|
+
TypedName.new(type, n, name_authority)
|
339
|
+
end
|
340
|
+
end
|
305
341
|
end
|
306
342
|
|
307
343
|
# SmartPaths
|