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
@@ -0,0 +1,182 @@
|
|
1
|
+
# Returns the lowest value among a variable number of arguments.
|
2
|
+
# Takes at least one argument.
|
3
|
+
#
|
4
|
+
# This function is (with one exception) compatible with the stdlib function
|
5
|
+
# with the same name and performs deprecated type conversion before
|
6
|
+
# comparison as follows:
|
7
|
+
#
|
8
|
+
# * If a value converted to String is an optionally '-' prefixed,
|
9
|
+
# string of digits, one optional decimal point, followed by optional
|
10
|
+
# decimal digits - then the comparison is performed on the values
|
11
|
+
# converted to floating point.
|
12
|
+
# * If a value is not considered convertible to float, it is converted
|
13
|
+
# to a `String` and the comparison is a lexical compare where min is
|
14
|
+
# the lexicographical earlier value.
|
15
|
+
# * A lexicographical compare is performed in a system locale - international
|
16
|
+
# characters may therefore not appear in what a user thinks is the correct order.
|
17
|
+
# * The conversion rules apply to values in pairs - the rule must hold for both
|
18
|
+
# values - a value may therefore be compared using different rules depending
|
19
|
+
# on the "other value".
|
20
|
+
# * The returned result found to be the "lowest" is the original unconverted value.
|
21
|
+
#
|
22
|
+
# The above rules have been deprecated in Puppet 6.0.0 as they produce strange results when
|
23
|
+
# given values of mixed data types. In general, either convert values to be
|
24
|
+
# all `String` or all `Numeric` values before calling the function, or call the
|
25
|
+
# function with a lambda that performs type conversion and comparison. This because one
|
26
|
+
# simply cannot compare `Boolean` with `Regexp` and with any arbitrary `Array`, `Hash` or
|
27
|
+
# `Object` and getting a meaningful result.
|
28
|
+
#
|
29
|
+
# The one change in the function's behavior is when the function is given a single
|
30
|
+
# array argument. The stdlib implementation would return that array as the result where
|
31
|
+
# it now instead returns the max value from that array.
|
32
|
+
#
|
33
|
+
# @example 'min of values - stdlib compatible'
|
34
|
+
#
|
35
|
+
# ```puppet
|
36
|
+
# notice(min(1)) # would notice 1
|
37
|
+
# notice(min(1,2)) # would notice 1
|
38
|
+
# notice(min("1", 2)) # would notice 1
|
39
|
+
# notice(min("0777", 512)) # would notice 512, since "0777" is not converted from octal form
|
40
|
+
# notice(min(0777, 512)) # would notice 511, since 0777 is decimal 511
|
41
|
+
# notice(min('aa', 'ab')) # would notice 'aa'
|
42
|
+
# notice(min(['a'], ['b'])) # would notice ['a'], since "['a']" is before "['b']"
|
43
|
+
# ```
|
44
|
+
#
|
45
|
+
# @example find 'min' value in an array
|
46
|
+
#
|
47
|
+
# ```puppet
|
48
|
+
# $x = [1,2,3,4]
|
49
|
+
# notice(min(*$x)) # would notice 1
|
50
|
+
# ```
|
51
|
+
#
|
52
|
+
# @example find 'min' value in an array directly - since Puppet 6.0.0
|
53
|
+
#
|
54
|
+
# ```puppet
|
55
|
+
# $x = [1,2,3,4]
|
56
|
+
# notice(min($x)) # would notice 1
|
57
|
+
# notice($x.min) # would notice 1
|
58
|
+
# ```
|
59
|
+
# This example shows that a single array argument is used as the set of values
|
60
|
+
# as opposed to being a single returned value.
|
61
|
+
#
|
62
|
+
# When calling with a lambda, it must accept two variables and it must return
|
63
|
+
# one of -1, 0, or 1 depending on if first argument is before/lower than, equal to,
|
64
|
+
# or higher/after the second argument.
|
65
|
+
#
|
66
|
+
# @example 'min of values using a lambda'
|
67
|
+
#
|
68
|
+
# ```puppet
|
69
|
+
# notice(min("2", "10", "100") |$a, $b| { compare($a, $b) })
|
70
|
+
# ```
|
71
|
+
#
|
72
|
+
# Would notice "10" as lower since it is lexicographically lower/before the other values. Without the
|
73
|
+
# lambda the stdlib compatible (deprecated) behavior would have been to return "2" since number conversion kicks in.
|
74
|
+
#
|
75
|
+
Puppet::Functions.create_function(:min) do
|
76
|
+
dispatch :on_numeric do
|
77
|
+
repeated_param 'Numeric', :values
|
78
|
+
end
|
79
|
+
|
80
|
+
dispatch :on_string do
|
81
|
+
repeated_param 'String', :values
|
82
|
+
end
|
83
|
+
|
84
|
+
dispatch :on_single_numeric_array do
|
85
|
+
param 'Array[Numeric]', :values
|
86
|
+
optional_block_param 'Callable[2,2]', :block
|
87
|
+
end
|
88
|
+
|
89
|
+
dispatch :on_single_string_array do
|
90
|
+
param 'Array[String]', :values
|
91
|
+
optional_block_param 'Callable[2,2]', :block
|
92
|
+
end
|
93
|
+
|
94
|
+
dispatch :on_single_any_array do
|
95
|
+
param 'Array', :values
|
96
|
+
optional_block_param 'Callable[2,2]', :block
|
97
|
+
end
|
98
|
+
|
99
|
+
dispatch :on_any_with_block do
|
100
|
+
repeated_param 'Any', :values
|
101
|
+
block_param 'Callable[2,2]', :block
|
102
|
+
end
|
103
|
+
|
104
|
+
dispatch :on_any do
|
105
|
+
repeated_param 'Any', :values
|
106
|
+
end
|
107
|
+
|
108
|
+
|
109
|
+
# All are Numeric - ok now, will be ok later
|
110
|
+
def on_numeric(*args)
|
111
|
+
assert_arg_count(args)
|
112
|
+
args.min
|
113
|
+
end
|
114
|
+
|
115
|
+
# All are String, may convert to numeric (which is deprecated)
|
116
|
+
def on_string(*args)
|
117
|
+
assert_arg_count(args)
|
118
|
+
|
119
|
+
args.min do|a,b|
|
120
|
+
if a.to_s =~ %r{\A^-?\d+([._eE]\d+)?\z} && b.to_s =~ %r{\A-?\d+([._eE]\d+)?\z}
|
121
|
+
Puppet.warn_once('deprecations', 'min_function_numeric_coerce_string',
|
122
|
+
_("The min() function's auto conversion of String to Numeric is deprecated - change to convert input before calling, or use lambda"))
|
123
|
+
a.to_f <=> b.to_f
|
124
|
+
else
|
125
|
+
# case sensitive as in the stdlib function
|
126
|
+
a <=> b
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
def on_any_with_block(*args, &block)
|
132
|
+
args.min {|x,y| block.call(x,y) }
|
133
|
+
end
|
134
|
+
|
135
|
+
def on_single_numeric_array(array, &block)
|
136
|
+
if block_given?
|
137
|
+
on_any_with_block(*array, &block)
|
138
|
+
else
|
139
|
+
on_numeric(*array)
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
def on_single_string_array(array, &block)
|
144
|
+
if block_given?
|
145
|
+
on_any_with_block(*array, &block)
|
146
|
+
else
|
147
|
+
on_string(*array)
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
def on_single_any_array(array, &block)
|
152
|
+
if block_given?
|
153
|
+
on_any_with_block(*array, &block)
|
154
|
+
else
|
155
|
+
on_any(*array)
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
# Mix of data types - while only some compares are actually bad it will deprecate
|
160
|
+
# the entire call
|
161
|
+
#
|
162
|
+
def on_any(*args)
|
163
|
+
assert_arg_count(args)
|
164
|
+
args.min do |a, b|
|
165
|
+
as = a.to_s
|
166
|
+
bs = b.to_s
|
167
|
+
if as =~ %r{\A^-?\d+([._eE]\d+)?\z} && bs =~ %r{\A-?\d+([._eE]\d+)?\z}
|
168
|
+
Puppet.warn_once('deprecations', 'min_function_numeric_coerce_string',
|
169
|
+
_("The min() function's auto conversion of String to Numeric is deprecated - change to convert input before calling, or use lambda"))
|
170
|
+
a.to_f <=> b.to_f
|
171
|
+
else
|
172
|
+
Puppet.warn_once('deprecations', 'min_function_string_coerce_any',
|
173
|
+
_("The min() function's auto conversion of Any to String is deprecated - change to convert input before calling, or use lambda"))
|
174
|
+
as <=> bs
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
def assert_arg_count(args)
|
180
|
+
raise(ArgumentError, 'min(): Wrong number of arguments need at least one') if args.empty?
|
181
|
+
end
|
182
|
+
end
|
@@ -9,14 +9,7 @@ Puppet::Functions.create_function(:next) do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def next_impl(value = nil)
|
12
|
-
|
13
|
-
if stacktrace.size > 0
|
14
|
-
file, line = stacktrace[0]
|
15
|
-
else
|
16
|
-
file = nil
|
17
|
-
line = nil
|
18
|
-
end
|
19
|
-
|
12
|
+
file, line = Puppet::Pops::PuppetStack.top_of_stack
|
20
13
|
exc = Puppet::Pops::Evaluator::Next.new(value, file, line)
|
21
14
|
raise exc
|
22
15
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Applies a [lambda](https://
|
1
|
+
# Applies a [lambda](https://puppet.com/docs/puppet/latest/lang_lambdas.html)
|
2
2
|
# to every value in a data structure from the first argument, carrying over the returned
|
3
3
|
# value of each iteration, and returns the result of the lambda's final iteration. This
|
4
4
|
# lets you create a new value or data structure by combining values from the first
|
@@ -9,14 +9,7 @@ Puppet::Functions.create_function(:return, Puppet::Functions::InternalFunction)
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def return_impl(value = nil)
|
12
|
-
|
13
|
-
if stacktrace.size > 0
|
14
|
-
file, line = stacktrace[0]
|
15
|
-
else
|
16
|
-
file = nil
|
17
|
-
line = nil
|
18
|
-
end
|
19
|
-
|
12
|
+
file, line = Puppet::Pops::PuppetStack.top_of_stack
|
20
13
|
raise Puppet::Pops::Evaluator::Return.new(value, file, line)
|
21
14
|
end
|
22
15
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Reverses the order of the elements of something that is iterable and optionally runs a
|
2
|
-
# [lambda](https://
|
2
|
+
# [lambda](https://puppet.com/docs/puppet/latest/lang_lambdas.html) for each
|
3
3
|
# element.
|
4
4
|
#
|
5
5
|
# This function takes one to two arguments:
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# Returns an `Integer` value rounded to the nearest value.
|
2
|
+
# Takes a single `Numeric` value as an argument.
|
3
|
+
#
|
4
|
+
# @example 'rounding a value'
|
5
|
+
#
|
6
|
+
# ```puppet
|
7
|
+
# notice(round(2.9)) # would notice 3
|
8
|
+
# notice(round(2.1)) # would notice 2
|
9
|
+
# notice(round(-2.9)) # would notice -3
|
10
|
+
# ```
|
11
|
+
#
|
12
|
+
Puppet::Functions.create_function(:round) do
|
13
|
+
dispatch :on_numeric do
|
14
|
+
param 'Numeric', :val
|
15
|
+
end
|
16
|
+
|
17
|
+
def on_numeric(x)
|
18
|
+
if x > 0
|
19
|
+
Integer(x + 0.5)
|
20
|
+
else
|
21
|
+
Integer(x - 0.5)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# Strips trailing spaces from a String
|
2
|
+
#
|
3
|
+
# This function is compatible with the stdlib function with the same name.
|
4
|
+
#
|
5
|
+
# The function does the following:
|
6
|
+
# * For a `String` the conversion removes all trailing ASCII white space characters such as space, tab, newline, and return.
|
7
|
+
# It does not remove other space-like characters like hard space (Unicode U+00A0). (Tip, `/^[[:space:]]/` regular expression
|
8
|
+
# matches all space-like characters).
|
9
|
+
# * For an `Iterable[Variant[String, Numeric]]` (for example an `Array`) each value is processed and the conversion is not recursive.
|
10
|
+
# * If the value is `Numeric` it is simply returned (this is for backwards compatibility).
|
11
|
+
# * An error is raised for all other data types.
|
12
|
+
#
|
13
|
+
# @example Removing trailing space from a String
|
14
|
+
# ```puppet
|
15
|
+
# "hello\n\t".lstrip()
|
16
|
+
# camelcase("hello\n\t")
|
17
|
+
# ```
|
18
|
+
# Would both result in `"hello"`
|
19
|
+
#
|
20
|
+
# @example Removing trailing space from strings in an Array
|
21
|
+
# ```puppet
|
22
|
+
# ["hello\n\t", "hi\n\t"].lstrip()
|
23
|
+
# lstrip(["hello\n\t", "hi\n\t"])
|
24
|
+
# ```
|
25
|
+
# Would both result in `['hello', 'hi']`
|
26
|
+
#
|
27
|
+
Puppet::Functions.create_function(:rstrip) do
|
28
|
+
|
29
|
+
dispatch :on_numeric do
|
30
|
+
param 'Numeric', :arg
|
31
|
+
end
|
32
|
+
|
33
|
+
dispatch :on_string do
|
34
|
+
param 'String', :arg
|
35
|
+
end
|
36
|
+
|
37
|
+
dispatch :on_iterable do
|
38
|
+
param 'Iterable[Variant[String, Numeric]]', :arg
|
39
|
+
end
|
40
|
+
|
41
|
+
# unit function - since the old implementation skipped Numeric values
|
42
|
+
def on_numeric(n)
|
43
|
+
n
|
44
|
+
end
|
45
|
+
|
46
|
+
def on_string(s)
|
47
|
+
s.rstrip
|
48
|
+
end
|
49
|
+
|
50
|
+
def on_iterable(a)
|
51
|
+
a.map {|x| do_rstrip(x) }
|
52
|
+
end
|
53
|
+
|
54
|
+
def do_rstrip(x)
|
55
|
+
# x can only be a String or Numeric because type constraints have been automatically applied
|
56
|
+
x.is_a?(String) ? x.rstrip : x
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# The same as length() - returns the size of an Array, Hash, String, or Binary value.
|
2
|
+
#
|
3
|
+
# @since 6.0.0 - also supporting Binary
|
4
|
+
#
|
5
|
+
Puppet::Functions.create_function(:size) do
|
6
|
+
dispatch :generic_size do
|
7
|
+
param 'Variant[Collection, String, Binary]', :arg
|
8
|
+
end
|
9
|
+
|
10
|
+
|
11
|
+
def generic_size(arg)
|
12
|
+
call_function('length', arg)
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
# Sorts an Array numerically or lexicographically or the characters of a String lexicographically.
|
2
|
+
# Please note: This function is based on Ruby String comparison and as such may not be entirely UTF8 compatible.
|
3
|
+
# To ensure compatibility please use this function with Ruby 2.4.0 or greater - https://bugs.ruby-lang.org/issues/10085.
|
4
|
+
#
|
5
|
+
# This function is compatible with the function sort() in stdlib.
|
6
|
+
# * Comparison of characters in a string always uses a system locale and may not be what is expected for a particular locale
|
7
|
+
# * Sorting is based on Ruby's <=> operator unless a lambda is given that performs the comparison.
|
8
|
+
# * comparison of strings is case dependent (use lambda with `compare($a,$b)` to ignore case)
|
9
|
+
# * comparison of mixed data types raises an error (if there is the need to sort mixed data types use a lambda)
|
10
|
+
#
|
11
|
+
# Also see the `compare()` function for information about comparable data types in general.
|
12
|
+
#
|
13
|
+
# @example Sorting a String
|
14
|
+
#
|
15
|
+
# ```puppet
|
16
|
+
# notice(sort("xadb")) # notices 'abdx'
|
17
|
+
# ```
|
18
|
+
#
|
19
|
+
# @example Sorting an Array
|
20
|
+
#
|
21
|
+
# ```puppet
|
22
|
+
# notice(sort([3,6,2])) # notices [2, 3, 6]
|
23
|
+
# ```
|
24
|
+
#
|
25
|
+
# @example Sorting with a lambda
|
26
|
+
#
|
27
|
+
# ```puppet
|
28
|
+
# notice(sort([3,6,2]) |$a,$b| { compare($a, $b) }) # notices [2, 3, 6]
|
29
|
+
# notice(sort([3,6,2]) |$a,$b| { compare($b, $a) }) # notices [6, 3, 2]
|
30
|
+
# ```
|
31
|
+
#
|
32
|
+
# @example Case independent sorting with a lambda
|
33
|
+
#
|
34
|
+
# ```puppet
|
35
|
+
# notice(sort(['A','b','C'])) # notices ['A', 'C', 'b']
|
36
|
+
# notice(sort(['A','b','C']) |$a,$b| { compare($a, $b) }) # notices ['A', 'b', 'C']
|
37
|
+
# notice(sort(['A','b','C']) |$a,$b| { compare($a, $b, true) }) # notices ['A', 'b', 'C']
|
38
|
+
# notice(sort(['A','b','C']) |$a,$b| { compare($a, $b, false) }) # notices ['A','C', 'b']
|
39
|
+
# ```
|
40
|
+
#
|
41
|
+
# @example Sorting Array with Numeric and String so that numbers are before strings
|
42
|
+
#
|
43
|
+
# ```puppet
|
44
|
+
# notice(sort(['b', 3, 'a', 2]) |$a, $b| {
|
45
|
+
# case [$a, $b] {
|
46
|
+
# [String, Numeric] : { 1 }
|
47
|
+
# [Numeric, String] : { -1 }
|
48
|
+
# default: { compare($a, $b) }
|
49
|
+
# }
|
50
|
+
# })
|
51
|
+
# ```
|
52
|
+
# Would notice [2,3,'a','b']
|
53
|
+
#
|
54
|
+
# @since 6.0.0 - supporting a lambda to do compare
|
55
|
+
#
|
56
|
+
Puppet::Functions.create_function(:sort) do
|
57
|
+
dispatch :sort_string do
|
58
|
+
param 'String', :string_value
|
59
|
+
optional_block_param 'Callable[2,2]', :block
|
60
|
+
end
|
61
|
+
|
62
|
+
dispatch :sort_array do
|
63
|
+
param 'Array', :array_value
|
64
|
+
optional_block_param 'Callable[2,2]', :block
|
65
|
+
end
|
66
|
+
|
67
|
+
def sort_string(s, &block)
|
68
|
+
sort_array(s.split(''), &block).join('')
|
69
|
+
end
|
70
|
+
|
71
|
+
def sort_array(a, &block)
|
72
|
+
a.sort(&block)
|
73
|
+
end
|
74
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Provides stepping with given interval over elements in an iterable and optionally runs a
|
2
|
-
# [lambda](https://
|
2
|
+
# [lambda](https://puppet.com/docs/puppet/latest/lang_lambdas.html) for each
|
3
3
|
# element.
|
4
4
|
#
|
5
5
|
# This function takes two to three arguments:
|
@@ -202,13 +202,7 @@ Puppet::Functions.create_function(:strftime) do
|
|
202
202
|
end
|
203
203
|
|
204
204
|
def legacy_strftime(format, timezone = nil)
|
205
|
-
|
206
|
-
if stacktrace.size > 0
|
207
|
-
file, line = stacktrace[0]
|
208
|
-
else
|
209
|
-
file = nil
|
210
|
-
line = nil
|
211
|
-
end
|
205
|
+
file, line = Puppet::Pops::PuppetStack.top_of_stack
|
212
206
|
Puppet.warn_once('deprecations', 'legacy#strftime',
|
213
207
|
_('The argument signature (String format, [String timezone]) is deprecated for #strftime. See #strftime documentation and Timespan type for more info'),
|
214
208
|
file, line)
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# Strips leading and trailing spaces from a String
|
2
|
+
#
|
3
|
+
# This function is compatible with the stdlib function with the same name.
|
4
|
+
#
|
5
|
+
# The function does the following:
|
6
|
+
# * For a `String` the conversion removes all leading and trailing ASCII white space characters such as space, tab, newline, and return.
|
7
|
+
# It does not remove other space-like characters like hard space (Unicode U+00A0). (Tip, `/^[[:space:]]/` regular expression
|
8
|
+
# matches all space-like characters).
|
9
|
+
# * For an `Iterable[Variant[String, Numeric]]` (for example an `Array`) each value is processed and the conversion is not recursive.
|
10
|
+
# * If the value is `Numeric` it is simply returned (this is for backwards compatibility).
|
11
|
+
# * An error is raised for all other data types.
|
12
|
+
#
|
13
|
+
# @example Removing leading and trailing space from a String
|
14
|
+
# ```puppet
|
15
|
+
# " hello\n\t".lstrip()
|
16
|
+
# camelcase(" hello\n\t")
|
17
|
+
# ```
|
18
|
+
# Would both result in `"hello"`
|
19
|
+
#
|
20
|
+
# @example Removing trailing space from strings in an Array
|
21
|
+
# ```puppet
|
22
|
+
# [" hello\n\t", " hi\n\t"].lstrip()
|
23
|
+
# lstrip([" hello\n\t", " hi\n\t"])
|
24
|
+
# ```
|
25
|
+
# Would both result in `['hello', 'hi']`
|
26
|
+
#
|
27
|
+
Puppet::Functions.create_function(:strip) do
|
28
|
+
|
29
|
+
dispatch :on_numeric do
|
30
|
+
param 'Numeric', :arg
|
31
|
+
end
|
32
|
+
|
33
|
+
dispatch :on_string do
|
34
|
+
param 'String', :arg
|
35
|
+
end
|
36
|
+
|
37
|
+
dispatch :on_iterable do
|
38
|
+
param 'Iterable[Variant[String, Numeric]]', :arg
|
39
|
+
end
|
40
|
+
|
41
|
+
# unit function - since the old implementation skipped Numeric values
|
42
|
+
def on_numeric(n)
|
43
|
+
n
|
44
|
+
end
|
45
|
+
|
46
|
+
def on_string(s)
|
47
|
+
s.strip
|
48
|
+
end
|
49
|
+
|
50
|
+
def on_iterable(a)
|
51
|
+
a.map {|x| do_strip(x) }
|
52
|
+
end
|
53
|
+
|
54
|
+
def do_strip(x)
|
55
|
+
# x can only be a String or Numeric because type constraints have been automatically applied
|
56
|
+
x.is_a?(String) ? x.strip : x
|
57
|
+
end
|
58
|
+
end
|