bolt 0.20.3 → 0.20.5
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/bolt-modules/boltlib/lib/puppet/functions/run_task.rb +3 -3
- data/bolt-modules/boltlib/lib/puppet/functions/set_feature.rb +33 -0
- data/lib/bolt/inventory.rb +19 -1
- data/lib/bolt/target.rb +15 -0
- data/lib/bolt/transport/local.rb +6 -1
- data/lib/bolt/transport/orch.rb +2 -0
- data/lib/bolt/transport/ssh.rb +7 -2
- data/lib/bolt/transport/winrm.rb +6 -1
- data/lib/bolt/version.rb +1 -1
- data/modules/facts/plans/retrieve.pp +2 -26
- data/modules/facts/tasks/init.json +9 -0
- data/vendored/puppet/lib/hiera/puppet_function.rb +1 -1
- data/vendored/puppet/lib/hiera/scope.rb +24 -2
- data/vendored/puppet/lib/puppet.rb +4 -13
- data/vendored/puppet/lib/puppet/application.rb +2 -2
- data/vendored/puppet/lib/puppet/application/agent.rb +1 -1
- data/vendored/puppet/lib/puppet/application/apply.rb +1 -1
- data/vendored/puppet/lib/puppet/application/cert.rb +1 -1
- data/vendored/puppet/lib/puppet/application/device.rb +8 -8
- data/vendored/puppet/lib/puppet/application/face_base.rb +1 -1
- data/vendored/puppet/lib/puppet/application/lookup.rb +2 -2
- data/vendored/puppet/lib/puppet/application/resource.rb +2 -2
- data/vendored/puppet/lib/puppet/application/script.rb +1 -1
- data/vendored/puppet/lib/puppet/configurer.rb +47 -24
- data/vendored/puppet/lib/puppet/confine.rb +4 -1
- data/vendored/puppet/lib/puppet/context.rb +1 -1
- data/vendored/puppet/lib/puppet/defaults.rb +32 -44
- data/vendored/puppet/lib/puppet/error.rb +14 -7
- data/vendored/puppet/lib/puppet/external/dot.rb +23 -17
- data/vendored/puppet/lib/puppet/face/config.rb +58 -3
- data/vendored/puppet/lib/puppet/face/epp.rb +1 -1
- data/vendored/puppet/lib/puppet/face/module/build.rb +3 -3
- data/vendored/puppet/lib/puppet/face/module/install.rb +0 -4
- data/vendored/puppet/lib/puppet/face/module/list.rb +0 -5
- data/vendored/puppet/lib/puppet/face/module/search.rb +1 -1
- data/vendored/puppet/lib/puppet/face/module/uninstall.rb +0 -4
- data/vendored/puppet/lib/puppet/face/module/upgrade.rb +0 -4
- data/vendored/puppet/lib/puppet/face/status.rb +2 -2
- data/vendored/puppet/lib/puppet/file_serving/base.rb +5 -5
- data/vendored/puppet/lib/puppet/file_serving/metadata.rb +2 -1
- data/vendored/puppet/lib/puppet/forge.rb +7 -8
- data/vendored/puppet/lib/puppet/forge/errors.rb +3 -3
- data/vendored/puppet/lib/puppet/functions/abs.rb +61 -0
- data/vendored/puppet/lib/puppet/functions/all.rb +2 -2
- data/vendored/puppet/lib/puppet/functions/any.rb +2 -2
- data/vendored/puppet/lib/puppet/functions/assert_type.rb +3 -3
- data/vendored/puppet/lib/puppet/functions/break.rb +3 -7
- data/vendored/puppet/lib/puppet/functions/camelcase.rb +62 -0
- data/vendored/puppet/lib/puppet/functions/capitalize.rb +61 -0
- data/vendored/puppet/lib/puppet/functions/ceiling.rb +37 -0
- data/vendored/puppet/lib/puppet/functions/chomp.rb +57 -0
- data/vendored/puppet/lib/puppet/functions/chop.rb +67 -0
- data/vendored/puppet/lib/puppet/functions/compare.rb +125 -0
- data/vendored/puppet/lib/puppet/functions/convert_to.rb +3 -2
- data/vendored/puppet/lib/puppet/functions/dig.rb +21 -1
- data/vendored/puppet/lib/puppet/functions/downcase.rb +89 -0
- data/vendored/puppet/lib/puppet/functions/each.rb +2 -2
- data/vendored/puppet/lib/puppet/functions/empty.rb +1 -3
- data/vendored/puppet/lib/puppet/functions/eyaml_lookup_key.rb +4 -2
- data/vendored/puppet/lib/puppet/functions/filter.rb +2 -2
- data/vendored/puppet/lib/puppet/functions/floor.rb +37 -0
- data/vendored/puppet/lib/puppet/functions/get.rb +150 -0
- data/vendored/puppet/lib/puppet/functions/getvar.rb +87 -0
- data/vendored/puppet/lib/puppet/functions/hiera.rb +5 -5
- data/vendored/puppet/lib/puppet/functions/hiera_array.rb +5 -5
- data/vendored/puppet/lib/puppet/functions/hiera_hash.rb +6 -6
- data/vendored/puppet/lib/puppet/functions/hiera_include.rb +7 -7
- data/vendored/puppet/lib/puppet/functions/hocon_data.rb +1 -1
- data/vendored/puppet/lib/puppet/functions/json_data.rb +3 -3
- data/vendored/puppet/lib/puppet/functions/lest.rb +1 -1
- data/vendored/puppet/lib/puppet/functions/lookup.rb +3 -2
- data/vendored/puppet/lib/puppet/functions/lstrip.rb +58 -0
- data/vendored/puppet/lib/puppet/functions/map.rb +1 -1
- data/vendored/puppet/lib/puppet/functions/match.rb +11 -0
- data/vendored/puppet/lib/puppet/functions/max.rb +183 -0
- data/vendored/puppet/lib/puppet/functions/min.rb +182 -0
- data/vendored/puppet/lib/puppet/functions/next.rb +1 -8
- data/vendored/puppet/lib/puppet/functions/reduce.rb +1 -1
- data/vendored/puppet/lib/puppet/functions/return.rb +1 -8
- data/vendored/puppet/lib/puppet/functions/reverse_each.rb +1 -1
- data/vendored/puppet/lib/puppet/functions/round.rb +24 -0
- data/vendored/puppet/lib/puppet/functions/rstrip.rb +58 -0
- data/vendored/puppet/lib/puppet/functions/size.rb +15 -0
- data/vendored/puppet/lib/puppet/functions/sort.rb +74 -0
- data/vendored/puppet/lib/puppet/functions/step.rb +1 -1
- data/vendored/puppet/lib/puppet/functions/strftime.rb +1 -7
- data/vendored/puppet/lib/puppet/functions/strip.rb +58 -0
- data/vendored/puppet/lib/puppet/functions/then.rb +1 -1
- data/vendored/puppet/lib/puppet/functions/tree_each.rb +7 -7
- data/vendored/puppet/lib/puppet/functions/upcase.rb +89 -0
- data/vendored/puppet/lib/puppet/functions/with.rb +4 -4
- data/vendored/puppet/lib/puppet/functions/yaml_data.rb +4 -2
- data/vendored/puppet/lib/puppet/graph/simple_graph.rb +9 -5
- data/vendored/puppet/lib/puppet/indirector/certificate_revocation_list/rest.rb +0 -11
- data/vendored/puppet/lib/puppet/indirector/indirection.rb +8 -12
- data/vendored/puppet/lib/puppet/indirector/node/exec.rb +1 -1
- data/vendored/puppet/lib/puppet/indirector/node/ldap.rb +1 -1
- data/vendored/puppet/lib/puppet/indirector/request.rb +11 -11
- data/vendored/puppet/lib/puppet/indirector/rest.rb +11 -11
- data/vendored/puppet/lib/puppet/interface/action.rb +2 -5
- data/vendored/puppet/lib/puppet/metatype/manager.rb +0 -2
- data/vendored/puppet/lib/puppet/module.rb +7 -33
- data/vendored/puppet/lib/puppet/module/task.rb +0 -1
- data/vendored/puppet/lib/puppet/module_tool.rb +2 -5
- data/vendored/puppet/lib/puppet/module_tool/applications/application.rb +5 -5
- data/vendored/puppet/lib/puppet/module_tool/applications/builder.rb +2 -2
- data/vendored/puppet/lib/puppet/module_tool/applications/checksummer.rb +3 -3
- data/vendored/puppet/lib/puppet/module_tool/applications/installer.rb +6 -7
- data/vendored/puppet/lib/puppet/module_tool/applications/uninstaller.rb +1 -2
- data/vendored/puppet/lib/puppet/module_tool/applications/unpacker.rb +2 -2
- data/vendored/puppet/lib/puppet/module_tool/applications/upgrader.rb +5 -6
- data/vendored/puppet/lib/puppet/module_tool/dependency.rb +1 -1
- data/vendored/puppet/lib/puppet/module_tool/installed_modules.rb +2 -2
- data/vendored/puppet/lib/puppet/module_tool/local_tarball.rb +3 -3
- data/vendored/puppet/lib/puppet/module_tool/metadata.rb +3 -4
- data/vendored/puppet/lib/puppet/module_tool/shared_behaviors.rb +2 -2
- data/vendored/puppet/lib/puppet/network/authconfig.rb +0 -13
- data/vendored/puppet/lib/puppet/network/format_support.rb +1 -1
- data/vendored/puppet/lib/puppet/network/formats.rb +5 -7
- data/vendored/puppet/lib/puppet/network/http.rb +0 -2
- data/vendored/puppet/lib/puppet/network/http/api.rb +1 -10
- data/vendored/puppet/lib/puppet/network/http/api/master/v3/environment.rb +2 -2
- data/vendored/puppet/lib/puppet/network/http/api/master/v3/environments.rb +2 -2
- data/vendored/puppet/lib/puppet/network/http/compression.rb +1 -1
- data/vendored/puppet/lib/puppet/network/http/connection.rb +11 -3
- data/vendored/puppet/lib/puppet/network/http/error.rb +3 -3
- data/vendored/puppet/lib/puppet/network/http/factory.rb +3 -0
- data/vendored/puppet/lib/puppet/network/http/handler.rb +59 -27
- data/vendored/puppet/lib/puppet/network/resolver.rb +140 -67
- data/vendored/puppet/lib/puppet/node/environment.rb +2 -19
- data/vendored/puppet/lib/puppet/parameter.rb +12 -7
- data/vendored/puppet/lib/puppet/parser/ast.rb +4 -8
- data/vendored/puppet/lib/puppet/parser/ast/branch.rb +3 -3
- data/vendored/puppet/lib/puppet/parser/ast/leaf.rb +5 -0
- data/vendored/puppet/lib/puppet/parser/ast/pops_bridge.rb +18 -0
- data/vendored/puppet/lib/puppet/parser/compiler.rb +3 -4
- data/vendored/puppet/lib/puppet/parser/compiler/catalog_validator/relationship_validator.rb +9 -2
- data/vendored/puppet/lib/puppet/parser/functions.rb +1 -1
- data/vendored/puppet/lib/puppet/parser/functions/assert_type.rb +3 -3
- data/vendored/puppet/lib/puppet/parser/functions/create_resources.rb +1 -7
- data/vendored/puppet/lib/puppet/parser/functions/each.rb +2 -2
- data/vendored/puppet/lib/puppet/parser/functions/filter.rb +1 -1
- data/vendored/puppet/lib/puppet/parser/functions/hiera.rb +4 -4
- data/vendored/puppet/lib/puppet/parser/functions/hiera_array.rb +5 -5
- data/vendored/puppet/lib/puppet/parser/functions/hiera_hash.rb +6 -6
- data/vendored/puppet/lib/puppet/parser/functions/hiera_include.rb +10 -11
- data/vendored/puppet/lib/puppet/parser/functions/inline_template.rb +1 -1
- data/vendored/puppet/lib/puppet/parser/functions/lest.rb +1 -1
- data/vendored/puppet/lib/puppet/parser/functions/lookup.rb +1 -1
- data/vendored/puppet/lib/puppet/parser/functions/map.rb +1 -1
- data/vendored/puppet/lib/puppet/parser/functions/reduce.rb +1 -1
- data/vendored/puppet/lib/puppet/parser/functions/return.rb +22 -1
- data/vendored/puppet/lib/puppet/parser/functions/reverse_each.rb +1 -1
- data/vendored/puppet/lib/puppet/parser/functions/step.rb +1 -1
- data/vendored/puppet/lib/puppet/parser/functions/then.rb +1 -1
- data/vendored/puppet/lib/puppet/parser/functions/with.rb +4 -4
- data/vendored/puppet/lib/puppet/parser/resource.rb +0 -1
- data/vendored/puppet/lib/puppet/parser/resource/param.rb +12 -5
- data/vendored/puppet/lib/puppet/parser/scope.rb +5 -7
- data/vendored/puppet/lib/puppet/pops/evaluator/compare_operator.rb +3 -1
- data/vendored/puppet/lib/puppet/pops/evaluator/runtime3_support.rb +2 -7
- data/vendored/puppet/lib/puppet/pops/issues.rb +4 -0
- data/vendored/puppet/lib/puppet/pops/loader/loader_paths.rb +2 -2
- data/vendored/puppet/lib/puppet/pops/loader/module_loaders.rb +17 -12
- data/vendored/puppet/lib/puppet/pops/loader/task_instantiator.rb +73 -45
- data/vendored/puppet/lib/puppet/pops/lookup/lookup_adapter.rb +55 -6
- data/vendored/puppet/lib/puppet/pops/model/model_label_provider.rb +2 -0
- data/vendored/puppet/lib/puppet/pops/parser/epp_parser.rb +1 -1
- data/vendored/puppet/lib/puppet/pops/parser/epp_support.rb +6 -2
- data/vendored/puppet/lib/puppet/pops/parser/lexer2.rb +1 -1
- data/vendored/puppet/lib/puppet/pops/pcore.rb +7 -7
- data/vendored/puppet/lib/puppet/pops/puppet_stack.rb +15 -1
- data/vendored/puppet/lib/puppet/pops/serialization.rb +2 -2
- data/vendored/puppet/lib/puppet/pops/serialization/from_data_converter.rb +2 -2
- data/vendored/puppet/lib/puppet/pops/serialization/json.rb +7 -7
- data/vendored/puppet/lib/puppet/pops/serialization/to_data_converter.rb +5 -5
- data/vendored/puppet/lib/puppet/pops/types/types.rb +8 -4
- data/vendored/puppet/lib/puppet/pops/validation/checker4_0.rb +73 -0
- data/vendored/puppet/lib/puppet/pops/validation/validator_factory_4_0.rb +4 -3
- data/vendored/puppet/lib/puppet/provider/augeas/augeas.rb +7 -0
- data/vendored/puppet/lib/puppet/provider/service/systemd.rb +1 -1
- data/vendored/puppet/lib/puppet/provider/user/aix.rb +2 -2
- data/vendored/puppet/lib/puppet/provider/yumrepo/inifile.rb +21 -9
- data/vendored/puppet/lib/puppet/reference/providers.rb +1 -1
- data/vendored/puppet/lib/puppet/reference/report.rb +1 -1
- data/vendored/puppet/lib/puppet/resource.rb +1 -1
- data/vendored/puppet/lib/puppet/resource/capability_finder.rb +4 -4
- data/vendored/puppet/lib/puppet/resource/catalog.rb +6 -3
- data/vendored/puppet/lib/puppet/resource/type.rb +6 -2
- data/vendored/puppet/lib/puppet/rest/client.rb +79 -0
- data/vendored/puppet/lib/puppet/rest/errors.rb +14 -0
- data/vendored/puppet/lib/puppet/rest/response.rb +29 -0
- data/vendored/puppet/lib/puppet/rest/route.rb +102 -0
- data/vendored/puppet/lib/puppet/rest/routes.rb +31 -0
- data/vendored/puppet/lib/puppet/settings.rb +9 -5
- data/vendored/puppet/lib/puppet/settings/config_file.rb +1 -1
- data/vendored/puppet/lib/puppet/settings/environment_conf.rb +10 -1
- data/vendored/puppet/lib/puppet/ssl.rb +0 -1
- data/vendored/puppet/lib/puppet/ssl/certificate.rb +6 -2
- data/vendored/puppet/lib/puppet/ssl/certificate_authority.rb +3 -3
- data/vendored/puppet/lib/puppet/ssl/host.rb +258 -19
- data/vendored/puppet/lib/puppet/ssl/validator/default_validator.rb +33 -19
- data/vendored/puppet/lib/puppet/syntax_checkers/json.rb +1 -1
- data/vendored/puppet/lib/puppet/transaction/event.rb +34 -7
- data/vendored/puppet/lib/puppet/transaction/report.rb +17 -14
- data/vendored/puppet/lib/puppet/type.rb +20 -12
- data/vendored/puppet/lib/puppet/type/file.rb +1 -1
- data/vendored/puppet/lib/puppet/type/file/content.rb +15 -2
- data/vendored/puppet/lib/puppet/type/file/ensure.rb +1 -1
- data/vendored/puppet/lib/puppet/type/schedule.rb +1 -1
- data/vendored/puppet/lib/puppet/type/stage.rb +1 -1
- data/vendored/puppet/lib/puppet/type/tidy.rb +5 -1
- data/vendored/puppet/lib/puppet/type/user.rb +35 -18
- data/vendored/puppet/lib/puppet/type/yumrepo.rb +8 -17
- data/vendored/puppet/lib/puppet/util.rb +0 -1
- data/vendored/puppet/lib/puppet/util/autoload.rb +1 -6
- data/vendored/puppet/lib/puppet/util/checksums.rb +0 -2
- data/vendored/puppet/lib/puppet/util/classgen.rb +0 -6
- data/vendored/puppet/lib/puppet/util/fileparsing.rb +27 -5
- data/vendored/puppet/lib/puppet/util/instance_loader.rb +3 -3
- data/vendored/puppet/lib/puppet/util/json.rb +77 -0
- data/vendored/puppet/lib/puppet/util/json_lockfile.rb +3 -3
- data/vendored/puppet/lib/puppet/util/ldap/connection.rb +7 -7
- data/vendored/puppet/lib/puppet/util/log/destinations.rb +2 -2
- data/vendored/puppet/lib/puppet/util/logging.rb +1 -1
- data/vendored/puppet/lib/puppet/util/plist.rb +1 -1
- data/vendored/puppet/lib/puppet/util/provider_features.rb +2 -5
- data/vendored/puppet/lib/puppet/util/reference.rb +5 -4
- data/vendored/puppet/lib/puppet/util/tagging.rb +16 -3
- data/vendored/puppet/lib/puppet/version.rb +1 -1
- metadata +44 -26
- data/vendored/puppet/lib/puppet/application/master.rb +0 -317
- data/vendored/puppet/lib/puppet/feature/rack.rb +0 -19
- data/vendored/puppet/lib/puppet/network/http/api/ca.rb +0 -2
- data/vendored/puppet/lib/puppet/network/http/api/ca/v1.rb +0 -11
- data/vendored/puppet/lib/puppet/network/http/rack.rb +0 -33
- data/vendored/puppet/lib/puppet/network/http/rack/rest.rb +0 -162
- data/vendored/puppet/lib/puppet/network/http/webrick.rb +0 -124
- data/vendored/puppet/lib/puppet/network/http/webrick/rest.rb +0 -114
- data/vendored/puppet/lib/puppet/network/server.rb +0 -39
- data/vendored/puppet/lib/puppet/ssl/configuration.rb +0 -61
- data/vendored/puppet/lib/puppet/util/methodhelper.rb +0 -32
- data/vendored/puppet/lib/puppet/vendor/load_semantic.rb +0 -1
- data/vendored/puppet/lib/puppet/vendor/load_semantic_puppet.rb +0 -1
- data/vendored/puppet/lib/puppet/vendor/semantic/lib/semantic.rb +0 -5
- data/vendored/puppet/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet.rb +0 -11
- data/vendored/puppet/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency.rb +0 -181
- data/vendored/puppet/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency/graph.rb +0 -60
- data/vendored/puppet/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency/graph_node.rb +0 -117
- data/vendored/puppet/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency/module_release.rb +0 -58
- data/vendored/puppet/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency/source.rb +0 -25
- data/vendored/puppet/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency/unsatisfiable_graph.rb +0 -31
- data/vendored/puppet/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/gem_version.rb +0 -3
- data/vendored/puppet/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/version.rb +0 -203
- data/vendored/puppet/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/version_range.rb +0 -758
@@ -1,6 +1,6 @@
|
|
1
1
|
Puppet::Parser::Functions::newfunction(:inline_template, :type => :rvalue, :arity => -2, :doc =>
|
2
2
|
"Evaluate a template string and return its value. See
|
3
|
-
[the templating docs](https://
|
3
|
+
[the templating docs](https://puppet.com/docs/puppet/latest/lang_template.html) for
|
4
4
|
more information. Note that if multiple template strings are specified, their
|
5
5
|
output is all concatenated and returned as the output of the function.") do |vals|
|
6
6
|
|
@@ -3,7 +3,7 @@ Puppet::Parser::Functions::newfunction(
|
|
3
3
|
:type => :rvalue,
|
4
4
|
:arity => -2,
|
5
5
|
:doc => <<-DOC
|
6
|
-
Call a [lambda](https://
|
6
|
+
Call a [lambda](https://puppet.com/docs/puppet/latest/lang_lambdas.html)
|
7
7
|
(which should accept no arguments) if the argument given to the function is `undef`.
|
8
8
|
Returns the result of calling the lambda if the argument is `undef`, otherwise the
|
9
9
|
given argument.
|
@@ -31,7 +31,7 @@ The arguments accepted by `lookup` are as follows:
|
|
31
31
|
first key, it will try again with the subsequent ones, only resorting to a
|
32
32
|
default value if none of them succeed.
|
33
33
|
2. `<VALUE TYPE>` (data type) --- A
|
34
|
-
[data type](https://
|
34
|
+
[data type](https://puppet.com/docs/puppet/latest/lang_data_type.html)
|
35
35
|
that must match the retrieved value; if not, the lookup (and catalog
|
36
36
|
compilation) will fail. Defaults to `Data` (accepts any normal value).
|
37
37
|
3. `<MERGE BEHAVIOR>` (string or hash; see **"Merge Behaviors"** below) ---
|
@@ -3,7 +3,7 @@ Puppet::Parser::Functions::newfunction(
|
|
3
3
|
:type => :rvalue,
|
4
4
|
:arity => -3,
|
5
5
|
:doc => <<-DOC
|
6
|
-
Applies a [lambda](https://
|
6
|
+
Applies a [lambda](https://puppet.com/docs/puppet/latest/lang_lambdas.html)
|
7
7
|
to every value in a data structure and returns an array containing the results.
|
8
8
|
|
9
9
|
This function takes two mandatory arguments, in this order:
|
@@ -3,7 +3,7 @@ Puppet::Parser::Functions::newfunction(
|
|
3
3
|
:type => :rvalue,
|
4
4
|
:arity => -3,
|
5
5
|
:doc => <<-DOC
|
6
|
-
Applies a [lambda](https://
|
6
|
+
Applies a [lambda](https://puppet.com/docs/puppet/latest/lang_lambdas.html)
|
7
7
|
to every value in a data structure from the first argument, carrying over the returned
|
8
8
|
value of each iteration, and returns the result of the lambda's final iteration. This
|
9
9
|
lets you create a new value or data structure by combining values from the first
|
@@ -4,7 +4,8 @@ Puppet::Parser::Functions::newfunction(
|
|
4
4
|
:doc => <<-DOC
|
5
5
|
Immediately returns the given optional value from a function, class body or user defined type body.
|
6
6
|
If a value is not given, an `undef` value is returned. This function does not return to the immediate caller.
|
7
|
-
If called from within a lambda the return
|
7
|
+
If this function is called from within a lambda, the return action is from the scope of the
|
8
|
+
function containing the lambda (top scope), not the function accepting the lambda (local scope).
|
8
9
|
|
9
10
|
The signal produced to return a value bubbles up through
|
10
11
|
the call stack until reaching a function, class definition or
|
@@ -63,6 +64,26 @@ The code would notice `'bar'` but not `'foo'`
|
|
63
64
|
|
64
65
|
Note that the returned value is ignored if used in a class or user defined type.
|
65
66
|
|
67
|
+
**Example:** Using `return` in a lambda
|
68
|
+
|
69
|
+
```puppet
|
70
|
+
# Concatenate three strings into a single string formatted as a list.
|
71
|
+
function getFruit() {
|
72
|
+
with("apples", "oranges", "bananas") |$x, $y, $z| {
|
73
|
+
return("${x}, ${y}, and ${z}")
|
74
|
+
}
|
75
|
+
notice "not reached"
|
76
|
+
}
|
77
|
+
$fruit = getFruit()
|
78
|
+
notice $fruit
|
79
|
+
|
80
|
+
# The output contains "apples, oranges, and bananas".
|
81
|
+
# "not reached" is not output because the function returns its value within the
|
82
|
+
# calling function's scope, which stops processing the calling function before
|
83
|
+
# the `notice "not reached"` statement.
|
84
|
+
# Using `return()` outside of a calling function results in an error.
|
85
|
+
```
|
86
|
+
|
66
87
|
* Also see functions `return` and `break`
|
67
88
|
* Since 4.8.0
|
68
89
|
DOC
|
@@ -4,7 +4,7 @@ Puppet::Parser::Functions::newfunction(
|
|
4
4
|
:arity => -1,
|
5
5
|
:doc => <<-DOC
|
6
6
|
Reverses the order of the elements of something that is iterable and optionally runs a
|
7
|
-
[lambda](https://
|
7
|
+
[lambda](https://puppet.com/docs/puppet/latest/lang_lambdas.html) for each
|
8
8
|
element.
|
9
9
|
|
10
10
|
This function takes one to two arguments:
|
@@ -4,7 +4,7 @@ Puppet::Parser::Functions::newfunction(
|
|
4
4
|
:arity => -1,
|
5
5
|
:doc => <<-DOC
|
6
6
|
Provides stepping with given interval over elements in an iterable and optionally runs a
|
7
|
-
[lambda](https://
|
7
|
+
[lambda](https://puppet.com/docs/puppet/latest/lang_lambdas.html) for each
|
8
8
|
element.
|
9
9
|
|
10
10
|
This function takes two to three arguments:
|
@@ -3,7 +3,7 @@ Puppet::Parser::Functions::newfunction(
|
|
3
3
|
:type => :rvalue,
|
4
4
|
:arity => -2,
|
5
5
|
:doc => <<-DOC
|
6
|
-
Call a [lambda](https://
|
6
|
+
Call a [lambda](https://puppet.com/docs/puppet/latest/lang_lambdas.html)
|
7
7
|
with the given argument unless the argument is undef. Return `undef` if argument is
|
8
8
|
`undef`, and otherwise the result of giving the argument to the lambda.
|
9
9
|
|
@@ -3,11 +3,11 @@ Puppet::Parser::Functions::newfunction(
|
|
3
3
|
:type => :rvalue,
|
4
4
|
:arity => -1,
|
5
5
|
:doc => <<-DOC
|
6
|
-
Call a [lambda](https://
|
6
|
+
Call a [lambda](https://puppet.com/docs/puppet/latest/lang_lambdas.html)
|
7
7
|
with the given arguments and return the result. Since a lambda's scope is
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
local to the lambda, you can use the `with` function to create private blocks
|
9
|
+
of code within a class using variables whose values cannot be accessed outside
|
10
|
+
of the lambda.
|
11
11
|
|
12
12
|
**Example**: Using `with`
|
13
13
|
|
@@ -2,14 +2,21 @@
|
|
2
2
|
class Puppet::Parser::Resource::Param
|
3
3
|
include Puppet::Util
|
4
4
|
include Puppet::Util::Errors
|
5
|
-
include Puppet::Util::MethodHelper
|
6
5
|
|
7
6
|
attr_accessor :name, :value, :source, :add, :file, :line
|
8
7
|
|
9
|
-
def initialize(
|
10
|
-
|
11
|
-
|
12
|
-
@
|
8
|
+
def initialize(name: nil, value: nil, source: nil, line: nil, file: nil, add: nil)
|
9
|
+
@value = value
|
10
|
+
@source = source
|
11
|
+
@line = line
|
12
|
+
@file = file
|
13
|
+
@add = add
|
14
|
+
|
15
|
+
unless name
|
16
|
+
# This must happen after file and line are set to have them reported in the error
|
17
|
+
self.fail(Puppet::ResourceError, "'name' is a required option for #{self.class}")
|
18
|
+
end
|
19
|
+
@name = name.intern
|
13
20
|
end
|
14
21
|
|
15
22
|
def line_to_i
|
@@ -7,8 +7,6 @@ require 'puppet/parser'
|
|
7
7
|
require 'puppet/parser/templatewrapper'
|
8
8
|
require 'puppet/parser/resource'
|
9
9
|
|
10
|
-
require 'puppet/util/methodhelper'
|
11
|
-
|
12
10
|
# This class is part of the internal parser/evaluator/compiler functionality of Puppet.
|
13
11
|
# It is passed between the various classes that participate in evaluation.
|
14
12
|
# None of its methods are API except those that are clearly marked as such.
|
@@ -16,7 +14,6 @@ require 'puppet/util/methodhelper'
|
|
16
14
|
# @api public
|
17
15
|
class Puppet::Parser::Scope
|
18
16
|
extend Forwardable
|
19
|
-
include Puppet::Util::MethodHelper
|
20
17
|
|
21
18
|
# Variables that always exist with nil value even if not set
|
22
19
|
BUILT_IN_VARS = ['module_name'.freeze, 'caller_module_name'.freeze].freeze
|
@@ -374,14 +371,15 @@ class Puppet::Parser::Scope
|
|
374
371
|
end
|
375
372
|
|
376
373
|
# Initialize our new scope. Defaults to having no parent.
|
377
|
-
def initialize(compiler,
|
374
|
+
def initialize(compiler, source: nil, resource: nil)
|
378
375
|
if compiler.is_a? Puppet::Parser::AbstractCompiler
|
379
376
|
@compiler = compiler
|
380
377
|
else
|
381
378
|
raise Puppet::DevError, _("you must pass a compiler instance to a new scope object")
|
382
379
|
end
|
383
380
|
|
384
|
-
|
381
|
+
@source = source
|
382
|
+
@resource = resource
|
385
383
|
|
386
384
|
extend_with_functions_module
|
387
385
|
|
@@ -875,8 +873,8 @@ class Puppet::Parser::Scope
|
|
875
873
|
return "Scope(#{@resource})" unless @resource.nil?
|
876
874
|
|
877
875
|
# For logging of function-scope - it is now showing the file and line.
|
878
|
-
detail = Puppet::Pops::PuppetStack.
|
879
|
-
return "Scope()"
|
876
|
+
detail = Puppet::Pops::PuppetStack.top_of_stack
|
877
|
+
return "Scope()" if detail.empty?
|
880
878
|
|
881
879
|
# shorten the path if possible
|
882
880
|
path = detail[0]
|
@@ -23,7 +23,7 @@ class CompareOperator
|
|
23
23
|
@@include_visitor ||= Visitor.new(self, "include", 2, 2)
|
24
24
|
end
|
25
25
|
|
26
|
-
def equals
|
26
|
+
def equals(a, b)
|
27
27
|
@@equals_visitor.visit_this_1(self, a, b)
|
28
28
|
end
|
29
29
|
|
@@ -59,6 +59,8 @@ class CompareOperator
|
|
59
59
|
def cmp_Numeric(a, b)
|
60
60
|
if b.is_a?(Numeric)
|
61
61
|
a <=> b
|
62
|
+
elsif b.is_a?(Time::Timespan) || b.is_a?(Time::Timestamp)
|
63
|
+
-(b <=> a) # compare other way and invert result
|
62
64
|
else
|
63
65
|
raise ArgumentError.new(_("A Numeric is not comparable to non Numeric"))
|
64
66
|
end
|
@@ -55,13 +55,8 @@ module Runtime3Support
|
|
55
55
|
#
|
56
56
|
def runtime_issue(issue, options={})
|
57
57
|
# Get position from puppet runtime stack
|
58
|
-
|
59
|
-
|
60
|
-
file, line = stacktrace[0]
|
61
|
-
else
|
62
|
-
file = nil
|
63
|
-
line = nil
|
64
|
-
end
|
58
|
+
file, line = Puppet::Pops::PuppetStack.top_of_stack
|
59
|
+
|
65
60
|
# Use a SemanticError as the sourcepos
|
66
61
|
semantic = Puppet::Pops::SemanticError.new(issue, nil, options.merge({:file => file, :line => line}))
|
67
62
|
optionally_fail(issue, semantic)
|
@@ -486,6 +486,10 @@ module Issues
|
|
486
486
|
_("Unacceptable name. The name '%{name}' is unacceptable as the name of %{value}") % { name: name, value: label.a_an(semantic) }
|
487
487
|
end
|
488
488
|
|
489
|
+
ILLEGAL_DEFINITION_LOCATION = issue :ILLEGAL_DEFINITION_LOCATION, :name, :file do
|
490
|
+
_("Unacceptable location. The name '%{name}' is unacceptable in file '%{file}'") % { name: name, file: file }
|
491
|
+
end
|
492
|
+
|
489
493
|
CAPTURES_REST_NOT_LAST = hard_issue :CAPTURES_REST_NOT_LAST, :param_name do
|
490
494
|
_("Parameter $%{param} is not last, and has 'captures rest'") % { param: param_name }
|
491
495
|
end
|
@@ -67,7 +67,7 @@ module LoaderPaths
|
|
67
67
|
@generic_path = (the_root_path.nil? ? relative_path : File.join(the_root_path, relative_path))
|
68
68
|
end
|
69
69
|
|
70
|
-
def
|
70
|
+
def fuzzy_matching?
|
71
71
|
false
|
72
72
|
end
|
73
73
|
|
@@ -239,7 +239,7 @@ module LoaderPaths
|
|
239
239
|
EMPTY_STRING
|
240
240
|
end
|
241
241
|
|
242
|
-
def
|
242
|
+
def fuzzy_matching?
|
243
243
|
true
|
244
244
|
end
|
245
245
|
|
@@ -291,13 +291,12 @@ module ModuleLoaders
|
|
291
291
|
raise NotImplementedError.new
|
292
292
|
end
|
293
293
|
|
294
|
-
# Abstract method that subclasses override to return an array of paths that
|
295
|
-
# path extension.
|
294
|
+
# Abstract method that subclasses override to return an array of paths that may be associated with the resolved path.
|
296
295
|
#
|
297
296
|
# @param resolved_path [String] a path, without extension, resolved by a smart path against the loader's root (if it has one)
|
298
297
|
# @return [Array<String>]
|
299
298
|
#
|
300
|
-
def
|
299
|
+
def candidate_paths(resolved_path)
|
301
300
|
raise NotImplementedError.new
|
302
301
|
end
|
303
302
|
|
@@ -386,9 +385,9 @@ module ModuleLoaders
|
|
386
385
|
next unless sp.valid_name?(typed_name)
|
387
386
|
origin = sp.effective_path(typed_name, is_global ? 0 : 1)
|
388
387
|
unless origin.nil?
|
389
|
-
if sp.
|
390
|
-
# Find all paths that
|
391
|
-
origins =
|
388
|
+
if sp.fuzzy_matching?
|
389
|
+
# Find all paths that might be related to origin
|
390
|
+
origins = candidate_paths(origin)
|
392
391
|
return [origins, sp] unless origins.empty?
|
393
392
|
else
|
394
393
|
existing = existing_path(origin)
|
@@ -424,13 +423,19 @@ module ModuleLoaders
|
|
424
423
|
@path_index.include?(effective_path) ? effective_path : nil
|
425
424
|
end
|
426
425
|
|
427
|
-
def
|
426
|
+
def candidate_paths(effective_path)
|
427
|
+
basename = File.basename(effective_path, '.*')
|
428
428
|
dirname = File.dirname(effective_path)
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
429
|
+
|
430
|
+
files = @path_index.select do |path|
|
431
|
+
File.dirname(path) == dirname
|
432
|
+
end
|
433
|
+
|
434
|
+
# At least one file has to match what we're loading, or it certainly doesn't exist
|
435
|
+
if files.any? { |file| File.basename(file, '.*') == basename }
|
436
|
+
files
|
437
|
+
else
|
438
|
+
[]
|
434
439
|
end
|
435
440
|
end
|
436
441
|
|
@@ -3,66 +3,94 @@
|
|
3
3
|
module Puppet::Pops
|
4
4
|
module Loader
|
5
5
|
class TaskInstantiator
|
6
|
-
def self.
|
7
|
-
name = typed_name.name
|
8
|
-
metadata = nil
|
9
|
-
task_source = nil
|
10
|
-
source_refs.each do |source_ref|
|
11
|
-
if source_ref.end_with?('.json')
|
12
|
-
metadata = source_ref
|
13
|
-
elsif task_source.nil?
|
14
|
-
task_source = source_ref
|
15
|
-
else
|
16
|
-
raise ArgumentError, _('Only one file can exists besides the .json file for task %{name} in directory %{directory}') %
|
17
|
-
{ name: name, directory: File.dirname(source_refs[0]) }
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
if task_source.nil?
|
22
|
-
raise ArgumentError, _('No source besides task metadata was found in directory %{directory} for task %{name}') %
|
23
|
-
{ name: name, directory: File.dirname(source_refs[0]) }
|
24
|
-
end
|
25
|
-
create_task(loader, name, task_source, metadata)
|
26
|
-
end
|
27
|
-
|
28
|
-
def self.create_task(loader, name, task_source, metadata)
|
6
|
+
def self.load_metadata(loader, metadata)
|
29
7
|
if metadata.nil?
|
30
|
-
|
8
|
+
EMPTY_HASH
|
31
9
|
else
|
32
10
|
json_text = loader.get_contents(metadata)
|
33
11
|
begin
|
34
|
-
|
35
|
-
rescue
|
12
|
+
Puppet::Util::Json.load(json_text).freeze || EMPTY_HASH
|
13
|
+
rescue Puppet::Util::Json::ParseError => ex
|
36
14
|
raise Puppet::ParseError.new(ex.message, metadata)
|
37
|
-
rescue Types::TypeAssertionError => ex
|
38
|
-
# Not strictly a parser error but from the users perspective, the file content didn't parse properly. The
|
39
|
-
# ParserError also conveys file info (even though line is unknown)
|
40
|
-
msg = _('Failed to load metadata for task %{name}: %{reason}') % { :name => name, :reason => ex.message }
|
41
|
-
raise Puppet::ParseError.new(msg, metadata)
|
42
15
|
end
|
43
16
|
end
|
44
17
|
end
|
45
18
|
|
46
|
-
def self.
|
19
|
+
def self.validate_implementations(typed_name, directory, metadata, executables)
|
20
|
+
name = typed_name.name
|
21
|
+
basename = typed_name.name_parts[1] || 'init'
|
22
|
+
# If 'implementations' is defined, it needs to mention at least one
|
23
|
+
# implementation, and everything it mentions must exist.
|
24
|
+
if metadata.key?('implementations')
|
25
|
+
if metadata['implementations'].is_a?(Array)
|
26
|
+
metadata['implementations'].map do |impl|
|
27
|
+
path = executables.find { |real_impl| File.basename(real_impl) == impl['name'] }
|
28
|
+
if path
|
29
|
+
{ "name" => impl['name'], "requirements" => impl.fetch('requirements', []), "path" => path }
|
30
|
+
else
|
31
|
+
raise ArgumentError, _("Task metadata for task %{name} specifies missing implementation %{implementation}") %
|
32
|
+
{ name: name, implementation: impl['name'] }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
else
|
36
|
+
# If 'implementations' is the wrong type, we just pass it through and
|
37
|
+
# let the task type definition reject it.
|
38
|
+
metadata['implementations']
|
39
|
+
end
|
40
|
+
# If implementations isn't defined, then we use executables matching the
|
41
|
+
# task name, and only one may exist.
|
42
|
+
else
|
43
|
+
implementations = executables.select { |impl| File.basename(impl, '.*') == basename }
|
44
|
+
if implementations.empty?
|
45
|
+
raise ArgumentError, _('No source besides task metadata was found in directory %{directory} for task %{name}') %
|
46
|
+
{ name: name, directory: directory }
|
47
|
+
elsif implementations.length > 1
|
48
|
+
raise ArgumentError, _("Multiple executables were found in directory %{directory} for task %{name}; define 'implementations' in metadata to differentiate between them") %
|
49
|
+
{ name: name, directory: implementations[0] }
|
50
|
+
end
|
51
|
+
|
52
|
+
[{ "name" => File.basename(implementations.first), "path" => implementations.first, "requirements" => [] }]
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.create(loader, typed_name, source_refs)
|
57
|
+
name = typed_name.name
|
58
|
+
basename = typed_name.name_parts[1] || 'init'
|
59
|
+
dirname = File.dirname(source_refs[0])
|
60
|
+
metadata_files, executables = source_refs.partition { |source_ref| source_ref.end_with?('.json') }
|
61
|
+
metadata_file = metadata_files.find { |source_ref| File.basename(source_ref, '.json') == basename }
|
62
|
+
|
63
|
+
metadata = load_metadata(loader, metadata_file)
|
64
|
+
|
65
|
+
implementation_metadata = validate_implementations(typed_name, dirname, metadata, executables)
|
66
|
+
|
47
67
|
arguments = {
|
48
68
|
'name' => name,
|
49
|
-
'
|
69
|
+
'implementations' => implementation_metadata
|
50
70
|
}
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
71
|
+
|
72
|
+
begin
|
73
|
+
metadata.each_pair do |key, value|
|
74
|
+
if %w[parameters output].include?(key)
|
75
|
+
ps = {}
|
76
|
+
value.each_pair do |k, v|
|
77
|
+
pd = v.dup
|
78
|
+
t = v['type']
|
79
|
+
pd['type'] = t.nil? ? Types::TypeFactory.data : Types::TypeParser.singleton.parse(t)
|
80
|
+
ps[k] = pd
|
81
|
+
end
|
82
|
+
value = ps
|
59
83
|
end
|
60
|
-
|
84
|
+
arguments[key] = value unless arguments.key?(key)
|
61
85
|
end
|
62
|
-
arguments[key] = value
|
63
|
-
end
|
64
86
|
|
65
|
-
|
87
|
+
Types::TypeFactory.task.from_hash(arguments)
|
88
|
+
rescue Types::TypeAssertionError => ex
|
89
|
+
# Not strictly a parser error but from the users perspective, the file content didn't parse properly. The
|
90
|
+
# ParserError also conveys file info (even though line is unknown)
|
91
|
+
msg = _('Failed to load metadata for task %{name}: %{reason}') % { name: name, reason: ex.message }
|
92
|
+
raise Puppet::ParseError.new(msg, metadata_file)
|
93
|
+
end
|
66
94
|
end
|
67
95
|
end
|
68
96
|
end
|