openvox 9.0.0.pre.alpha2 → 9.0.0.pre.beta2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +114 -1
- data/CODE_OF_CONDUCT.md +1 -1
- data/Gemfile +5 -5
- data/README.md +6 -6
- data/Rakefile +3 -3
- data/conf/environment.conf +2 -2
- data/conf/fileserver.conf +3 -3
- data/conf/puppet.conf +4 -4
- data/examples/enc/regexp_nodes/regexp_nodes.rb +2 -2
- data/examples/hiera/README.md +1 -1
- data/examples/nagios/check_puppet.rb +1 -1
- data/ext/README.md +3 -3
- data/ext/hiera/hiera.yaml +1 -1
- data/ext/project_data.yaml +1 -1
- data/ext/redhat/client.sysconfig +1 -0
- data/ext/solaris/smf/puppet.xml +2 -2
- data/ext/windows/puppet_interactive.bat +1 -1
- data/ext/windows/service/daemon.rb +5 -5
- data/lib/hiera/puppet_function.rb +1 -2
- data/lib/hiera_puppet.rb +1 -1
- data/lib/puppet/agent/disabler.rb +3 -3
- data/lib/puppet/agent/locker.rb +1 -1
- data/lib/puppet/agent.rb +2 -2
- data/lib/puppet/application/agent.rb +33 -35
- data/lib/puppet/application/apply.rb +7 -7
- data/lib/puppet/application/describe.rb +3 -3
- data/lib/puppet/application/device.rb +1 -1
- data/lib/puppet/application/doc.rb +5 -7
- data/lib/puppet/application/facts.rb +1 -1
- data/lib/puppet/application/filebucket.rb +5 -5
- data/lib/puppet/application/lookup.rb +8 -8
- data/lib/puppet/application/resource.rb +5 -5
- data/lib/puppet/application/script.rb +3 -3
- data/lib/puppet/application/ssl.rb +4 -4
- data/lib/puppet/application_support.rb +2 -2
- data/lib/puppet/configurer.rb +13 -7
- data/lib/puppet/confine/variable.rb +2 -2
- data/lib/puppet/context.rb +1 -1
- data/lib/puppet/data_binding.rb +1 -1
- data/lib/puppet/defaults.rb +157 -226
- data/lib/puppet/error.rb +1 -1
- data/lib/puppet/etc.rb +4 -4
- data/lib/puppet/face/catalog/select.rb +3 -3
- data/lib/puppet/face/catalog.rb +4 -4
- data/lib/puppet/face/config.rb +6 -6
- data/lib/puppet/face/facts.rb +6 -6
- data/lib/puppet/face/help/man.erb +3 -3
- data/lib/puppet/face/node/clean.rb +3 -3
- data/lib/puppet/face/node.rb +2 -2
- data/lib/puppet/face/plugin.rb +4 -4
- data/lib/puppet/functions/all.rb +4 -4
- data/lib/puppet/functions/any.rb +4 -4
- data/lib/puppet/functions/assert_type.rb +5 -5
- data/lib/puppet/functions/defined.rb +1 -1
- data/lib/puppet/functions/each.rb +11 -11
- data/lib/puppet/functions/epp.rb +5 -5
- data/lib/puppet/functions/eyaml_lookup_key.rb +1 -1
- data/lib/puppet/functions/filter.rb +5 -5
- data/lib/puppet/functions/find_file.rb +1 -1
- data/lib/puppet/functions/hiera.rb +4 -4
- data/lib/puppet/functions/hiera_array.rb +5 -5
- data/lib/puppet/functions/hiera_hash.rb +5 -5
- data/lib/puppet/functions/hiera_include.rb +6 -6
- data/lib/puppet/functions/hocon_data.rb +1 -1
- data/lib/puppet/functions/include.rb +1 -1
- data/lib/puppet/functions/index.rb +3 -3
- data/lib/puppet/functions/inline_epp.rb +6 -6
- data/lib/puppet/functions/json_data.rb +1 -1
- data/lib/puppet/functions/lest.rb +1 -1
- data/lib/puppet/functions/lookup.rb +14 -14
- data/lib/puppet/functions/map.rb +5 -5
- data/lib/puppet/functions/reduce.rb +6 -6
- data/lib/puppet/functions/regsubst.rb +1 -13
- data/lib/puppet/functions/reverse_each.rb +5 -5
- data/lib/puppet/functions/scanf.rb +1 -1
- data/lib/puppet/functions/step.rb +5 -5
- data/lib/puppet/functions/then.rb +1 -1
- data/lib/puppet/functions/tree_each.rb +3 -3
- data/lib/puppet/functions/versioncmp.rb +1 -1
- data/lib/puppet/functions/with.rb +2 -2
- data/lib/puppet/functions/yaml_data.rb +1 -1
- data/lib/puppet/generate/type.rb +5 -1
- data/lib/puppet/gettext/config.rb +5 -5
- data/lib/puppet/gettext/module_translations.rb +1 -1
- data/lib/puppet/graph/simple_graph.rb +0 -1
- data/lib/puppet/http/client.rb +5 -5
- data/lib/puppet/http/factory.rb +1 -1
- data/lib/puppet/http/resolver/server_list.rb +2 -2
- data/lib/puppet/http/service/compiler.rb +3 -3
- data/lib/puppet/http/service/file_server.rb +1 -1
- data/lib/puppet/http/service.rb +19 -1
- data/lib/puppet/http/session.rb +1 -1
- data/lib/puppet/http.rb +1 -1
- data/lib/puppet/indirector/catalog/compiler.rb +2 -2
- data/lib/puppet/indirector/data_binding/hiera.rb +93 -2
- data/lib/puppet/indirector/face.rb +4 -4
- data/lib/puppet/indirector/facts/facter.rb +7 -7
- data/lib/puppet/indirector/file_bucket_file/file.rb +2 -2
- data/lib/puppet/indirector/file_bucket_file/rest.rb +7 -3
- data/lib/puppet/indirector/file_content/file_server.rb +1 -1
- data/lib/puppet/indirector/file_metadata/file_server.rb +1 -1
- data/lib/puppet/indirector/node/exec.rb +1 -1
- data/lib/puppet/indirector/node/rest.rb +1 -1
- data/lib/puppet/indirector/report/processor.rb +1 -1
- data/lib/puppet/indirector.rb +1 -1
- data/lib/puppet/interface/documentation.rb +1 -1
- data/lib/puppet/interface/face_collection.rb +1 -1
- data/lib/puppet/interface/option.rb +2 -2
- data/lib/puppet/module/task.rb +1 -1
- data/lib/puppet/module_tool/applications/application.rb +1 -1
- data/lib/puppet/module_tool/metadata.rb +1 -2
- data/lib/puppet/module_tool.rb +1 -1
- data/lib/puppet/network/authorization.rb +1 -1
- data/lib/puppet/network/http/api.rb +2 -2
- data/lib/puppet/network/http/connection.rb +2 -2
- data/lib/puppet/node/environment.rb +6 -6
- data/lib/puppet/node.rb +2 -2
- data/lib/puppet/pal/catalog_compiler.rb +1 -1
- data/lib/puppet/pal/pal_impl.rb +1 -25
- data/lib/puppet/parser/compiler.rb +1 -1
- data/lib/puppet/parser/functions/assert_type.rb +5 -5
- data/lib/puppet/parser/functions/create_resources.rb +1 -1
- data/lib/puppet/parser/functions/defined.rb +1 -1
- data/lib/puppet/parser/functions/digest.rb +1 -1
- data/lib/puppet/parser/functions/each.rb +11 -11
- data/lib/puppet/parser/functions/epp.rb +5 -5
- data/lib/puppet/parser/functions/filter.rb +5 -5
- data/lib/puppet/parser/functions/generate.rb +1 -1
- data/lib/puppet/parser/functions/hiera.rb +3 -3
- data/lib/puppet/parser/functions/hiera_array.rb +4 -4
- data/lib/puppet/parser/functions/hiera_hash.rb +4 -4
- data/lib/puppet/parser/functions/hiera_include.rb +5 -5
- data/lib/puppet/parser/functions/include.rb +1 -1
- data/lib/puppet/parser/functions/inline_epp.rb +6 -6
- data/lib/puppet/parser/functions/inline_template.rb +1 -1
- data/lib/puppet/parser/functions/lest.rb +1 -1
- data/lib/puppet/parser/functions/lookup.rb +14 -14
- data/lib/puppet/parser/functions/map.rb +5 -5
- data/lib/puppet/parser/functions/reduce.rb +7 -7
- data/lib/puppet/parser/functions/reverse_each.rb +5 -5
- data/lib/puppet/parser/functions/scanf.rb +1 -1
- data/lib/puppet/parser/functions/step.rb +5 -5
- data/lib/puppet/parser/functions/then.rb +1 -1
- data/lib/puppet/parser/functions/versioncmp.rb +1 -1
- data/lib/puppet/parser/functions/with.rb +1 -1
- data/lib/puppet/parser/functions.rb +3 -3
- data/lib/puppet/parser/scope.rb +1 -1
- data/lib/puppet/plugins/syntax_checkers.rb +2 -2
- data/lib/puppet/plugins.rb +1 -1
- data/lib/puppet/pops/evaluator/collectors/exported_collector.rb +1 -1
- data/lib/puppet/pops/evaluator/deferred_resolver.rb +4 -1
- data/lib/puppet/pops/issues.rb +3 -3
- data/lib/puppet/pops/loader/module_loaders.rb +4 -4
- data/lib/puppet/pops/loader/ruby_legacy_function_instantiator.rb +1 -1
- data/lib/puppet/pops/loaders.rb +4 -4
- data/lib/puppet/pops/lookup/lookup_adapter.rb +7 -66
- data/lib/puppet/pops/model/factory.rb +5 -5
- data/lib/puppet/pops/resource/resource_type_impl.rb +1 -1
- data/lib/puppet/pops/serialization/to_data_converter.rb +1 -1
- data/lib/puppet/pops/types/iterable.rb +1 -1
- data/lib/puppet/property/keyvalue.rb +3 -3
- data/lib/puppet/provider/group/aix.rb +2 -2
- data/lib/puppet/provider/nameservice/directoryservice.rb +2 -2
- data/lib/puppet/provider/package/aix.rb +1 -1
- data/lib/puppet/provider/package/apt.rb +2 -2
- data/lib/puppet/provider/package/aptitude.rb +0 -1
- data/lib/puppet/provider/package/dnfmodule.rb +1 -1
- data/lib/puppet/provider/package/nim.rb +1 -1
- data/lib/puppet/provider/package/pacman.rb +1 -2
- data/lib/puppet/provider/package/pip.rb +1 -1
- data/lib/puppet/provider/package/pip2.rb +1 -1
- data/lib/puppet/provider/package/pip3.rb +1 -1
- data/lib/puppet/provider/package/pkgdmg.rb +2 -2
- data/lib/puppet/provider/package/puppet_gem.rb +2 -2
- data/lib/puppet/provider/package/puppetserver_gem.rb +1 -1
- data/lib/puppet/provider/package/windows.rb +1 -1
- data/lib/puppet/provider/service/freebsd.rb +1 -1
- data/lib/puppet/provider/service/init.rb +5 -5
- data/lib/puppet/provider/service/launchd.rb +2 -2
- data/lib/puppet/provider/service/smf.rb +1 -1
- data/lib/puppet/provider/service/upstart.rb +2 -2
- data/lib/puppet/provider/user/aix.rb +3 -3
- data/lib/puppet/provider/user/directoryservice.rb +9 -9
- data/lib/puppet/provider/user/pw.rb +3 -3
- data/lib/puppet/provider.rb +1 -1
- data/lib/puppet/reference/configuration.rb +6 -13
- data/lib/puppet/reference/function.rb +4 -4
- data/lib/puppet/reference/indirection.rb +2 -2
- data/lib/puppet/reference/metaparameter.rb +3 -3
- data/lib/puppet/reference/providers.rb +3 -3
- data/lib/puppet/reference/report.rb +4 -4
- data/lib/puppet/reference/type.rb +2 -2
- data/lib/puppet/relationship.rb +1 -1
- data/lib/puppet/reports/http.rb +4 -4
- data/lib/puppet/reports.rb +1 -1
- data/lib/puppet/resource/catalog.rb +4 -4
- data/lib/puppet/resource/type.rb +8 -8
- data/lib/puppet/settings/base_setting.rb +2 -3
- data/lib/puppet/settings/config_file.rb +3 -3
- data/lib/puppet/settings/environment_conf.rb +3 -11
- data/lib/puppet/settings.rb +11 -51
- data/lib/puppet/ssl/certificate.rb +4 -0
- data/lib/puppet/ssl/certificate_request.rb +1 -1
- data/lib/puppet/ssl/oids.rb +1 -1
- data/lib/puppet/ssl/openssl_loader.rb +1 -1
- data/lib/puppet/ssl/ssl_provider.rb +5 -5
- data/lib/puppet/ssl/state_machine.rb +9 -3
- data/lib/puppet/syntax_checkers.rb +1 -1
- data/lib/puppet/transaction/report.rb +3 -3
- data/lib/puppet/transaction.rb +0 -1
- data/lib/puppet/type/exec.rb +20 -20
- data/lib/puppet/type/file/content.rb +10 -37
- data/lib/puppet/type/file/ensure.rb +18 -9
- data/lib/puppet/type/file/mode.rb +4 -4
- data/lib/puppet/type/file/selcontext.rb +2 -2
- data/lib/puppet/type/file/source.rb +19 -25
- data/lib/puppet/type/file.rb +22 -15
- data/lib/puppet/type/filebucket.rb +22 -8
- data/lib/puppet/type/group.rb +5 -5
- data/lib/puppet/type/notify.rb +1 -1
- data/lib/puppet/type/package.rb +4 -4
- data/lib/puppet/type/schedule.rb +11 -11
- data/lib/puppet/type/service.rb +8 -8
- data/lib/puppet/type/stage.rb +1 -1
- data/lib/puppet/type/user.rb +19 -21
- data/lib/puppet/type/whit.rb +2 -2
- data/lib/puppet/type.rb +27 -27
- data/lib/puppet/util/character_encoding.rb +3 -3
- data/lib/puppet/util/command_line.rb +1 -1
- data/lib/puppet/util/execution.rb +1 -1
- data/lib/puppet/util/filetype.rb +6 -6
- data/lib/puppet/util/log.rb +2 -2
- data/lib/puppet/util/logging.rb +3 -3
- data/lib/puppet/util/plist.rb +1 -1
- data/lib/puppet/util/profiler/around_profiler.rb +1 -1
- data/lib/puppet/util/profiler.rb +1 -1
- data/lib/puppet/util/rdoc.rb +6 -3
- data/lib/puppet/util/selinux.rb +5 -5
- data/lib/puppet/util/tag_set.rb +0 -1
- data/lib/puppet/util/windows/adsi.rb +1 -1
- data/lib/puppet/util/windows/com.rb +2 -2
- data/lib/puppet/util/windows/eventlog.rb +6 -6
- data/lib/puppet/util/windows/file.rb +2 -2
- data/lib/puppet/util/windows/security.rb +3 -3
- data/lib/puppet/util.rb +8 -3
- data/lib/puppet/version.rb +8 -8
- data/lib/puppet/x509/cert_provider.rb +1 -1
- data/lib/puppet.rb +5 -5
- data/locales/config.yaml +3 -3
- data/locales/puppet.pot +462 -464
- data/man/man5/puppet.conf.5 +122 -146
- data/man/man8/puppet-agent.8 +25 -25
- data/man/man8/puppet-apply.8 +6 -6
- data/man/man8/puppet-catalog.8 +11 -11
- data/man/man8/puppet-config.8 +7 -7
- data/man/man8/puppet-describe.8 +3 -3
- data/man/man8/puppet-device.8 +2 -2
- data/man/man8/puppet-doc.8 +5 -5
- data/man/man8/puppet-epp.8 +3 -3
- data/man/man8/puppet-facts.8 +11 -11
- data/man/man8/puppet-filebucket.8 +5 -5
- data/man/man8/puppet-generate.8 +3 -3
- data/man/man8/puppet-help.8 +3 -3
- data/man/man8/puppet-lookup.8 +8 -8
- data/man/man8/puppet-module.8 +7 -7
- data/man/man8/puppet-node.8 +11 -45
- data/man/man8/puppet-parser.8 +3 -3
- data/man/man8/puppet-plugin.8 +7 -7
- data/man/man8/puppet-report.8 +6 -6
- data/man/man8/puppet-resource.8 +5 -5
- data/man/man8/puppet-script.8 +3 -3
- data/man/man8/puppet-ssl.8 +21 -23
- data/man/man8/puppet.8 +2 -2
- metadata +5 -8
- data/lib/puppet/indirector/hiera.rb +0 -101
- data/lib/puppet/util/rdoc/generators/puppet_generator.rb +0 -902
- data/lib/puppet/util/rdoc/generators/template/puppet/puppet.rb +0 -1068
|
@@ -6,9 +6,9 @@ Puppet::Parser::Functions.newfunction(
|
|
|
6
6
|
:arity => -3,
|
|
7
7
|
:doc => <<~DOC
|
|
8
8
|
Returns the given value if it is of the given
|
|
9
|
-
[data type](https://
|
|
9
|
+
[data type](https://docs.openvoxproject.org/openvox/latest/lang_data.html), or
|
|
10
10
|
otherwise either raises an error or executes an optional two-parameter
|
|
11
|
-
[lambda](https://
|
|
11
|
+
[lambda](https://docs.openvoxproject.org/openvox/latest/lang_lambdas.html).
|
|
12
12
|
|
|
13
13
|
The function takes two mandatory arguments, in this order:
|
|
14
14
|
|
|
@@ -24,7 +24,7 @@ Puppet::Parser::Functions.newfunction(
|
|
|
24
24
|
$valid_username = assert_type(String[1], $raw_username)
|
|
25
25
|
|
|
26
26
|
# $valid_username contains "Amy Berry".
|
|
27
|
-
# If $raw_username was an empty string or a different data type, the
|
|
27
|
+
# If $raw_username was an empty string or a different data type, the OpenVox run would
|
|
28
28
|
# fail with an "Expected type does not match actual" error.
|
|
29
29
|
~~~
|
|
30
30
|
|
|
@@ -47,13 +47,13 @@ Puppet::Parser::Functions.newfunction(
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
# $valid_username contains "Amy Berry".
|
|
50
|
-
# If $raw_username was an empty string, the
|
|
50
|
+
# If $raw_username was an empty string, the OpenVox run would set $valid_username to
|
|
51
51
|
# "anonymous" and output a warning: "The username should be 'String[1, default]', not
|
|
52
52
|
# 'String[0, 0]'. Using 'anonymous'."
|
|
53
53
|
~~~
|
|
54
54
|
|
|
55
55
|
For more information about data types, see the
|
|
56
|
-
[documentation](https://
|
|
56
|
+
[documentation](https://docs.openvoxproject.org/openvox/latest/lang_data.html).
|
|
57
57
|
|
|
58
58
|
- Since 4.0.0
|
|
59
59
|
DOC
|
|
@@ -4,7 +4,7 @@ Puppet::Parser::Functions.newfunction(:create_resources, :arity => -3, :doc => <
|
|
|
4
4
|
Converts a hash into a set of resources and adds them to the catalog.
|
|
5
5
|
|
|
6
6
|
**Note**: Use this function selectively. It's generally better to write resources in
|
|
7
|
-
[Puppet](https://
|
|
7
|
+
[Puppet](https://docs.openvoxproject.org/openvox/latest/lang_resources.html), as
|
|
8
8
|
resources created with `create_resource` are difficult to read and troubleshoot.
|
|
9
9
|
|
|
10
10
|
This function takes two mandatory arguments: a resource type, and a hash describing
|
|
@@ -35,7 +35,7 @@ Puppet::Parser::Functions.newfunction(
|
|
|
35
35
|
defined(File['/tmp/file'])
|
|
36
36
|
~~~
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
OpenVox depends on the configuration's evaluation order when checking whether a resource
|
|
39
39
|
is declared.
|
|
40
40
|
|
|
41
41
|
**Example**: Importance of evaluation order when using `defined`
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require_relative '../../../puppet/util/checksums'
|
|
4
|
-
Puppet::Parser::Functions.newfunction(:digest, :type => :rvalue, :arity => 1, :doc => "Returns a hash value from a provided string using the digest_algorithm setting from the
|
|
4
|
+
Puppet::Parser::Functions.newfunction(:digest, :type => :rvalue, :arity => 1, :doc => "Returns a hash value from a provided string using the digest_algorithm setting from the OpenVox config file.") do |args|
|
|
5
5
|
algo = Puppet[:digest_algorithm]
|
|
6
6
|
Puppet::Util::Checksums.method(algo.intern).call args[0]
|
|
7
7
|
end
|
|
@@ -5,7 +5,7 @@ Puppet::Parser::Functions.newfunction(
|
|
|
5
5
|
:type => :rvalue,
|
|
6
6
|
:arity => -3,
|
|
7
7
|
:doc => <<~DOC
|
|
8
|
-
Runs a [lambda](https://
|
|
8
|
+
Runs a [lambda](https://docs.openvoxproject.org/openvox/latest/lang_lambdas.html)
|
|
9
9
|
repeatedly using each value in a data structure, then returns the values unchanged.
|
|
10
10
|
|
|
11
11
|
This function takes two mandatory arguments, in this order:
|
|
@@ -22,7 +22,7 @@ Puppet::Parser::Functions.newfunction(
|
|
|
22
22
|
|
|
23
23
|
`each($data) |$parameter| { <PUPPET CODE BLOCK> }`
|
|
24
24
|
|
|
25
|
-
When the first argument (`$data` in the above example) is an array,
|
|
25
|
+
When the first argument (`$data` in the above example) is an array, OpenVox passes each
|
|
26
26
|
value in turn to the lambda, then returns the original values.
|
|
27
27
|
|
|
28
28
|
**Example**: Using the `each` function with an array and a one-parameter lambda
|
|
@@ -35,11 +35,11 @@ Puppet::Parser::Functions.newfunction(
|
|
|
35
35
|
message => $item
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
#
|
|
38
|
+
# OpenVox creates one resource for each of the three items in $data. Each resource is
|
|
39
39
|
# named after the item's value and uses the item's value in a parameter.
|
|
40
40
|
~~~
|
|
41
41
|
|
|
42
|
-
When the first argument is a hash,
|
|
42
|
+
When the first argument is a hash, OpenVox passes each key and value pair to the lambda
|
|
43
43
|
as an array in the form `[key, value]` and returns the original hash.
|
|
44
44
|
|
|
45
45
|
**Example**: Using the `each` function with a hash and a one-parameter lambda
|
|
@@ -53,11 +53,11 @@ Puppet::Parser::Functions.newfunction(
|
|
|
53
53
|
message => $items[1]
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
|
-
#
|
|
56
|
+
# OpenVox creates one resource for each of the three items in $data, each named after the
|
|
57
57
|
# item's key and containing a parameter using the item's value.
|
|
58
58
|
~~~
|
|
59
59
|
|
|
60
|
-
When the first argument is an array and the lambda has two parameters,
|
|
60
|
+
When the first argument is an array and the lambda has two parameters, OpenVox passes the
|
|
61
61
|
array's indexes (enumerated from 0) in the first parameter and its values in the second
|
|
62
62
|
parameter.
|
|
63
63
|
|
|
@@ -72,11 +72,11 @@ Puppet::Parser::Functions.newfunction(
|
|
|
72
72
|
message => $index
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
|
-
#
|
|
75
|
+
# OpenVox creates one resource for each of the three items in $data, each named after the
|
|
76
76
|
# item's value and containing a parameter using the item's index.
|
|
77
77
|
~~~
|
|
78
78
|
|
|
79
|
-
When the first argument is a hash,
|
|
79
|
+
When the first argument is a hash, OpenVox passes its keys to the first parameter and its
|
|
80
80
|
values to the second parameter.
|
|
81
81
|
|
|
82
82
|
**Example**: Using the `each` function with a hash and a two-parameter lambda
|
|
@@ -90,13 +90,13 @@ Puppet::Parser::Functions.newfunction(
|
|
|
90
90
|
message => $value
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
|
-
#
|
|
93
|
+
# OpenVox creates one resource for each of the three items in $data, each named after the
|
|
94
94
|
# item's key and containing a parameter using the item's value.
|
|
95
95
|
~~~
|
|
96
96
|
|
|
97
97
|
For an example that demonstrates how to create multiple `file` resources using `each`,
|
|
98
|
-
see the
|
|
99
|
-
[iteration](https://
|
|
98
|
+
see the OpenVox
|
|
99
|
+
[iteration](https://docs.openvoxproject.org/openvox/latest/lang_iteration.html)
|
|
100
100
|
documentation.
|
|
101
101
|
|
|
102
102
|
- Since 4.0.0
|
|
@@ -9,12 +9,12 @@ result as a String.
|
|
|
9
9
|
The first argument to this function should be a `<MODULE NAME>/<TEMPLATE FILE>`
|
|
10
10
|
reference, which loads `<TEMPLATE FILE>` from `<MODULE NAME>`'s `templates`
|
|
11
11
|
directory. In most cases, the last argument is optional; if used, it should be a
|
|
12
|
-
[hash](https://
|
|
12
|
+
[hash](https://docs.openvoxproject.org/openvox/latest/lang_data_hash.html) that contains parameters to
|
|
13
13
|
pass to the template.
|
|
14
14
|
|
|
15
|
-
- See the [template](https://
|
|
15
|
+
- See the [template](https://docs.openvoxproject.org/openvox/latest/lang_template.html) documentation
|
|
16
16
|
for general template usage information.
|
|
17
|
-
- See the [EPP syntax](https://
|
|
17
|
+
- See the [EPP syntax](https://docs.openvoxproject.org/openvox/latest/lang_template_epp.html)
|
|
18
18
|
documentation for examples of EPP.
|
|
19
19
|
|
|
20
20
|
For example, to call the apache module's `templates/vhost/_docroot.epp`
|
|
@@ -27,12 +27,12 @@ function like this:
|
|
|
27
27
|
This function can also accept an absolute path, which can load a template file
|
|
28
28
|
from anywhere on disk.
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
OpenVox produces a syntax error if you pass more parameters than are declared in
|
|
31
31
|
the template's parameter tag. When passing parameters to a template that
|
|
32
32
|
contains a parameter tag, use the same names as the tag's declared parameters.
|
|
33
33
|
|
|
34
34
|
Parameters are required only if they are declared in the called template's
|
|
35
|
-
parameter tag without default values.
|
|
35
|
+
parameter tag without default values. OpenVox produces an error if the `epp`
|
|
36
36
|
function fails to pass any required parameter.
|
|
37
37
|
|
|
38
38
|
- Since 4.0.0") do |_args|
|
|
@@ -5,7 +5,7 @@ Puppet::Parser::Functions.newfunction(
|
|
|
5
5
|
:type => :rvalue,
|
|
6
6
|
:arity => -3,
|
|
7
7
|
:doc => <<~DOC
|
|
8
|
-
Applies a [lambda](https://
|
|
8
|
+
Applies a [lambda](https://docs.openvoxproject.org/openvox/latest/lang_lambdas.html)
|
|
9
9
|
to every value in a data structure and returns an array or hash containing any elements
|
|
10
10
|
for which the lambda evaluates to a truthy value (not `false` or `undef`).
|
|
11
11
|
|
|
@@ -23,7 +23,7 @@ Puppet::Parser::Functions.newfunction(
|
|
|
23
23
|
|
|
24
24
|
`$filtered_data = filter($data) |$parameter| { <PUPPET CODE BLOCK> }`
|
|
25
25
|
|
|
26
|
-
When the first argument (`$data` in the above example) is an array,
|
|
26
|
+
When the first argument (`$data` in the above example) is an array, OpenVox passes each
|
|
27
27
|
value in turn to the lambda and returns an array containing the results.
|
|
28
28
|
|
|
29
29
|
**Example**: Using the `filter` function with an array and a one-parameter lambda
|
|
@@ -35,7 +35,7 @@ Puppet::Parser::Functions.newfunction(
|
|
|
35
35
|
# $filtered_data = [blueberry, raspberry]
|
|
36
36
|
~~~
|
|
37
37
|
|
|
38
|
-
When the first argument is a hash,
|
|
38
|
+
When the first argument is a hash, OpenVox passes each key and value pair to the lambda
|
|
39
39
|
as an array in the form `[key, value]` and returns a hash containing the results.
|
|
40
40
|
|
|
41
41
|
**Example**: Using the `filter` function with a hash and a one-parameter lambda
|
|
@@ -47,7 +47,7 @@ Puppet::Parser::Functions.newfunction(
|
|
|
47
47
|
# $filtered_data = {blueberry => 1, raspberry => 2}
|
|
48
48
|
~~~
|
|
49
49
|
|
|
50
|
-
When the first argument is an array and the lambda has two parameters,
|
|
50
|
+
When the first argument is an array and the lambda has two parameters, OpenVox passes the
|
|
51
51
|
array's indexes (enumerated from 0) in the first parameter and its values in the second
|
|
52
52
|
parameter.
|
|
53
53
|
|
|
@@ -61,7 +61,7 @@ Puppet::Parser::Functions.newfunction(
|
|
|
61
61
|
# $filtered_data = [raspberry]
|
|
62
62
|
~~~
|
|
63
63
|
|
|
64
|
-
When the first argument is a hash,
|
|
64
|
+
When the first argument is a hash, OpenVox passes its keys to the first parameter and its
|
|
65
65
|
values to the second parameter.
|
|
66
66
|
|
|
67
67
|
**Example**: Using the `filter` function with a hash and a two-parameter lambda
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# Runs an external command and returns the results
|
|
4
4
|
Puppet::Parser::Functions.newfunction(:generate, :arity => -2, :type => :rvalue,
|
|
5
|
-
:doc => "Calls an external command on the
|
|
5
|
+
:doc => "Calls an external command on the OpenVox server and returns
|
|
6
6
|
the results of the command. Any arguments are passed to the external command as
|
|
7
7
|
arguments. If the generator does not exit with return code of 0,
|
|
8
8
|
the generator is considered to have failed and a parse error is
|
|
@@ -15,7 +15,7 @@ module Puppet::Parser::Functions
|
|
|
15
15
|
|
|
16
16
|
1. A string key that Hiera searches for in the hierarchy. **Required**.
|
|
17
17
|
2. An optional default value to return if Hiera doesn't find anything matching the key.
|
|
18
|
-
* If this argument isn't provided and this function results in a lookup failure,
|
|
18
|
+
* If this argument isn't provided and this function results in a lookup failure, OpenVox
|
|
19
19
|
fails with a compilation error.
|
|
20
20
|
3. The optional name of an arbitrary
|
|
21
21
|
[hierarchy level](https://puppet.com/docs/hiera/latest/hierarchy.html) to insert at the
|
|
@@ -60,7 +60,7 @@ module Puppet::Parser::Functions
|
|
|
60
60
|
~~~
|
|
61
61
|
|
|
62
62
|
You can optionally generate the default value with a
|
|
63
|
-
[lambda](https://
|
|
63
|
+
[lambda](https://docs.openvoxproject.org/openvox/latest/lang_lambdas.html) that
|
|
64
64
|
takes one parameter.
|
|
65
65
|
|
|
66
66
|
**Example**: Using `hiera` with a lambda
|
|
@@ -80,7 +80,7 @@ module Puppet::Parser::Functions
|
|
|
80
80
|
above, Hiera matches the 'users' key and returns it as a hash.
|
|
81
81
|
|
|
82
82
|
The `hiera` function is deprecated in favor of using `lookup` and will be removed in 6.0.0.
|
|
83
|
-
See https://
|
|
83
|
+
See https://docs.openvoxproject.org/openvox/latest/deprecated_language.html.
|
|
84
84
|
Replace the calls as follows:
|
|
85
85
|
|
|
86
86
|
| from | to |
|
|
@@ -17,7 +17,7 @@ module Puppet::Parser::Functions
|
|
|
17
17
|
|
|
18
18
|
1. A string key that Hiera searches for in the hierarchy. **Required**.
|
|
19
19
|
2. An optional default value to return if Hiera doesn't find anything matching the key.
|
|
20
|
-
* If this argument isn't provided and this function results in a lookup failure,
|
|
20
|
+
* If this argument isn't provided and this function results in a lookup failure, OpenVox
|
|
21
21
|
fails with a compilation error.
|
|
22
22
|
3. The optional name of an arbitrary
|
|
23
23
|
[hierarchy level](https://puppet.com/docs/hiera/latest/hierarchy.html) to insert at the
|
|
@@ -49,7 +49,7 @@ module Puppet::Parser::Functions
|
|
|
49
49
|
~~~
|
|
50
50
|
|
|
51
51
|
You can optionally generate the default value with a
|
|
52
|
-
[lambda](https://
|
|
52
|
+
[lambda](https://docs.openvoxproject.org/openvox/latest/lang_lambdas.html) that
|
|
53
53
|
takes one parameter.
|
|
54
54
|
|
|
55
55
|
**Example**: Using `hiera_array` with a lambda
|
|
@@ -65,10 +65,10 @@ module Puppet::Parser::Functions
|
|
|
65
65
|
~~~
|
|
66
66
|
|
|
67
67
|
`hiera_array` expects that all values returned will be strings or arrays. If any matched
|
|
68
|
-
value is a hash,
|
|
68
|
+
value is a hash, OpenVox raises a type mismatch error.
|
|
69
69
|
|
|
70
70
|
`hiera_array` is deprecated in favor of using `lookup` and will be removed in 6.0.0.
|
|
71
|
-
See https://
|
|
71
|
+
See https://docs.openvoxproject.org/openvox/latest/deprecated_language.html.
|
|
72
72
|
Replace the calls as follows:
|
|
73
73
|
|
|
74
74
|
| from | to |
|
|
@@ -21,7 +21,7 @@ module Puppet::Parser::Functions
|
|
|
21
21
|
|
|
22
22
|
1. A string key that Hiera searches for in the hierarchy. **Required**.
|
|
23
23
|
2. An optional default value to return if Hiera doesn't find anything matching the key.
|
|
24
|
-
* If this argument isn't provided and this function results in a lookup failure,
|
|
24
|
+
* If this argument isn't provided and this function results in a lookup failure, OpenVox
|
|
25
25
|
fails with a compilation error.
|
|
26
26
|
3. The optional name of an arbitrary
|
|
27
27
|
[hierarchy level](https://puppet.com/docs/hiera/latest/hierarchy.html) to insert at the
|
|
@@ -58,7 +58,7 @@ module Puppet::Parser::Functions
|
|
|
58
58
|
~~~
|
|
59
59
|
|
|
60
60
|
You can optionally generate the default value with a
|
|
61
|
-
[lambda](https://
|
|
61
|
+
[lambda](https://docs.openvoxproject.org/openvox/latest/lang_lambdas.html) that
|
|
62
62
|
takes one parameter.
|
|
63
63
|
|
|
64
64
|
**Example**: Using `hiera_hash` with a lambda
|
|
@@ -75,10 +75,10 @@ module Puppet::Parser::Functions
|
|
|
75
75
|
~~~
|
|
76
76
|
|
|
77
77
|
`hiera_hash` expects that all values returned will be hashes. If any of the values
|
|
78
|
-
found in the data sources are strings or arrays,
|
|
78
|
+
found in the data sources are strings or arrays, OpenVox raises a type mismatch error.
|
|
79
79
|
|
|
80
80
|
`hiera_hash` is deprecated in favor of using `lookup` and will be removed in 6.0.0.
|
|
81
|
-
See https://
|
|
81
|
+
See https://docs.openvoxproject.org/openvox/latest/deprecated_language.html.
|
|
82
82
|
Replace the calls as follows:
|
|
83
83
|
|
|
84
84
|
| from | to |
|
|
@@ -24,7 +24,7 @@ module Puppet::Parser::Functions
|
|
|
24
24
|
|
|
25
25
|
1. A string key that Hiera searches for in the hierarchy. **Required**.
|
|
26
26
|
2. An optional default value to return if Hiera doesn't find anything matching the key.
|
|
27
|
-
* If this argument isn't provided and this function results in a lookup failure,
|
|
27
|
+
* If this argument isn't provided and this function results in a lookup failure, OpenVox
|
|
28
28
|
fails with a compilation error.
|
|
29
29
|
3. The optional name of an arbitrary
|
|
30
30
|
[hierarchy level](https://puppet.com/docs/hiera/latest/hierarchy.html) to insert at the
|
|
@@ -57,11 +57,11 @@ module Puppet::Parser::Functions
|
|
|
57
57
|
# In site.pp, outside of any node definitions and below any top-scope variables:
|
|
58
58
|
hiera_include('classes', undef)
|
|
59
59
|
|
|
60
|
-
#
|
|
60
|
+
# OpenVox assigns the apache and apache::mod::php classes to the web01.example.com node.
|
|
61
61
|
~~~
|
|
62
62
|
|
|
63
63
|
You can optionally generate the default value with a
|
|
64
|
-
[lambda](https://
|
|
64
|
+
[lambda](https://docs.openvoxproject.org/openvox/latest/lang_lambdas.html) that
|
|
65
65
|
takes one parameter.
|
|
66
66
|
|
|
67
67
|
**Example**: Using `hiera_include` with a lambda
|
|
@@ -72,7 +72,7 @@ module Puppet::Parser::Functions
|
|
|
72
72
|
# In site.pp, outside of any node definitions and below any top-scope variables:
|
|
73
73
|
hiera_include('classes') | $key | {"Key \'${key}\' not found" }
|
|
74
74
|
|
|
75
|
-
#
|
|
75
|
+
# OpenVox assigns the apache and apache::mod::php classes to the web01.example.com node.
|
|
76
76
|
# If hiera_include couldn't match its key, it would return the lambda result,
|
|
77
77
|
# "Key 'classes' not found".
|
|
78
78
|
~~~
|
|
@@ -87,7 +87,7 @@ module Puppet::Parser::Functions
|
|
|
87
87
|
| hiera_include($key, $default, $level) | override level not supported |
|
|
88
88
|
|
|
89
89
|
See
|
|
90
|
-
[the Upgrading to Hiera 5 migration guide](https://
|
|
90
|
+
[the Upgrading to Hiera 5 migration guide](https://docs.openvoxproject.org/openvox/latest/hiera_migrate.html)
|
|
91
91
|
for more information.
|
|
92
92
|
|
|
93
93
|
Note that calls using the 'override level' option are not directly supported by 'lookup' and the produced
|
|
@@ -8,7 +8,7 @@ names, or a comma-separated list of class names.
|
|
|
8
8
|
|
|
9
9
|
The `include` function can be used multiple times on the same class and will
|
|
10
10
|
only declare a given class once. If a class declared with `include` has any
|
|
11
|
-
parameters,
|
|
11
|
+
parameters, OpenVox will automatically look up values for them in Hiera, using
|
|
12
12
|
`<class name>::<parameter name>` as the lookup key.
|
|
13
13
|
|
|
14
14
|
Contrast this behavior with resource-like class declarations
|
|
@@ -8,12 +8,12 @@ text result as a String.
|
|
|
8
8
|
|
|
9
9
|
The first argument to this function should be a string containing an EPP
|
|
10
10
|
template. In most cases, the last argument is optional; if used, it should be a
|
|
11
|
-
[hash](https://
|
|
11
|
+
[hash](https://docs.openvoxproject.org/openvox/latest/lang_data_hash.html) that contains parameters to
|
|
12
12
|
pass to the template.
|
|
13
13
|
|
|
14
|
-
- See the [template](https://
|
|
14
|
+
- See the [template](https://docs.openvoxproject.org/openvox/latest/lang_template.html) documentation
|
|
15
15
|
for general template usage information.
|
|
16
|
-
- See the [EPP syntax](https://
|
|
16
|
+
- See the [EPP syntax](https://docs.openvoxproject.org/openvox/latest/lang_template_epp.html)
|
|
17
17
|
documentation for examples of EPP.
|
|
18
18
|
|
|
19
19
|
For example, to evaluate an inline EPP template and pass it the `docroot` and
|
|
@@ -22,16 +22,16 @@ For example, to evaluate an inline EPP template and pass it the `docroot` and
|
|
|
22
22
|
`inline_epp('docroot: <%= $docroot %> Virtual docroot: <%= $virtual_docroot %>',
|
|
23
23
|
{ 'docroot' => '/var/www/html', 'virtual_docroot' => '/var/www/example' })`
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
OpenVox produces a syntax error if you pass more parameters than are declared in
|
|
26
26
|
the template's parameter tag. When passing parameters to a template that
|
|
27
27
|
contains a parameter tag, use the same names as the tag's declared parameters.
|
|
28
28
|
|
|
29
29
|
Parameters are required only if they are declared in the called template's
|
|
30
|
-
parameter tag without default values.
|
|
30
|
+
parameter tag without default values. OpenVox produces an error if the
|
|
31
31
|
`inline_epp` function fails to pass any required parameter.
|
|
32
32
|
|
|
33
33
|
An inline EPP template should be written as a single-quoted string or
|
|
34
|
-
[heredoc](https://
|
|
34
|
+
[heredoc](https://docs.openvoxproject.org/openvox/latest/lang_data_string.html#heredocs).
|
|
35
35
|
A double-quoted string is subject to expression interpolation before the string
|
|
36
36
|
is parsed as an EPP template.
|
|
37
37
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Puppet::Parser::Functions.newfunction(:inline_template, :type => :rvalue, :arity => -2, :doc =>
|
|
4
4
|
"Evaluate a template string and return its value. See
|
|
5
|
-
[the templating docs](https://
|
|
5
|
+
[the templating docs](https://docs.openvoxproject.org/openvox/latest/lang_template.html) for
|
|
6
6
|
more information. Note that if multiple template strings are specified, their
|
|
7
7
|
output is all concatenated and returned as the output of the function.") do |vals|
|
|
8
8
|
if Puppet[:tasks]
|
|
@@ -5,7 +5,7 @@ Puppet::Parser::Functions.newfunction(
|
|
|
5
5
|
:type => :rvalue,
|
|
6
6
|
:arity => -2,
|
|
7
7
|
:doc => <<~DOC
|
|
8
|
-
Call a [lambda](https://
|
|
8
|
+
Call a [lambda](https://docs.openvoxproject.org/openvox/latest/lang_lambdas.html)
|
|
9
9
|
(which should accept no arguments) if the argument given to the function is `undef`.
|
|
10
10
|
Returns the result of calling the lambda if the argument is `undef`, otherwise the
|
|
11
11
|
given argument.
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
module Puppet::Parser::Functions
|
|
4
4
|
newfunction(:lookup, :type => :rvalue, :arity => -2, :doc => <<~'ENDHEREDOC') do |_args|
|
|
5
|
-
Uses the
|
|
5
|
+
Uses the OpenVox lookup system to retrieve a value for a given key. By default,
|
|
6
6
|
this returns the first value found (and fails compilation if no values are
|
|
7
7
|
available), but you can configure it to merge multiple values into one, fail
|
|
8
8
|
gracefully, and more.
|
|
9
9
|
|
|
10
|
-
When looking up a key,
|
|
10
|
+
When looking up a key, OpenVox will search up to three tiers of data, in the
|
|
11
11
|
following order:
|
|
12
12
|
|
|
13
13
|
1. Hiera.
|
|
@@ -29,22 +29,22 @@ module Puppet::Parser::Functions
|
|
|
29
29
|
The arguments accepted by `lookup` are as follows:
|
|
30
30
|
|
|
31
31
|
1. `<NAME>` (string or array) --- The name of the key to look up.
|
|
32
|
-
* This can also be an array of keys. If
|
|
32
|
+
* This can also be an array of keys. If OpenVox doesn't find anything for the
|
|
33
33
|
first key, it will try again with the subsequent ones, only resorting to a
|
|
34
34
|
default value if none of them succeed.
|
|
35
35
|
2. `<VALUE TYPE>` (data type) --- A
|
|
36
|
-
[data type](https://
|
|
36
|
+
[data type](https://docs.openvoxproject.org/openvox/latest/lang_data_type.html)
|
|
37
37
|
that must match the retrieved value; if not, the lookup (and catalog
|
|
38
38
|
compilation) will fail. Defaults to `Data` (accepts any normal value).
|
|
39
39
|
3. `<MERGE BEHAVIOR>` (string or hash; see **"Merge Behaviors"** below) ---
|
|
40
40
|
Whether (and how) to combine multiple values. If present, this overrides any
|
|
41
|
-
merge behavior specified in the data sources. Defaults to no value;
|
|
41
|
+
merge behavior specified in the data sources. Defaults to no value; OpenVox will
|
|
42
42
|
use merge behavior from the data sources if present, and will otherwise do a
|
|
43
43
|
first-found lookup.
|
|
44
44
|
4. `<DEFAULT VALUE>` (any normal value) --- If present, `lookup` returns this
|
|
45
45
|
when it can't find a normal value. Default values are never merged with found
|
|
46
46
|
values. Like a normal value, the default must match the value type. Defaults to
|
|
47
|
-
no value; if
|
|
47
|
+
no value; if OpenVox can't find a normal value, the lookup (and compilation) will
|
|
48
48
|
fail.
|
|
49
49
|
5. `<OPTIONS HASH>` (hash) --- Alternate way to set the arguments above, plus
|
|
50
50
|
some less-common extra options. If you pass an options hash, you can't combine
|
|
@@ -56,24 +56,24 @@ module Puppet::Parser::Functions
|
|
|
56
56
|
* `'merge'` --- Same as `<MERGE BEHAVIOR>` (argument 3).
|
|
57
57
|
* `'default_value'` --- Same as `<DEFAULT VALUE>` (argument 4).
|
|
58
58
|
* `'default_values_hash'` (hash) --- A hash of lookup keys and default
|
|
59
|
-
values. If
|
|
59
|
+
values. If OpenVox can't find a normal value, it will check this hash for the
|
|
60
60
|
requested key before giving up. You can combine this with `default_value` or
|
|
61
61
|
a lambda, which will be used if the key isn't present in this hash. Defaults
|
|
62
62
|
to an empty hash.
|
|
63
|
-
* `'override'` (hash) --- A hash of lookup keys and override values.
|
|
63
|
+
* `'override'` (hash) --- A hash of lookup keys and override values. OpenVox
|
|
64
64
|
will check for the requested key in the overrides hash _first;_ if found, it
|
|
65
65
|
returns that value as the _final_ value, ignoring merge behavior. Defaults
|
|
66
66
|
to an empty hash.
|
|
67
67
|
|
|
68
68
|
Finally, `lookup` can take a lambda, which must accept a single parameter.
|
|
69
69
|
This is yet another way to set a default value for the lookup; if no results are
|
|
70
|
-
found,
|
|
70
|
+
found, OpenVox will pass the requested key to the lambda and use its result as
|
|
71
71
|
the default value.
|
|
72
72
|
|
|
73
73
|
#### Merge Behaviors
|
|
74
74
|
|
|
75
|
-
|
|
76
|
-
values in multiple sources. By default,
|
|
75
|
+
OpenVox lookup uses a hierarchy of data sources, and a given key might have
|
|
76
|
+
values in multiple sources. By default, OpenVox returns the first value it finds,
|
|
77
77
|
but it can also continue searching and merge all the values together.
|
|
78
78
|
|
|
79
79
|
> **Note:** Data sources can use the special `lookup_options` metadata key to
|
|
@@ -82,17 +82,17 @@ module Puppet::Parser::Functions
|
|
|
82
82
|
|
|
83
83
|
The valid merge behaviors are:
|
|
84
84
|
|
|
85
|
-
* `'first'` --- Returns the first value found, with no merging.
|
|
85
|
+
* `'first'` --- Returns the first value found, with no merging. OpenVox lookup's
|
|
86
86
|
default behavior.
|
|
87
87
|
* `'unique'` (called "array merge" in classic Hiera) --- Combines any number of
|
|
88
88
|
arrays and scalar values to return a merged, flattened array with all duplicate
|
|
89
89
|
values removed. The lookup will fail if any hash values are found.
|
|
90
90
|
* `'hash'` --- Combines the keys and values of any number of hashes to return a
|
|
91
|
-
merged hash. If the same key exists in multiple source hashes,
|
|
91
|
+
merged hash. If the same key exists in multiple source hashes, OpenVox will use
|
|
92
92
|
the value from the highest-priority data source; it won't recursively merge the
|
|
93
93
|
values.
|
|
94
94
|
* `'deep'` --- Combines the keys and values of any number of hashes to return a
|
|
95
|
-
merged hash. If the same key exists in multiple source hashes,
|
|
95
|
+
merged hash. If the same key exists in multiple source hashes, OpenVox will
|
|
96
96
|
recursively merge hash or array values (with duplicate values removed from
|
|
97
97
|
arrays). For conflicting scalar values, the highest-priority value will win.
|
|
98
98
|
* `{'strategy' => 'first|unique|hash'}` --- Same as the string versions of these
|
|
@@ -5,7 +5,7 @@ Puppet::Parser::Functions.newfunction(
|
|
|
5
5
|
:type => :rvalue,
|
|
6
6
|
:arity => -3,
|
|
7
7
|
:doc => <<~DOC
|
|
8
|
-
Applies a [lambda](https://
|
|
8
|
+
Applies a [lambda](https://docs.openvoxproject.org/openvox/latest/lang_lambdas.html)
|
|
9
9
|
to every value in a data structure and returns an array containing the results.
|
|
10
10
|
|
|
11
11
|
This function takes two mandatory arguments, in this order:
|
|
@@ -22,7 +22,7 @@ Puppet::Parser::Functions.newfunction(
|
|
|
22
22
|
|
|
23
23
|
`$transformed_data = map($data) |$parameter| { <PUPPET CODE BLOCK> }`
|
|
24
24
|
|
|
25
|
-
When the first argument (`$data` in the above example) is an array,
|
|
25
|
+
When the first argument (`$data` in the above example) is an array, OpenVox passes each
|
|
26
26
|
value in turn to the lambda.
|
|
27
27
|
|
|
28
28
|
**Example**: Using the `map` function with an array and a one-parameter lambda
|
|
@@ -34,7 +34,7 @@ Puppet::Parser::Functions.newfunction(
|
|
|
34
34
|
# $transformed_data contains [10,20,30]
|
|
35
35
|
~~~
|
|
36
36
|
|
|
37
|
-
When the first argument is a hash,
|
|
37
|
+
When the first argument is a hash, OpenVox passes each key and value pair to the lambda
|
|
38
38
|
as an array in the form `[key, value]`.
|
|
39
39
|
|
|
40
40
|
**Example**: Using the `map` function with a hash and a one-parameter lambda
|
|
@@ -46,7 +46,7 @@ Puppet::Parser::Functions.newfunction(
|
|
|
46
46
|
# $transformed_data contains ['a','b','c']
|
|
47
47
|
~~~
|
|
48
48
|
|
|
49
|
-
When the first argument is an array and the lambda has two parameters,
|
|
49
|
+
When the first argument is an array and the lambda has two parameters, OpenVox passes the
|
|
50
50
|
array's indexes (enumerated from 0) in the first parameter and its values in the second
|
|
51
51
|
parameter.
|
|
52
52
|
|
|
@@ -59,7 +59,7 @@ Puppet::Parser::Functions.newfunction(
|
|
|
59
59
|
# $transformed_data contains [0,1,2]
|
|
60
60
|
~~~
|
|
61
61
|
|
|
62
|
-
When the first argument is a hash,
|
|
62
|
+
When the first argument is a hash, OpenVox passes its keys to the first parameter and its
|
|
63
63
|
values to the second parameter.
|
|
64
64
|
|
|
65
65
|
**Example**: Using the `map` function with a hash and a two-parameter lambda
|
|
@@ -5,7 +5,7 @@ Puppet::Parser::Functions.newfunction(
|
|
|
5
5
|
:type => :rvalue,
|
|
6
6
|
:arity => -3,
|
|
7
7
|
:doc => <<~DOC
|
|
8
|
-
Applies a [lambda](https://
|
|
8
|
+
Applies a [lambda](https://docs.openvoxproject.org/openvox/latest/lang_lambdas.html)
|
|
9
9
|
to every value in a data structure from the first argument, carrying over the returned
|
|
10
10
|
value of each iteration, and returns the result of the lambda's final iteration. This
|
|
11
11
|
lets you create a new value or data structure by combining values from the first
|
|
@@ -36,21 +36,21 @@ Puppet::Parser::Functions.newfunction(
|
|
|
36
36
|
|
|
37
37
|
`reduce($data, start) |$memo, $value| { ... }`
|
|
38
38
|
|
|
39
|
-
When the first argument (`$data` in the above example) is an array,
|
|
39
|
+
When the first argument (`$data` in the above example) is an array, OpenVox passes each
|
|
40
40
|
of the data structure's values in turn to the lambda's parameters. When the first
|
|
41
|
-
argument is a hash,
|
|
41
|
+
argument is a hash, OpenVox converts each of the hash's values to an array in the form
|
|
42
42
|
`[key, value]`.
|
|
43
43
|
|
|
44
|
-
If you pass a start memo value,
|
|
45
|
-
and the data structure's first value. Otherwise,
|
|
44
|
+
If you pass a start memo value, OpenVox executes the lambda with the provided memo value
|
|
45
|
+
and the data structure's first value. Otherwise, OpenVox passes the structure's first two
|
|
46
46
|
values to the lambda.
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
OpenVox calls the lambda for each of the data structure's remaining values. For each
|
|
49
49
|
call, it passes the result of the previous call as the first parameter ($memo in the
|
|
50
50
|
above examples) and the next value from the data structure as the second parameter
|
|
51
51
|
($value).
|
|
52
52
|
|
|
53
|
-
If the structure has one value,
|
|
53
|
+
If the structure has one value, OpenVox returns the value and does not call the lambda.
|
|
54
54
|
|
|
55
55
|
**Example**: Using the `reduce` function
|
|
56
56
|
|