From 00c881d0dabe77fd2401beb0d39c7386b50bb791 Mon Sep 17 00:00:00 2001 From: David Schmitt Date: Mon, 14 Sep 2015 18:26:25 +0100 Subject: (MODULES-2516) Adds an is_a() function The data type system is very hard to understand. Many people don't understand why type_of([1,2,3]) == Array will fail, but type_of([1,2,3]) <= Array passes. This does a simpler validation that doesn't rely on explicit data types. Instead, use $foo = [1,2,3] if $foo.is_a(Array) { notify { 'This is an array': } } This is based on code by Ben Ford . * Added acceptance tests * Added dispatch * Improved unit tests * Added docs to README --- lib/puppet/functions/is_a.rb | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 lib/puppet/functions/is_a.rb (limited to 'lib/puppet/functions') diff --git a/lib/puppet/functions/is_a.rb b/lib/puppet/functions/is_a.rb new file mode 100644 index 0000000..da98b03 --- /dev/null +++ b/lib/puppet/functions/is_a.rb @@ -0,0 +1,32 @@ +# Boolean check to determine whether a variable is of a given data type. This is equivalent to the `=~` type checks. +# +# @example how to check a data type +# # check a data type +# foo = 3 +# $bar = [1,2,3] +# $baz = 'A string!' +# +# if $foo.is_a(Integer) { +# notify { 'foo!': } +# } +# if $bar.is_a(Array) { +# notify { 'bar!': } +# } +# if $baz.is_a(String) { +# notify { 'baz!': } +# } +# +# See the documentation for "The Puppet Type System" for more information about types. +# See the `assert_type()` function for flexible ways to assert the type of a value. +# +Puppet::Functions.create_function(:is_a) do + dispatch :is_a do + param 'Any', :value + param 'Type', :type + end + + def is_a(value, type) + # See puppet's lib/puppet/pops/evaluator/evaluator_impl.rb eval_MatchExpression + Puppet::Pops::Types::TypeCalculator.instance?(type, value) + end +end -- cgit v1.2.3 From 72d23659513517389880ba13663a1d6380d538ca Mon Sep 17 00:00:00 2001 From: tphoney Date: Tue, 5 Jul 2016 09:56:42 +0100 Subject: (MODULES-3529)add deprecation function --- lib/puppet/functions/deprecation.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 lib/puppet/functions/deprecation.rb (limited to 'lib/puppet/functions') diff --git a/lib/puppet/functions/deprecation.rb b/lib/puppet/functions/deprecation.rb new file mode 100644 index 0000000..3b84ae5 --- /dev/null +++ b/lib/puppet/functions/deprecation.rb @@ -0,0 +1,21 @@ +# Function to print deprecation warnings, Logs a warning once for a given key. The uniqueness key - can appear once. The msg is the message text including any positional information that is formatted by the user/caller of the method It is affected by the puppet setting 'strict', which can be set to :error (outputs as an error message), :off (no message / error is displayed) and :warning (default, outputs a warning) *Type*: String, String. +# + +Puppet::Functions.create_function(:deprecation) do + dispatch :deprecation do + param 'String', :key + param 'String', :message + end + + def deprecation(key, message) + # depending on configuration setting of strict + case Puppet.settings[:strict] + when :off + # do nothing + when :error + fail("deprecation. #{key}. #{message}") + else + Puppet.warn_once('deprecation', key, message) + end + end +end -- cgit v1.2.3 From adf922c28441bc95f5cbac1f0951256c080b3298 Mon Sep 17 00:00:00 2001 From: Helen Campbell Date: Wed, 10 Aug 2016 14:17:16 +0100 Subject: (WIP) Addition of validate legacy function --- lib/puppet/functions/validate_legacy.rb | 54 +++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 lib/puppet/functions/validate_legacy.rb (limited to 'lib/puppet/functions') diff --git a/lib/puppet/functions/validate_legacy.rb b/lib/puppet/functions/validate_legacy.rb new file mode 100644 index 0000000..9d7d012 --- /dev/null +++ b/lib/puppet/functions/validate_legacy.rb @@ -0,0 +1,54 @@ +Puppet::Functions.create_function(:validate_legacy, Puppet::Functions::InternalFunction) do + # The function checks a value against both the target_type (new) and the previous_validation function (old). + + dispatch :validate_legacy do + param 'Type', :target_type + param 'String', :previous_validation + param 'NotUndef', :value + optional_param 'Any', :args + end + dispatch :validate_legacy_s do + scope_param + param 'String', :type_string + param 'String', :previous_validation + param 'NotUndef', :value + optional_repeated_param 'Any', :args + end + + def validate_legacy_s(scope, type_string, *args) + t = Puppet::Pops::Types::TypeParser.new.parse(type_string, scope) + validate_legacy(t, *args) + end + + def validate_legacy(target_type, previous_validation, value, *prev_args) + if assert_type(target_type, value) + if previous_validation(previous_validation, value, *prev_args) + # Silently passes + else + Puppet.warn("Accepting previously invalid value for target_type '#{target_type}'") + end + else + inferred_type = Puppet::Pops::Types::TypeCalculator.infer_set(value) + error_msg = Puppet::Pops::Types::TypeMismatchDescriber.new.describe_mismatch(previous_validation, target_type, inferred_type) + if previous_validation(previous_validation, value, *prev_args) + Puppet.warn(error_msg) + else + call_function('fail', error_msg) + end + end + end + + def previous_validation(previous_validation, value, *prev_args) + # Call the previous validation function and catch any errors. Return true if no errors are thrown. + begin + call_function(previous_validation, value, *prev_args) + true + rescue Puppet::ParseError + false + end + end + + def assert_type(type, value) + Puppet::Pops::Types::TypeCalculator.instance?(type, value) + end +end -- cgit v1.2.3 From 6c6c6d8e3448e3072d590a0782237486e46bc88d Mon Sep 17 00:00:00 2001 From: Helen Campbell Date: Tue, 23 Aug 2016 15:02:39 +0100 Subject: Deprecation function to be mutable in all cases --- lib/puppet/functions/deprecation.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/puppet/functions') diff --git a/lib/puppet/functions/deprecation.rb b/lib/puppet/functions/deprecation.rb index 3b84ae5..6b7b977 100644 --- a/lib/puppet/functions/deprecation.rb +++ b/lib/puppet/functions/deprecation.rb @@ -15,7 +15,7 @@ Puppet::Functions.create_function(:deprecation) do when :error fail("deprecation. #{key}. #{message}") else - Puppet.warn_once('deprecation', key, message) + Puppet.deprecation_warning(message, key) end end end -- cgit v1.2.3 From b63862ff43194194f7428739a32cfe13bad1e7ed Mon Sep 17 00:00:00 2001 From: Helen Campbell Date: Tue, 6 Sep 2016 15:00:07 +0100 Subject: Addition of logging with file and line numbers --- lib/puppet/functions/deprecation.rb | 8 +++++--- lib/puppet/functions/validate_legacy.rb | 4 +++- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'lib/puppet/functions') diff --git a/lib/puppet/functions/deprecation.rb b/lib/puppet/functions/deprecation.rb index 6b7b977..30aeb1d 100644 --- a/lib/puppet/functions/deprecation.rb +++ b/lib/puppet/functions/deprecation.rb @@ -1,5 +1,4 @@ # Function to print deprecation warnings, Logs a warning once for a given key. The uniqueness key - can appear once. The msg is the message text including any positional information that is formatted by the user/caller of the method It is affected by the puppet setting 'strict', which can be set to :error (outputs as an error message), :off (no message / error is displayed) and :warning (default, outputs a warning) *Type*: String, String. -# Puppet::Functions.create_function(:deprecation) do dispatch :deprecation do @@ -9,13 +8,16 @@ Puppet::Functions.create_function(:deprecation) do def deprecation(key, message) # depending on configuration setting of strict + caller_infos = caller.first.split(":") case Puppet.settings[:strict] when :off # do nothing when :error - fail("deprecation. #{key}. #{message}") + err_message = "#{message} : #{caller_infos[0]} : #{caller_infos[1]}" + fail("deprecation. #{key}. #{err_message}") else - Puppet.deprecation_warning(message, key) + err_message = "#{message} : #{caller_infos[0]} : #{caller_infos[1]}" + Puppet.deprecation_warning(err_message, key) end end end diff --git a/lib/puppet/functions/validate_legacy.rb b/lib/puppet/functions/validate_legacy.rb index 9d7d012..b1066e2 100644 --- a/lib/puppet/functions/validate_legacy.rb +++ b/lib/puppet/functions/validate_legacy.rb @@ -28,8 +28,10 @@ Puppet::Functions.create_function(:validate_legacy, Puppet::Functions::InternalF Puppet.warn("Accepting previously invalid value for target_type '#{target_type}'") end else + caller_infos = caller.first.split(":") inferred_type = Puppet::Pops::Types::TypeCalculator.infer_set(value) - error_msg = Puppet::Pops::Types::TypeMismatchDescriber.new.describe_mismatch(previous_validation, target_type, inferred_type) + message = Puppet::Pops::Types::TypeMismatchDescriber.new.describe_mismatch(previous_validation, target_type, inferred_type) + error_msg = "#{message} : #{caller_infos[0]} : #{caller_infos[1]}" if previous_validation(previous_validation, value, *prev_args) Puppet.warn(error_msg) else -- cgit v1.2.3 From f1edd2715a755573d7578839a3efe8473b79b5c5 Mon Sep 17 00:00:00 2001 From: David Schmitt Date: Tue, 6 Sep 2016 11:18:48 +0100 Subject: (MODULES-3737) validate_legacy: refactoring * validate_legacy now accepts undef values * update the TypeMismatch message to include the original validate function name * only notice, not warn, on newly allowed values * changed previous_validation to function_name to avoid confusion with the function of the same name * use deprecation() instead of warn(), when hitting a deprecated value * prepare the tests and function for MODULES-3735 * rewrite validate_legacy tests to use new rspec-puppet * move validate_re deprecation to puppet4 only * adapt validate_re_spec --- lib/puppet/functions/validate_legacy.rb | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) (limited to 'lib/puppet/functions') diff --git a/lib/puppet/functions/validate_legacy.rb b/lib/puppet/functions/validate_legacy.rb index b1066e2..0ba6dd8 100644 --- a/lib/puppet/functions/validate_legacy.rb +++ b/lib/puppet/functions/validate_legacy.rb @@ -2,48 +2,49 @@ Puppet::Functions.create_function(:validate_legacy, Puppet::Functions::InternalF # The function checks a value against both the target_type (new) and the previous_validation function (old). dispatch :validate_legacy do + scope_param param 'Type', :target_type - param 'String', :previous_validation - param 'NotUndef', :value - optional_param 'Any', :args + param 'String', :function_name + param 'Any', :value + optional_repeated_param 'Any', :args end + dispatch :validate_legacy_s do scope_param param 'String', :type_string - param 'String', :previous_validation - param 'NotUndef', :value + param 'String', :function_name + param 'Any', :value optional_repeated_param 'Any', :args end def validate_legacy_s(scope, type_string, *args) t = Puppet::Pops::Types::TypeParser.new.parse(type_string, scope) - validate_legacy(t, *args) + validate_legacy(scope, t, *args) end - def validate_legacy(target_type, previous_validation, value, *prev_args) + def validate_legacy(scope, target_type, function_name, value, *prev_args) if assert_type(target_type, value) - if previous_validation(previous_validation, value, *prev_args) + if previous_validation(scope, function_name, value, *prev_args) # Silently passes else - Puppet.warn("Accepting previously invalid value for target_type '#{target_type}'") + Puppet.notice("Accepting previously invalid value for target type '#{target_type}'") end else caller_infos = caller.first.split(":") inferred_type = Puppet::Pops::Types::TypeCalculator.infer_set(value) - message = Puppet::Pops::Types::TypeMismatchDescriber.new.describe_mismatch(previous_validation, target_type, inferred_type) - error_msg = "#{message} : #{caller_infos[0]} : #{caller_infos[1]}" - if previous_validation(previous_validation, value, *prev_args) - Puppet.warn(error_msg) + error_msg = Puppet::Pops::Types::TypeMismatchDescriber.new.describe_mismatch("validate_legacy(#{function_name}) [#{caller_infos[0]}:#{caller_infos[1]}]", target_type, inferred_type) + if previous_validation(scope, function_name, value, *prev_args) + call_function('deprecation', 'validate_legacy', error_msg) else call_function('fail', error_msg) end end end - def previous_validation(previous_validation, value, *prev_args) + def previous_validation(scope, function_name, value, *prev_args) # Call the previous validation function and catch any errors. Return true if no errors are thrown. begin - call_function(previous_validation, value, *prev_args) + scope.send("function_#{function_name}".to_s, [value, *prev_args]) true rescue Puppet::ParseError false -- cgit v1.2.3 From 0ec7ffa5c086c8a1c6e871b086299dd1953fa8ba Mon Sep 17 00:00:00 2001 From: Helen Campbell Date: Thu, 15 Sep 2016 11:35:38 +0100 Subject: Ensure validate functions use Puppet 4 deprecation --- lib/puppet/functions/validate_absolute_path.rb | 3 +++ lib/puppet/functions/validate_array.rb | 3 +++ lib/puppet/functions/validate_bool.rb | 3 +++ lib/puppet/functions/validate_hash.rb | 3 +++ lib/puppet/functions/validate_integer.rb | 3 +++ lib/puppet/functions/validate_ip_address.rb | 3 +++ lib/puppet/functions/validate_ipv4_address.rb | 3 +++ lib/puppet/functions/validate_ipv6_address.rb | 3 +++ lib/puppet/functions/validate_numeric.rb | 3 +++ lib/puppet/functions/validate_re.rb | 3 +++ lib/puppet/functions/validate_string.rb | 3 +++ 11 files changed, 33 insertions(+) create mode 100644 lib/puppet/functions/validate_absolute_path.rb create mode 100644 lib/puppet/functions/validate_array.rb create mode 100644 lib/puppet/functions/validate_bool.rb create mode 100644 lib/puppet/functions/validate_hash.rb create mode 100644 lib/puppet/functions/validate_integer.rb create mode 100644 lib/puppet/functions/validate_ip_address.rb create mode 100644 lib/puppet/functions/validate_ipv4_address.rb create mode 100644 lib/puppet/functions/validate_ipv6_address.rb create mode 100644 lib/puppet/functions/validate_numeric.rb create mode 100644 lib/puppet/functions/validate_re.rb create mode 100644 lib/puppet/functions/validate_string.rb (limited to 'lib/puppet/functions') diff --git a/lib/puppet/functions/validate_absolute_path.rb b/lib/puppet/functions/validate_absolute_path.rb new file mode 100644 index 0000000..5ae9d29 --- /dev/null +++ b/lib/puppet/functions/validate_absolute_path.rb @@ -0,0 +1,3 @@ +require 'puppet_x/puppetlabs/stdlib/deprecation_gen' +PuppetX::Puppetlabs::Stdlib.deprecation_gen("validate_absolute_path", "Stdlib::Compat::Absolute_Path") +# Puppet::Functions.create_function diff --git a/lib/puppet/functions/validate_array.rb b/lib/puppet/functions/validate_array.rb new file mode 100644 index 0000000..9155784 --- /dev/null +++ b/lib/puppet/functions/validate_array.rb @@ -0,0 +1,3 @@ +require 'puppet_x/puppetlabs/stdlib/deprecation_gen' +PuppetX::Puppetlabs::Stdlib.deprecation_gen("validate_array", "Stdlib::Compat::Array") +# Puppet::Functions.create_function diff --git a/lib/puppet/functions/validate_bool.rb b/lib/puppet/functions/validate_bool.rb new file mode 100644 index 0000000..10f6edf --- /dev/null +++ b/lib/puppet/functions/validate_bool.rb @@ -0,0 +1,3 @@ +require 'puppet_x/puppetlabs/stdlib/deprecation_gen' +PuppetX::Puppetlabs::Stdlib.deprecation_gen("validate_bool", "Stdlib::Compat::Bool") +# Puppet::Functions.create_function diff --git a/lib/puppet/functions/validate_hash.rb b/lib/puppet/functions/validate_hash.rb new file mode 100644 index 0000000..5349664 --- /dev/null +++ b/lib/puppet/functions/validate_hash.rb @@ -0,0 +1,3 @@ +require 'puppet_x/puppetlabs/stdlib/deprecation_gen' +PuppetX::Puppetlabs::Stdlib.deprecation_gen("validate_hash", "Stdlib::Compat::Hash") +# Puppet::Functions.create_function diff --git a/lib/puppet/functions/validate_integer.rb b/lib/puppet/functions/validate_integer.rb new file mode 100644 index 0000000..2c4645d --- /dev/null +++ b/lib/puppet/functions/validate_integer.rb @@ -0,0 +1,3 @@ +require 'puppet_x/puppetlabs/stdlib/deprecation_gen' +PuppetX::Puppetlabs::Stdlib.deprecation_gen("validate_integer", "Stdlib::Compat::Integer") +# Puppet::Functions.create_function diff --git a/lib/puppet/functions/validate_ip_address.rb b/lib/puppet/functions/validate_ip_address.rb new file mode 100644 index 0000000..15a710e --- /dev/null +++ b/lib/puppet/functions/validate_ip_address.rb @@ -0,0 +1,3 @@ +require 'puppet_x/puppetlabs/stdlib/deprecation_gen' +PuppetX::Puppetlabs::Stdlib.deprecation_gen("validate_ip_address", "Stdlib::Compat::Ip_Address") +# Puppet::Functions.create_function diff --git a/lib/puppet/functions/validate_ipv4_address.rb b/lib/puppet/functions/validate_ipv4_address.rb new file mode 100644 index 0000000..8e1bc59 --- /dev/null +++ b/lib/puppet/functions/validate_ipv4_address.rb @@ -0,0 +1,3 @@ +require 'puppet_x/puppetlabs/stdlib/deprecation_gen' +PuppetX::Puppetlabs::Stdlib.deprecation_gen("validate_ipv4_address", "Stdlib::Compat::Ipv4_Address") +# Puppet::Functions.create_function diff --git a/lib/puppet/functions/validate_ipv6_address.rb b/lib/puppet/functions/validate_ipv6_address.rb new file mode 100644 index 0000000..865648a --- /dev/null +++ b/lib/puppet/functions/validate_ipv6_address.rb @@ -0,0 +1,3 @@ +require 'puppet_x/puppetlabs/stdlib/deprecation_gen' +PuppetX::Puppetlabs::Stdlib.deprecation_gen("validate_ipv6_address", "Stdlib::Compat::Ipv6_address") +# Puppet::Functions.create_function diff --git a/lib/puppet/functions/validate_numeric.rb b/lib/puppet/functions/validate_numeric.rb new file mode 100644 index 0000000..0c2e1f2 --- /dev/null +++ b/lib/puppet/functions/validate_numeric.rb @@ -0,0 +1,3 @@ +require 'puppet_x/puppetlabs/stdlib/deprecation_gen' +PuppetX::Puppetlabs::Stdlib.deprecation_gen("validate_numeric", "Stdlib::Compat::Numeric") +# Puppet::Functions.create_function diff --git a/lib/puppet/functions/validate_re.rb b/lib/puppet/functions/validate_re.rb new file mode 100644 index 0000000..d63ed42 --- /dev/null +++ b/lib/puppet/functions/validate_re.rb @@ -0,0 +1,3 @@ +require 'puppet_x/puppetlabs/stdlib/deprecation_gen' +PuppetX::Puppetlabs::Stdlib.deprecation_gen("validate_re", "Stdlib::Compat::Re") +# Puppet::Functions.create_function diff --git a/lib/puppet/functions/validate_string.rb b/lib/puppet/functions/validate_string.rb new file mode 100644 index 0000000..a196f43 --- /dev/null +++ b/lib/puppet/functions/validate_string.rb @@ -0,0 +1,3 @@ +require 'puppet_x/puppetlabs/stdlib/deprecation_gen' +PuppetX::Puppetlabs::Stdlib.deprecation_gen("validate_string", "Stdlib::Compat::String") +# Puppet::Functions.create_function -- cgit v1.2.3 From 69c69e750bdaee7d5eec264650551b149538de92 Mon Sep 17 00:00:00 2001 From: Helen Date: Wed, 21 Sep 2016 16:22:37 +0100 Subject: Revert "Ensure validate functions use Puppet 4 deprecation" --- lib/puppet/functions/validate_absolute_path.rb | 3 --- lib/puppet/functions/validate_array.rb | 3 --- lib/puppet/functions/validate_bool.rb | 3 --- lib/puppet/functions/validate_hash.rb | 3 --- lib/puppet/functions/validate_integer.rb | 3 --- lib/puppet/functions/validate_ip_address.rb | 3 --- lib/puppet/functions/validate_ipv4_address.rb | 3 --- lib/puppet/functions/validate_ipv6_address.rb | 3 --- lib/puppet/functions/validate_numeric.rb | 3 --- lib/puppet/functions/validate_re.rb | 3 --- lib/puppet/functions/validate_string.rb | 3 --- 11 files changed, 33 deletions(-) delete mode 100644 lib/puppet/functions/validate_absolute_path.rb delete mode 100644 lib/puppet/functions/validate_array.rb delete mode 100644 lib/puppet/functions/validate_bool.rb delete mode 100644 lib/puppet/functions/validate_hash.rb delete mode 100644 lib/puppet/functions/validate_integer.rb delete mode 100644 lib/puppet/functions/validate_ip_address.rb delete mode 100644 lib/puppet/functions/validate_ipv4_address.rb delete mode 100644 lib/puppet/functions/validate_ipv6_address.rb delete mode 100644 lib/puppet/functions/validate_numeric.rb delete mode 100644 lib/puppet/functions/validate_re.rb delete mode 100644 lib/puppet/functions/validate_string.rb (limited to 'lib/puppet/functions') diff --git a/lib/puppet/functions/validate_absolute_path.rb b/lib/puppet/functions/validate_absolute_path.rb deleted file mode 100644 index 5ae9d29..0000000 --- a/lib/puppet/functions/validate_absolute_path.rb +++ /dev/null @@ -1,3 +0,0 @@ -require 'puppet_x/puppetlabs/stdlib/deprecation_gen' -PuppetX::Puppetlabs::Stdlib.deprecation_gen("validate_absolute_path", "Stdlib::Compat::Absolute_Path") -# Puppet::Functions.create_function diff --git a/lib/puppet/functions/validate_array.rb b/lib/puppet/functions/validate_array.rb deleted file mode 100644 index 9155784..0000000 --- a/lib/puppet/functions/validate_array.rb +++ /dev/null @@ -1,3 +0,0 @@ -require 'puppet_x/puppetlabs/stdlib/deprecation_gen' -PuppetX::Puppetlabs::Stdlib.deprecation_gen("validate_array", "Stdlib::Compat::Array") -# Puppet::Functions.create_function diff --git a/lib/puppet/functions/validate_bool.rb b/lib/puppet/functions/validate_bool.rb deleted file mode 100644 index 10f6edf..0000000 --- a/lib/puppet/functions/validate_bool.rb +++ /dev/null @@ -1,3 +0,0 @@ -require 'puppet_x/puppetlabs/stdlib/deprecation_gen' -PuppetX::Puppetlabs::Stdlib.deprecation_gen("validate_bool", "Stdlib::Compat::Bool") -# Puppet::Functions.create_function diff --git a/lib/puppet/functions/validate_hash.rb b/lib/puppet/functions/validate_hash.rb deleted file mode 100644 index 5349664..0000000 --- a/lib/puppet/functions/validate_hash.rb +++ /dev/null @@ -1,3 +0,0 @@ -require 'puppet_x/puppetlabs/stdlib/deprecation_gen' -PuppetX::Puppetlabs::Stdlib.deprecation_gen("validate_hash", "Stdlib::Compat::Hash") -# Puppet::Functions.create_function diff --git a/lib/puppet/functions/validate_integer.rb b/lib/puppet/functions/validate_integer.rb deleted file mode 100644 index 2c4645d..0000000 --- a/lib/puppet/functions/validate_integer.rb +++ /dev/null @@ -1,3 +0,0 @@ -require 'puppet_x/puppetlabs/stdlib/deprecation_gen' -PuppetX::Puppetlabs::Stdlib.deprecation_gen("validate_integer", "Stdlib::Compat::Integer") -# Puppet::Functions.create_function diff --git a/lib/puppet/functions/validate_ip_address.rb b/lib/puppet/functions/validate_ip_address.rb deleted file mode 100644 index 15a710e..0000000 --- a/lib/puppet/functions/validate_ip_address.rb +++ /dev/null @@ -1,3 +0,0 @@ -require 'puppet_x/puppetlabs/stdlib/deprecation_gen' -PuppetX::Puppetlabs::Stdlib.deprecation_gen("validate_ip_address", "Stdlib::Compat::Ip_Address") -# Puppet::Functions.create_function diff --git a/lib/puppet/functions/validate_ipv4_address.rb b/lib/puppet/functions/validate_ipv4_address.rb deleted file mode 100644 index 8e1bc59..0000000 --- a/lib/puppet/functions/validate_ipv4_address.rb +++ /dev/null @@ -1,3 +0,0 @@ -require 'puppet_x/puppetlabs/stdlib/deprecation_gen' -PuppetX::Puppetlabs::Stdlib.deprecation_gen("validate_ipv4_address", "Stdlib::Compat::Ipv4_Address") -# Puppet::Functions.create_function diff --git a/lib/puppet/functions/validate_ipv6_address.rb b/lib/puppet/functions/validate_ipv6_address.rb deleted file mode 100644 index 865648a..0000000 --- a/lib/puppet/functions/validate_ipv6_address.rb +++ /dev/null @@ -1,3 +0,0 @@ -require 'puppet_x/puppetlabs/stdlib/deprecation_gen' -PuppetX::Puppetlabs::Stdlib.deprecation_gen("validate_ipv6_address", "Stdlib::Compat::Ipv6_address") -# Puppet::Functions.create_function diff --git a/lib/puppet/functions/validate_numeric.rb b/lib/puppet/functions/validate_numeric.rb deleted file mode 100644 index 0c2e1f2..0000000 --- a/lib/puppet/functions/validate_numeric.rb +++ /dev/null @@ -1,3 +0,0 @@ -require 'puppet_x/puppetlabs/stdlib/deprecation_gen' -PuppetX::Puppetlabs::Stdlib.deprecation_gen("validate_numeric", "Stdlib::Compat::Numeric") -# Puppet::Functions.create_function diff --git a/lib/puppet/functions/validate_re.rb b/lib/puppet/functions/validate_re.rb deleted file mode 100644 index d63ed42..0000000 --- a/lib/puppet/functions/validate_re.rb +++ /dev/null @@ -1,3 +0,0 @@ -require 'puppet_x/puppetlabs/stdlib/deprecation_gen' -PuppetX::Puppetlabs::Stdlib.deprecation_gen("validate_re", "Stdlib::Compat::Re") -# Puppet::Functions.create_function diff --git a/lib/puppet/functions/validate_string.rb b/lib/puppet/functions/validate_string.rb deleted file mode 100644 index a196f43..0000000 --- a/lib/puppet/functions/validate_string.rb +++ /dev/null @@ -1,3 +0,0 @@ -require 'puppet_x/puppetlabs/stdlib/deprecation_gen' -PuppetX::Puppetlabs::Stdlib.deprecation_gen("validate_string", "Stdlib::Compat::String") -# Puppet::Functions.create_function -- cgit v1.2.3 From 970852dd317fbb2699b406dd25aeddef496a7c92 Mon Sep 17 00:00:00 2001 From: Helen Campbell Date: Mon, 3 Oct 2016 14:10:50 +0100 Subject: Addition of Puppet 4 functions --- lib/puppet/functions/validate_absolute_path.rb | 3 +++ lib/puppet/functions/validate_array.rb | 3 +++ lib/puppet/functions/validate_bool.rb | 3 +++ lib/puppet/functions/validate_hash.rb | 3 +++ lib/puppet/functions/validate_integer.rb | 3 +++ lib/puppet/functions/validate_ip_address.rb | 3 +++ lib/puppet/functions/validate_ipv4_address.rb | 3 +++ lib/puppet/functions/validate_ipv6_address.rb | 3 +++ lib/puppet/functions/validate_numeric.rb | 3 +++ lib/puppet/functions/validate_re.rb | 3 +++ lib/puppet/functions/validate_string.rb | 3 +++ 11 files changed, 33 insertions(+) create mode 100644 lib/puppet/functions/validate_absolute_path.rb create mode 100644 lib/puppet/functions/validate_array.rb create mode 100644 lib/puppet/functions/validate_bool.rb create mode 100644 lib/puppet/functions/validate_hash.rb create mode 100644 lib/puppet/functions/validate_integer.rb create mode 100644 lib/puppet/functions/validate_ip_address.rb create mode 100644 lib/puppet/functions/validate_ipv4_address.rb create mode 100644 lib/puppet/functions/validate_ipv6_address.rb create mode 100644 lib/puppet/functions/validate_numeric.rb create mode 100644 lib/puppet/functions/validate_re.rb create mode 100644 lib/puppet/functions/validate_string.rb (limited to 'lib/puppet/functions') diff --git a/lib/puppet/functions/validate_absolute_path.rb b/lib/puppet/functions/validate_absolute_path.rb new file mode 100644 index 0000000..5ae9d29 --- /dev/null +++ b/lib/puppet/functions/validate_absolute_path.rb @@ -0,0 +1,3 @@ +require 'puppet_x/puppetlabs/stdlib/deprecation_gen' +PuppetX::Puppetlabs::Stdlib.deprecation_gen("validate_absolute_path", "Stdlib::Compat::Absolute_Path") +# Puppet::Functions.create_function diff --git a/lib/puppet/functions/validate_array.rb b/lib/puppet/functions/validate_array.rb new file mode 100644 index 0000000..9155784 --- /dev/null +++ b/lib/puppet/functions/validate_array.rb @@ -0,0 +1,3 @@ +require 'puppet_x/puppetlabs/stdlib/deprecation_gen' +PuppetX::Puppetlabs::Stdlib.deprecation_gen("validate_array", "Stdlib::Compat::Array") +# Puppet::Functions.create_function diff --git a/lib/puppet/functions/validate_bool.rb b/lib/puppet/functions/validate_bool.rb new file mode 100644 index 0000000..10f6edf --- /dev/null +++ b/lib/puppet/functions/validate_bool.rb @@ -0,0 +1,3 @@ +require 'puppet_x/puppetlabs/stdlib/deprecation_gen' +PuppetX::Puppetlabs::Stdlib.deprecation_gen("validate_bool", "Stdlib::Compat::Bool") +# Puppet::Functions.create_function diff --git a/lib/puppet/functions/validate_hash.rb b/lib/puppet/functions/validate_hash.rb new file mode 100644 index 0000000..5349664 --- /dev/null +++ b/lib/puppet/functions/validate_hash.rb @@ -0,0 +1,3 @@ +require 'puppet_x/puppetlabs/stdlib/deprecation_gen' +PuppetX::Puppetlabs::Stdlib.deprecation_gen("validate_hash", "Stdlib::Compat::Hash") +# Puppet::Functions.create_function diff --git a/lib/puppet/functions/validate_integer.rb b/lib/puppet/functions/validate_integer.rb new file mode 100644 index 0000000..2c4645d --- /dev/null +++ b/lib/puppet/functions/validate_integer.rb @@ -0,0 +1,3 @@ +require 'puppet_x/puppetlabs/stdlib/deprecation_gen' +PuppetX::Puppetlabs::Stdlib.deprecation_gen("validate_integer", "Stdlib::Compat::Integer") +# Puppet::Functions.create_function diff --git a/lib/puppet/functions/validate_ip_address.rb b/lib/puppet/functions/validate_ip_address.rb new file mode 100644 index 0000000..15a710e --- /dev/null +++ b/lib/puppet/functions/validate_ip_address.rb @@ -0,0 +1,3 @@ +require 'puppet_x/puppetlabs/stdlib/deprecation_gen' +PuppetX::Puppetlabs::Stdlib.deprecation_gen("validate_ip_address", "Stdlib::Compat::Ip_Address") +# Puppet::Functions.create_function diff --git a/lib/puppet/functions/validate_ipv4_address.rb b/lib/puppet/functions/validate_ipv4_address.rb new file mode 100644 index 0000000..8e1bc59 --- /dev/null +++ b/lib/puppet/functions/validate_ipv4_address.rb @@ -0,0 +1,3 @@ +require 'puppet_x/puppetlabs/stdlib/deprecation_gen' +PuppetX::Puppetlabs::Stdlib.deprecation_gen("validate_ipv4_address", "Stdlib::Compat::Ipv4_Address") +# Puppet::Functions.create_function diff --git a/lib/puppet/functions/validate_ipv6_address.rb b/lib/puppet/functions/validate_ipv6_address.rb new file mode 100644 index 0000000..865648a --- /dev/null +++ b/lib/puppet/functions/validate_ipv6_address.rb @@ -0,0 +1,3 @@ +require 'puppet_x/puppetlabs/stdlib/deprecation_gen' +PuppetX::Puppetlabs::Stdlib.deprecation_gen("validate_ipv6_address", "Stdlib::Compat::Ipv6_address") +# Puppet::Functions.create_function diff --git a/lib/puppet/functions/validate_numeric.rb b/lib/puppet/functions/validate_numeric.rb new file mode 100644 index 0000000..0c2e1f2 --- /dev/null +++ b/lib/puppet/functions/validate_numeric.rb @@ -0,0 +1,3 @@ +require 'puppet_x/puppetlabs/stdlib/deprecation_gen' +PuppetX::Puppetlabs::Stdlib.deprecation_gen("validate_numeric", "Stdlib::Compat::Numeric") +# Puppet::Functions.create_function diff --git a/lib/puppet/functions/validate_re.rb b/lib/puppet/functions/validate_re.rb new file mode 100644 index 0000000..d63ed42 --- /dev/null +++ b/lib/puppet/functions/validate_re.rb @@ -0,0 +1,3 @@ +require 'puppet_x/puppetlabs/stdlib/deprecation_gen' +PuppetX::Puppetlabs::Stdlib.deprecation_gen("validate_re", "Stdlib::Compat::Re") +# Puppet::Functions.create_function diff --git a/lib/puppet/functions/validate_string.rb b/lib/puppet/functions/validate_string.rb new file mode 100644 index 0000000..a196f43 --- /dev/null +++ b/lib/puppet/functions/validate_string.rb @@ -0,0 +1,3 @@ +require 'puppet_x/puppetlabs/stdlib/deprecation_gen' +PuppetX::Puppetlabs::Stdlib.deprecation_gen("validate_string", "Stdlib::Compat::String") +# Puppet::Functions.create_function -- cgit v1.2.3 From a4ebae621dd4dc09d760a51b8b221a3250142789 Mon Sep 17 00:00:00 2001 From: David Schmitt Date: Fri, 7 Oct 2016 13:00:06 +0100 Subject: (FM-5703, PUP-6717) Remove the dynamic deprecation_gen This was not working when the puppet master did not have the newest stdlib version in its environment. --- lib/puppet/functions/validate_absolute_path.rb | 13 ++++++++++--- lib/puppet/functions/validate_array.rb | 13 ++++++++++--- lib/puppet/functions/validate_bool.rb | 13 ++++++++++--- lib/puppet/functions/validate_hash.rb | 13 ++++++++++--- lib/puppet/functions/validate_integer.rb | 13 ++++++++++--- lib/puppet/functions/validate_ip_address.rb | 13 ++++++++++--- lib/puppet/functions/validate_ipv4_address.rb | 13 ++++++++++--- lib/puppet/functions/validate_ipv6_address.rb | 13 ++++++++++--- lib/puppet/functions/validate_numeric.rb | 13 ++++++++++--- lib/puppet/functions/validate_re.rb | 13 ++++++++++--- lib/puppet/functions/validate_string.rb | 13 ++++++++++--- 11 files changed, 110 insertions(+), 33 deletions(-) (limited to 'lib/puppet/functions') diff --git a/lib/puppet/functions/validate_absolute_path.rb b/lib/puppet/functions/validate_absolute_path.rb index 5ae9d29..94f52e1 100644 --- a/lib/puppet/functions/validate_absolute_path.rb +++ b/lib/puppet/functions/validate_absolute_path.rb @@ -1,3 +1,10 @@ -require 'puppet_x/puppetlabs/stdlib/deprecation_gen' -PuppetX::Puppetlabs::Stdlib.deprecation_gen("validate_absolute_path", "Stdlib::Compat::Absolute_Path") -# Puppet::Functions.create_function +Puppet::Functions.create_function(:validate_absolute_path, Puppet::Functions::InternalFunction) do + dispatch :deprecation_gen do + scope_param + optional_repeated_param 'Any', :args + end + def deprecation_gen(scope, *args) + call_function('deprecation', 'puppet_3_type_check', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Absolute_Path. There is further documentation for validate_legacy function in the README.") + scope.send("function_validate_absolute_path", args) + end +end diff --git a/lib/puppet/functions/validate_array.rb b/lib/puppet/functions/validate_array.rb index 9155784..eb8f5e5 100644 --- a/lib/puppet/functions/validate_array.rb +++ b/lib/puppet/functions/validate_array.rb @@ -1,3 +1,10 @@ -require 'puppet_x/puppetlabs/stdlib/deprecation_gen' -PuppetX::Puppetlabs::Stdlib.deprecation_gen("validate_array", "Stdlib::Compat::Array") -# Puppet::Functions.create_function +Puppet::Functions.create_function(:validate_array, Puppet::Functions::InternalFunction) do + dispatch :deprecation_gen do + scope_param + optional_repeated_param 'Any', :args + end + def deprecation_gen(scope, *args) + call_function('deprecation', 'puppet_3_type_check', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Array. There is further documentation for validate_legacy function in the README.") + scope.send("function_validate_array", args) + end +end diff --git a/lib/puppet/functions/validate_bool.rb b/lib/puppet/functions/validate_bool.rb index 10f6edf..168775d 100644 --- a/lib/puppet/functions/validate_bool.rb +++ b/lib/puppet/functions/validate_bool.rb @@ -1,3 +1,10 @@ -require 'puppet_x/puppetlabs/stdlib/deprecation_gen' -PuppetX::Puppetlabs::Stdlib.deprecation_gen("validate_bool", "Stdlib::Compat::Bool") -# Puppet::Functions.create_function +Puppet::Functions.create_function(:validate_bool, Puppet::Functions::InternalFunction) do + dispatch :deprecation_gen do + scope_param + optional_repeated_param 'Any', :args + end + def deprecation_gen(scope, *args) + call_function('deprecation', 'puppet_3_type_check', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Bool. There is further documentation for validate_legacy function in the README.") + scope.send("function_validate_bool", args) + end +end diff --git a/lib/puppet/functions/validate_hash.rb b/lib/puppet/functions/validate_hash.rb index 5349664..c356ceb 100644 --- a/lib/puppet/functions/validate_hash.rb +++ b/lib/puppet/functions/validate_hash.rb @@ -1,3 +1,10 @@ -require 'puppet_x/puppetlabs/stdlib/deprecation_gen' -PuppetX::Puppetlabs::Stdlib.deprecation_gen("validate_hash", "Stdlib::Compat::Hash") -# Puppet::Functions.create_function +Puppet::Functions.create_function(:validate_hash, Puppet::Functions::InternalFunction) do + dispatch :deprecation_gen do + scope_param + optional_repeated_param 'Any', :args + end + def deprecation_gen(scope, *args) + call_function('deprecation', 'puppet_3_type_check', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Hash. There is further documentation for validate_legacy function in the README.") + scope.send("function_validate_hash", args) + end +end diff --git a/lib/puppet/functions/validate_integer.rb b/lib/puppet/functions/validate_integer.rb index 2c4645d..db95f1c 100644 --- a/lib/puppet/functions/validate_integer.rb +++ b/lib/puppet/functions/validate_integer.rb @@ -1,3 +1,10 @@ -require 'puppet_x/puppetlabs/stdlib/deprecation_gen' -PuppetX::Puppetlabs::Stdlib.deprecation_gen("validate_integer", "Stdlib::Compat::Integer") -# Puppet::Functions.create_function +Puppet::Functions.create_function(:validate_integer, Puppet::Functions::InternalFunction) do + dispatch :deprecation_gen do + scope_param + optional_repeated_param 'Any', :args + end + def deprecation_gen(scope, *args) + call_function('deprecation', 'puppet_3_type_check', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Integer. There is further documentation for validate_legacy function in the README.") + scope.send("function_validate_integer", args) + end +end diff --git a/lib/puppet/functions/validate_ip_address.rb b/lib/puppet/functions/validate_ip_address.rb index 15a710e..eaf56bb 100644 --- a/lib/puppet/functions/validate_ip_address.rb +++ b/lib/puppet/functions/validate_ip_address.rb @@ -1,3 +1,10 @@ -require 'puppet_x/puppetlabs/stdlib/deprecation_gen' -PuppetX::Puppetlabs::Stdlib.deprecation_gen("validate_ip_address", "Stdlib::Compat::Ip_Address") -# Puppet::Functions.create_function +Puppet::Functions.create_function(:validate_ip_address, Puppet::Functions::InternalFunction) do + dispatch :deprecation_gen do + scope_param + optional_repeated_param 'Any', :args + end + def deprecation_gen(scope, *args) + call_function('deprecation', 'puppet_3_type_check', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Ip_Address. There is further documentation for validate_legacy function in the README.") + scope.send("function_validate_ip_address", args) + end +end diff --git a/lib/puppet/functions/validate_ipv4_address.rb b/lib/puppet/functions/validate_ipv4_address.rb index 8e1bc59..6a870eb 100644 --- a/lib/puppet/functions/validate_ipv4_address.rb +++ b/lib/puppet/functions/validate_ipv4_address.rb @@ -1,3 +1,10 @@ -require 'puppet_x/puppetlabs/stdlib/deprecation_gen' -PuppetX::Puppetlabs::Stdlib.deprecation_gen("validate_ipv4_address", "Stdlib::Compat::Ipv4_Address") -# Puppet::Functions.create_function +Puppet::Functions.create_function(:validate_ipv4_address, Puppet::Functions::InternalFunction) do + dispatch :deprecation_gen do + scope_param + optional_repeated_param 'Any', :args + end + def deprecation_gen(scope, *args) + call_function('deprecation', 'puppet_3_type_check', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Ipv4_Address. There is further documentation for validate_legacy function in the README.") + scope.send("function_validate_ipv4_address", args) + end +end diff --git a/lib/puppet/functions/validate_ipv6_address.rb b/lib/puppet/functions/validate_ipv6_address.rb index 865648a..922a9ac 100644 --- a/lib/puppet/functions/validate_ipv6_address.rb +++ b/lib/puppet/functions/validate_ipv6_address.rb @@ -1,3 +1,10 @@ -require 'puppet_x/puppetlabs/stdlib/deprecation_gen' -PuppetX::Puppetlabs::Stdlib.deprecation_gen("validate_ipv6_address", "Stdlib::Compat::Ipv6_address") -# Puppet::Functions.create_function +Puppet::Functions.create_function(:validate_ipv6_address, Puppet::Functions::InternalFunction) do + dispatch :deprecation_gen do + scope_param + optional_repeated_param 'Any', :args + end + def deprecation_gen(scope, *args) + call_function('deprecation', 'puppet_3_type_check', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Ipv6_address. There is further documentation for validate_legacy function in the README.") + scope.send("function_validate_ipv6_address", args) + end +end diff --git a/lib/puppet/functions/validate_numeric.rb b/lib/puppet/functions/validate_numeric.rb index 0c2e1f2..e48bec4 100644 --- a/lib/puppet/functions/validate_numeric.rb +++ b/lib/puppet/functions/validate_numeric.rb @@ -1,3 +1,10 @@ -require 'puppet_x/puppetlabs/stdlib/deprecation_gen' -PuppetX::Puppetlabs::Stdlib.deprecation_gen("validate_numeric", "Stdlib::Compat::Numeric") -# Puppet::Functions.create_function +Puppet::Functions.create_function(:validate_numeric, Puppet::Functions::InternalFunction) do + dispatch :deprecation_gen do + scope_param + optional_repeated_param 'Any', :args + end + def deprecation_gen(scope, *args) + call_function('deprecation', 'puppet_3_type_check', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Numeric. There is further documentation for validate_legacy function in the README.") + scope.send("function_validate_numeric", args) + end +end diff --git a/lib/puppet/functions/validate_re.rb b/lib/puppet/functions/validate_re.rb index d63ed42..8a95077 100644 --- a/lib/puppet/functions/validate_re.rb +++ b/lib/puppet/functions/validate_re.rb @@ -1,3 +1,10 @@ -require 'puppet_x/puppetlabs/stdlib/deprecation_gen' -PuppetX::Puppetlabs::Stdlib.deprecation_gen("validate_re", "Stdlib::Compat::Re") -# Puppet::Functions.create_function +Puppet::Functions.create_function(:validate_re, Puppet::Functions::InternalFunction) do + dispatch :deprecation_gen do + scope_param + optional_repeated_param 'Any', :args + end + def deprecation_gen(scope, *args) + call_function('deprecation', 'puppet_3_type_check', "This method is deprecated, please use the stdlib validate_legacy function, with Pattern[]. There is further documentation for validate_legacy function in the README.") + scope.send("function_validate_re", args) + end +end diff --git a/lib/puppet/functions/validate_string.rb b/lib/puppet/functions/validate_string.rb index a196f43..fe4c623 100644 --- a/lib/puppet/functions/validate_string.rb +++ b/lib/puppet/functions/validate_string.rb @@ -1,3 +1,10 @@ -require 'puppet_x/puppetlabs/stdlib/deprecation_gen' -PuppetX::Puppetlabs::Stdlib.deprecation_gen("validate_string", "Stdlib::Compat::String") -# Puppet::Functions.create_function +Puppet::Functions.create_function(:validate_string, Puppet::Functions::InternalFunction) do + dispatch :deprecation_gen do + scope_param + optional_repeated_param 'Any', :args + end + def deprecation_gen(scope, *args) + call_function('deprecation', 'puppet_3_type_check', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::String. There is further documentation for validate_legacy function in the README.") + scope.send("function_validate_string", args) + end +end -- cgit v1.2.3 From ddae9880025b6dfdc3b5a8c177548c8eb5e50a91 Mon Sep 17 00:00:00 2001 From: David Schmitt Date: Fri, 7 Oct 2016 13:00:16 +0100 Subject: (Maint) add missing validate_slength deprecation --- lib/puppet/functions/validate_slength.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 lib/puppet/functions/validate_slength.rb (limited to 'lib/puppet/functions') diff --git a/lib/puppet/functions/validate_slength.rb b/lib/puppet/functions/validate_slength.rb new file mode 100644 index 0000000..2d71a14 --- /dev/null +++ b/lib/puppet/functions/validate_slength.rb @@ -0,0 +1,10 @@ +Puppet::Functions.create_function(:validate_slength, Puppet::Functions::InternalFunction) do + dispatch :deprecation_gen do + scope_param + optional_repeated_param 'Any', :args + end + def deprecation_gen(scope, *args) + call_function('deprecation', 'puppet_3_type_check', "This method is deprecated, please use the stdlib validate_legacy function, with String[]. There is further documentation for validate_legacy function in the README.") + scope.send("function_validate_slength", args) + end +end -- cgit v1.2.3 From e44238a9c7da7ad4a872ba86cd103becadd51b3b Mon Sep 17 00:00:00 2001 From: David Schmitt Date: Sat, 8 Oct 2016 18:10:53 +0100 Subject: Revert "Addition of logging with file and line numbers" This reverts commit b63862ff43194194f7428739a32cfe13bad1e7ed, as it would only show the irrelevant first entry of the ruby stack trace. The puppetserver log does contain the full trace information, or you can use --strict=error to cause a hard failure when hitting a deprecation. # Conflicts: # lib/puppet/functions/validate_legacy.rb --- lib/puppet/functions/deprecation.rb | 8 +++----- lib/puppet/functions/validate_legacy.rb | 3 +-- 2 files changed, 4 insertions(+), 7 deletions(-) (limited to 'lib/puppet/functions') diff --git a/lib/puppet/functions/deprecation.rb b/lib/puppet/functions/deprecation.rb index 30aeb1d..6b7b977 100644 --- a/lib/puppet/functions/deprecation.rb +++ b/lib/puppet/functions/deprecation.rb @@ -1,4 +1,5 @@ # Function to print deprecation warnings, Logs a warning once for a given key. The uniqueness key - can appear once. The msg is the message text including any positional information that is formatted by the user/caller of the method It is affected by the puppet setting 'strict', which can be set to :error (outputs as an error message), :off (no message / error is displayed) and :warning (default, outputs a warning) *Type*: String, String. +# Puppet::Functions.create_function(:deprecation) do dispatch :deprecation do @@ -8,16 +9,13 @@ Puppet::Functions.create_function(:deprecation) do def deprecation(key, message) # depending on configuration setting of strict - caller_infos = caller.first.split(":") case Puppet.settings[:strict] when :off # do nothing when :error - err_message = "#{message} : #{caller_infos[0]} : #{caller_infos[1]}" - fail("deprecation. #{key}. #{err_message}") + fail("deprecation. #{key}. #{message}") else - err_message = "#{message} : #{caller_infos[0]} : #{caller_infos[1]}" - Puppet.deprecation_warning(err_message, key) + Puppet.deprecation_warning(message, key) end end end diff --git a/lib/puppet/functions/validate_legacy.rb b/lib/puppet/functions/validate_legacy.rb index 0ba6dd8..3f50459 100644 --- a/lib/puppet/functions/validate_legacy.rb +++ b/lib/puppet/functions/validate_legacy.rb @@ -30,9 +30,8 @@ Puppet::Functions.create_function(:validate_legacy, Puppet::Functions::InternalF Puppet.notice("Accepting previously invalid value for target type '#{target_type}'") end else - caller_infos = caller.first.split(":") inferred_type = Puppet::Pops::Types::TypeCalculator.infer_set(value) - error_msg = Puppet::Pops::Types::TypeMismatchDescriber.new.describe_mismatch("validate_legacy(#{function_name}) [#{caller_infos[0]}:#{caller_infos[1]}]", target_type, inferred_type) + error_msg = Puppet::Pops::Types::TypeMismatchDescriber.new.describe_mismatch("validate_legacy(#{function_name})", target_type, inferred_type) if previous_validation(scope, function_name, value, *prev_args) call_function('deprecation', 'validate_legacy', error_msg) else -- cgit v1.2.3 From bec521e6b79dd612a73e742d1cb6371e17ade1a9 Mon Sep 17 00:00:00 2001 From: David Schmitt Date: Sat, 8 Oct 2016 18:28:22 +0100 Subject: Update deprecation() so warnings can be disabled for CI --- lib/puppet/functions/deprecation.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/puppet/functions') diff --git a/lib/puppet/functions/deprecation.rb b/lib/puppet/functions/deprecation.rb index 6b7b977..a860aa2 100644 --- a/lib/puppet/functions/deprecation.rb +++ b/lib/puppet/functions/deprecation.rb @@ -15,7 +15,9 @@ Puppet::Functions.create_function(:deprecation) do when :error fail("deprecation. #{key}. #{message}") else - Puppet.deprecation_warning(message, key) + unless ENV['STDLIB_LOG_DEPRECATIONS'] == 'false' + Puppet.deprecation_warning(message, key) + end end end end -- cgit v1.2.3 From b92fad2b7667df836f8ca4eb92d8c8be84bd0538 Mon Sep 17 00:00:00 2001 From: David Schmitt Date: Wed, 12 Oct 2016 10:04:54 +0100 Subject: (MODULES-3961) emit more deprecation warnings This now emits one deprecation warning for each function used (but not for each call-site). Prior to this, only a single deprecation warning would have been triggered, potentially misleading users. Additionally this adds v4 deprecation stubs for the functions that were missed. --- lib/puppet/functions/is_absolute_path.rb | 10 ++++++++++ lib/puppet/functions/is_array.rb | 10 ++++++++++ lib/puppet/functions/is_bool.rb | 10 ++++++++++ lib/puppet/functions/is_float.rb | 10 ++++++++++ lib/puppet/functions/is_ip_address.rb | 10 ++++++++++ lib/puppet/functions/is_ipv4_address.rb | 10 ++++++++++ lib/puppet/functions/is_ipv6_address.rb | 10 ++++++++++ lib/puppet/functions/is_numeric.rb | 10 ++++++++++ lib/puppet/functions/is_string.rb | 10 ++++++++++ lib/puppet/functions/validate_absolute_path.rb | 2 +- lib/puppet/functions/validate_array.rb | 2 +- lib/puppet/functions/validate_bool.rb | 2 +- lib/puppet/functions/validate_hash.rb | 2 +- lib/puppet/functions/validate_integer.rb | 2 +- lib/puppet/functions/validate_ip_address.rb | 2 +- lib/puppet/functions/validate_ipv4_address.rb | 2 +- lib/puppet/functions/validate_ipv6_address.rb | 2 +- lib/puppet/functions/validate_numeric.rb | 2 +- lib/puppet/functions/validate_re.rb | 2 +- lib/puppet/functions/validate_slength.rb | 2 +- lib/puppet/functions/validate_string.rb | 2 +- 21 files changed, 102 insertions(+), 12 deletions(-) create mode 100644 lib/puppet/functions/is_absolute_path.rb create mode 100644 lib/puppet/functions/is_array.rb create mode 100644 lib/puppet/functions/is_bool.rb create mode 100644 lib/puppet/functions/is_float.rb create mode 100644 lib/puppet/functions/is_ip_address.rb create mode 100644 lib/puppet/functions/is_ipv4_address.rb create mode 100644 lib/puppet/functions/is_ipv6_address.rb create mode 100644 lib/puppet/functions/is_numeric.rb create mode 100644 lib/puppet/functions/is_string.rb (limited to 'lib/puppet/functions') diff --git a/lib/puppet/functions/is_absolute_path.rb b/lib/puppet/functions/is_absolute_path.rb new file mode 100644 index 0000000..0a100f8 --- /dev/null +++ b/lib/puppet/functions/is_absolute_path.rb @@ -0,0 +1,10 @@ +Puppet::Functions.create_function(:is_absolute_path, Puppet::Functions::InternalFunction) do + dispatch :deprecation_gen do + scope_param + optional_repeated_param 'Any', :args + end + def deprecation_gen(scope, *args) + call_function('deprecation', 'is_absolute_path', "This method is deprecated, please use match expressions with Stdlib::Compat::Absolute_Path instead. They are described at https://docs.puppet.com/puppet/latest/reference/lang_data_type.html#match-expressions.") + scope.send("function_is_absolute_path", args) + end +end diff --git a/lib/puppet/functions/is_array.rb b/lib/puppet/functions/is_array.rb new file mode 100644 index 0000000..0542a63 --- /dev/null +++ b/lib/puppet/functions/is_array.rb @@ -0,0 +1,10 @@ +Puppet::Functions.create_function(:is_array, Puppet::Functions::InternalFunction) do + dispatch :deprecation_gen do + scope_param + optional_repeated_param 'Any', :args + end + def deprecation_gen(scope, *args) + call_function('deprecation', 'is_array', "This method is deprecated, please use match expressions with Stdlib::Compat::Array instead. They are described at https://docs.puppet.com/puppet/latest/reference/lang_data_type.html#match-expressions.") + scope.send("function_is_array", args) + end +end diff --git a/lib/puppet/functions/is_bool.rb b/lib/puppet/functions/is_bool.rb new file mode 100644 index 0000000..ff1d462 --- /dev/null +++ b/lib/puppet/functions/is_bool.rb @@ -0,0 +1,10 @@ +Puppet::Functions.create_function(:is_bool, Puppet::Functions::InternalFunction) do + dispatch :deprecation_gen do + scope_param + optional_repeated_param 'Any', :args + end + def deprecation_gen(scope, *args) + call_function('deprecation', 'is_bool', "This method is deprecated, please use match expressions with Stdlib::Compat::Bool instead. They are described at https://docs.puppet.com/puppet/latest/reference/lang_data_type.html#match-expressions.") + scope.send("function_is_bool", args) + end +end diff --git a/lib/puppet/functions/is_float.rb b/lib/puppet/functions/is_float.rb new file mode 100644 index 0000000..b3763f2 --- /dev/null +++ b/lib/puppet/functions/is_float.rb @@ -0,0 +1,10 @@ +Puppet::Functions.create_function(:is_float, Puppet::Functions::InternalFunction) do + dispatch :deprecation_gen do + scope_param + optional_repeated_param 'Any', :args + end + def deprecation_gen(scope, *args) + call_function('deprecation', 'is_float', "This method is deprecated, please use match expressions with Stdlib::Compat::Float instead. They are described at https://docs.puppet.com/puppet/latest/reference/lang_data_type.html#match-expressions.") + scope.send("function_is_float", args) + end +end diff --git a/lib/puppet/functions/is_ip_address.rb b/lib/puppet/functions/is_ip_address.rb new file mode 100644 index 0000000..e584714 --- /dev/null +++ b/lib/puppet/functions/is_ip_address.rb @@ -0,0 +1,10 @@ +Puppet::Functions.create_function(:is_ip_address, Puppet::Functions::InternalFunction) do + dispatch :deprecation_gen do + scope_param + optional_repeated_param 'Any', :args + end + def deprecation_gen(scope, *args) + call_function('deprecation', 'is_ip_address', "This method is deprecated, please use match expressions with Stdlib::Compat::Ip_address instead. They are described at https://docs.puppet.com/puppet/latest/reference/lang_data_type.html#match-expressions.") + scope.send("function_is_ip_address", args) + end +end diff --git a/lib/puppet/functions/is_ipv4_address.rb b/lib/puppet/functions/is_ipv4_address.rb new file mode 100644 index 0000000..76c75e5 --- /dev/null +++ b/lib/puppet/functions/is_ipv4_address.rb @@ -0,0 +1,10 @@ +Puppet::Functions.create_function(:is_ipv4_address, Puppet::Functions::InternalFunction) do + dispatch :deprecation_gen do + scope_param + optional_repeated_param 'Any', :args + end + def deprecation_gen(scope, *args) + call_function('deprecation', 'is_ipv4_address', "This method is deprecated, please use match expressions with Stdlib::Compat::Ipv4 instead. They are described at https://docs.puppet.com/puppet/latest/reference/lang_data_type.html#match-expressions.") + scope.send("function_is_ipv4_address", args) + end +end diff --git a/lib/puppet/functions/is_ipv6_address.rb b/lib/puppet/functions/is_ipv6_address.rb new file mode 100644 index 0000000..dbf5282 --- /dev/null +++ b/lib/puppet/functions/is_ipv6_address.rb @@ -0,0 +1,10 @@ +Puppet::Functions.create_function(:is_ipv6_address, Puppet::Functions::InternalFunction) do + dispatch :deprecation_gen do + scope_param + optional_repeated_param 'Any', :args + end + def deprecation_gen(scope, *args) + call_function('deprecation', 'is_ipv4_address', "This method is deprecated, please use match expressions with Stdlib::Compat::Ipv6 instead. They are described at https://docs.puppet.com/puppet/latest/reference/lang_data_type.html#match-expressions.") + scope.send("function_is_ipv6_address", args) + end +end diff --git a/lib/puppet/functions/is_numeric.rb b/lib/puppet/functions/is_numeric.rb new file mode 100644 index 0000000..3a0f0cd --- /dev/null +++ b/lib/puppet/functions/is_numeric.rb @@ -0,0 +1,10 @@ +Puppet::Functions.create_function(:is_numeric, Puppet::Functions::InternalFunction) do + dispatch :deprecation_gen do + scope_param + optional_repeated_param 'Any', :args + end + def deprecation_gen(scope, *args) + call_function('deprecation', 'is_numeric', "This method is deprecated, please use match expressions with Stdlib::Compat::Numeric instead. They are described at https://docs.puppet.com/puppet/latest/reference/lang_data_type.html#match-expressions.") + scope.send("function_is_numeric", args) + end +end diff --git a/lib/puppet/functions/is_string.rb b/lib/puppet/functions/is_string.rb new file mode 100644 index 0000000..4978284 --- /dev/null +++ b/lib/puppet/functions/is_string.rb @@ -0,0 +1,10 @@ +Puppet::Functions.create_function(:is_string, Puppet::Functions::InternalFunction) do + dispatch :deprecation_gen do + scope_param + optional_repeated_param 'Any', :args + end + def deprecation_gen(scope, *args) + call_function('deprecation', 'is_string', "This method is deprecated, please use match expressions with Stdlib::Compat::String instead. They are described at https://docs.puppet.com/puppet/latest/reference/lang_data_type.html#match-expressions.") + scope.send("function_is_string", args) + end +end diff --git a/lib/puppet/functions/validate_absolute_path.rb b/lib/puppet/functions/validate_absolute_path.rb index 94f52e1..946ff31 100644 --- a/lib/puppet/functions/validate_absolute_path.rb +++ b/lib/puppet/functions/validate_absolute_path.rb @@ -4,7 +4,7 @@ Puppet::Functions.create_function(:validate_absolute_path, Puppet::Functions::In optional_repeated_param 'Any', :args end def deprecation_gen(scope, *args) - call_function('deprecation', 'puppet_3_type_check', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Absolute_Path. There is further documentation for validate_legacy function in the README.") + call_function('deprecation', 'validate_absolute_path', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Absolute_Path. There is further documentation for validate_legacy function in the README.") scope.send("function_validate_absolute_path", args) end end diff --git a/lib/puppet/functions/validate_array.rb b/lib/puppet/functions/validate_array.rb index eb8f5e5..c8553c4 100644 --- a/lib/puppet/functions/validate_array.rb +++ b/lib/puppet/functions/validate_array.rb @@ -4,7 +4,7 @@ Puppet::Functions.create_function(:validate_array, Puppet::Functions::InternalFu optional_repeated_param 'Any', :args end def deprecation_gen(scope, *args) - call_function('deprecation', 'puppet_3_type_check', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Array. There is further documentation for validate_legacy function in the README.") + call_function('deprecation', 'validate_array', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Array. There is further documentation for validate_legacy function in the README.") scope.send("function_validate_array", args) end end diff --git a/lib/puppet/functions/validate_bool.rb b/lib/puppet/functions/validate_bool.rb index 168775d..9d68cc9 100644 --- a/lib/puppet/functions/validate_bool.rb +++ b/lib/puppet/functions/validate_bool.rb @@ -4,7 +4,7 @@ Puppet::Functions.create_function(:validate_bool, Puppet::Functions::InternalFun optional_repeated_param 'Any', :args end def deprecation_gen(scope, *args) - call_function('deprecation', 'puppet_3_type_check', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Bool. There is further documentation for validate_legacy function in the README.") + call_function('deprecation', 'validate_bool', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Bool. There is further documentation for validate_legacy function in the README.") scope.send("function_validate_bool", args) end end diff --git a/lib/puppet/functions/validate_hash.rb b/lib/puppet/functions/validate_hash.rb index c356ceb..fdd8e01 100644 --- a/lib/puppet/functions/validate_hash.rb +++ b/lib/puppet/functions/validate_hash.rb @@ -4,7 +4,7 @@ Puppet::Functions.create_function(:validate_hash, Puppet::Functions::InternalFun optional_repeated_param 'Any', :args end def deprecation_gen(scope, *args) - call_function('deprecation', 'puppet_3_type_check', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Hash. There is further documentation for validate_legacy function in the README.") + call_function('deprecation', 'validate_hash', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Hash. There is further documentation for validate_legacy function in the README.") scope.send("function_validate_hash", args) end end diff --git a/lib/puppet/functions/validate_integer.rb b/lib/puppet/functions/validate_integer.rb index db95f1c..63a3523 100644 --- a/lib/puppet/functions/validate_integer.rb +++ b/lib/puppet/functions/validate_integer.rb @@ -4,7 +4,7 @@ Puppet::Functions.create_function(:validate_integer, Puppet::Functions::Internal optional_repeated_param 'Any', :args end def deprecation_gen(scope, *args) - call_function('deprecation', 'puppet_3_type_check', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Integer. There is further documentation for validate_legacy function in the README.") + call_function('deprecation', 'validate_integer', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Integer. There is further documentation for validate_legacy function in the README.") scope.send("function_validate_integer", args) end end diff --git a/lib/puppet/functions/validate_ip_address.rb b/lib/puppet/functions/validate_ip_address.rb index eaf56bb..c9c52bb 100644 --- a/lib/puppet/functions/validate_ip_address.rb +++ b/lib/puppet/functions/validate_ip_address.rb @@ -4,7 +4,7 @@ Puppet::Functions.create_function(:validate_ip_address, Puppet::Functions::Inter optional_repeated_param 'Any', :args end def deprecation_gen(scope, *args) - call_function('deprecation', 'puppet_3_type_check', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Ip_Address. There is further documentation for validate_legacy function in the README.") + call_function('deprecation', 'validate_ip_address', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Ip_Address. There is further documentation for validate_legacy function in the README.") scope.send("function_validate_ip_address", args) end end diff --git a/lib/puppet/functions/validate_ipv4_address.rb b/lib/puppet/functions/validate_ipv4_address.rb index 6a870eb..d501f7a 100644 --- a/lib/puppet/functions/validate_ipv4_address.rb +++ b/lib/puppet/functions/validate_ipv4_address.rb @@ -4,7 +4,7 @@ Puppet::Functions.create_function(:validate_ipv4_address, Puppet::Functions::Int optional_repeated_param 'Any', :args end def deprecation_gen(scope, *args) - call_function('deprecation', 'puppet_3_type_check', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Ipv4_Address. There is further documentation for validate_legacy function in the README.") + call_function('deprecation', 'validate_ipv4_address', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Ipv4_Address. There is further documentation for validate_legacy function in the README.") scope.send("function_validate_ipv4_address", args) end end diff --git a/lib/puppet/functions/validate_ipv6_address.rb b/lib/puppet/functions/validate_ipv6_address.rb index 922a9ac..aa8044f 100644 --- a/lib/puppet/functions/validate_ipv6_address.rb +++ b/lib/puppet/functions/validate_ipv6_address.rb @@ -4,7 +4,7 @@ Puppet::Functions.create_function(:validate_ipv6_address, Puppet::Functions::Int optional_repeated_param 'Any', :args end def deprecation_gen(scope, *args) - call_function('deprecation', 'puppet_3_type_check', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Ipv6_address. There is further documentation for validate_legacy function in the README.") + call_function('deprecation', 'validate_ipv6_address', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Ipv6_address. There is further documentation for validate_legacy function in the README.") scope.send("function_validate_ipv6_address", args) end end diff --git a/lib/puppet/functions/validate_numeric.rb b/lib/puppet/functions/validate_numeric.rb index e48bec4..7db5c90 100644 --- a/lib/puppet/functions/validate_numeric.rb +++ b/lib/puppet/functions/validate_numeric.rb @@ -4,7 +4,7 @@ Puppet::Functions.create_function(:validate_numeric, Puppet::Functions::Internal optional_repeated_param 'Any', :args end def deprecation_gen(scope, *args) - call_function('deprecation', 'puppet_3_type_check', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Numeric. There is further documentation for validate_legacy function in the README.") + call_function('deprecation', 'validate_numeric', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Numeric. There is further documentation for validate_legacy function in the README.") scope.send("function_validate_numeric", args) end end diff --git a/lib/puppet/functions/validate_re.rb b/lib/puppet/functions/validate_re.rb index 8a95077..ae5d9f1 100644 --- a/lib/puppet/functions/validate_re.rb +++ b/lib/puppet/functions/validate_re.rb @@ -4,7 +4,7 @@ Puppet::Functions.create_function(:validate_re, Puppet::Functions::InternalFunct optional_repeated_param 'Any', :args end def deprecation_gen(scope, *args) - call_function('deprecation', 'puppet_3_type_check', "This method is deprecated, please use the stdlib validate_legacy function, with Pattern[]. There is further documentation for validate_legacy function in the README.") + call_function('deprecation', 'validate_re', "This method is deprecated, please use the stdlib validate_legacy function, with Pattern[]. There is further documentation for validate_legacy function in the README.") scope.send("function_validate_re", args) end end diff --git a/lib/puppet/functions/validate_slength.rb b/lib/puppet/functions/validate_slength.rb index 2d71a14..c3c29a5 100644 --- a/lib/puppet/functions/validate_slength.rb +++ b/lib/puppet/functions/validate_slength.rb @@ -4,7 +4,7 @@ Puppet::Functions.create_function(:validate_slength, Puppet::Functions::Internal optional_repeated_param 'Any', :args end def deprecation_gen(scope, *args) - call_function('deprecation', 'puppet_3_type_check', "This method is deprecated, please use the stdlib validate_legacy function, with String[]. There is further documentation for validate_legacy function in the README.") + call_function('deprecation', 'validate_slength', "This method is deprecated, please use the stdlib validate_legacy function, with String[]. There is further documentation for validate_legacy function in the README.") scope.send("function_validate_slength", args) end end diff --git a/lib/puppet/functions/validate_string.rb b/lib/puppet/functions/validate_string.rb index fe4c623..9b0b731 100644 --- a/lib/puppet/functions/validate_string.rb +++ b/lib/puppet/functions/validate_string.rb @@ -4,7 +4,7 @@ Puppet::Functions.create_function(:validate_string, Puppet::Functions::InternalF optional_repeated_param 'Any', :args end def deprecation_gen(scope, *args) - call_function('deprecation', 'puppet_3_type_check', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::String. There is further documentation for validate_legacy function in the README.") + call_function('deprecation', 'validate_string', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::String. There is further documentation for validate_legacy function in the README.") scope.send("function_validate_string", args) end end -- cgit v1.2.3 From f2741dc814c1b6c10d8dd69c17aabf5bae106c17 Mon Sep 17 00:00:00 2001 From: David Schmitt Date: Wed, 12 Oct 2016 13:25:33 +0100 Subject: (MODULES-3962) Rework v4 function shims to work on puppet 3.7 and 4.0.0 This is a workaround for PUP-4438 (fixed in https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08, 4.1.0, 3.8.1). It works by manually passing through the scope, instead of relying on the InternalFunction class. --- lib/puppet/functions/is_absolute_path.rb | 11 ++++++++--- lib/puppet/functions/is_array.rb | 11 ++++++++--- lib/puppet/functions/is_bool.rb | 11 ++++++++--- lib/puppet/functions/is_float.rb | 11 ++++++++--- lib/puppet/functions/is_ip_address.rb | 11 ++++++++--- lib/puppet/functions/is_ipv4_address.rb | 11 ++++++++--- lib/puppet/functions/is_ipv6_address.rb | 11 ++++++++--- lib/puppet/functions/is_numeric.rb | 11 ++++++++--- lib/puppet/functions/is_string.rb | 11 ++++++++--- lib/puppet/functions/validate_absolute_path.rb | 11 ++++++++--- lib/puppet/functions/validate_array.rb | 11 ++++++++--- lib/puppet/functions/validate_bool.rb | 11 ++++++++--- lib/puppet/functions/validate_hash.rb | 11 ++++++++--- lib/puppet/functions/validate_integer.rb | 11 ++++++++--- lib/puppet/functions/validate_ip_address.rb | 11 ++++++++--- lib/puppet/functions/validate_ipv4_address.rb | 11 ++++++++--- lib/puppet/functions/validate_ipv6_address.rb | 11 ++++++++--- lib/puppet/functions/validate_legacy.rb | 16 +++++++++++----- lib/puppet/functions/validate_numeric.rb | 11 ++++++++--- lib/puppet/functions/validate_re.rb | 11 ++++++++--- lib/puppet/functions/validate_slength.rb | 11 ++++++++--- lib/puppet/functions/validate_string.rb | 11 ++++++++--- 22 files changed, 179 insertions(+), 68 deletions(-) (limited to 'lib/puppet/functions') diff --git a/lib/puppet/functions/is_absolute_path.rb b/lib/puppet/functions/is_absolute_path.rb index 0a100f8..b61064a 100644 --- a/lib/puppet/functions/is_absolute_path.rb +++ b/lib/puppet/functions/is_absolute_path.rb @@ -1,7 +1,12 @@ -Puppet::Functions.create_function(:is_absolute_path, Puppet::Functions::InternalFunction) do +Puppet::Functions.create_function(:is_absolute_path) do dispatch :deprecation_gen do - scope_param - optional_repeated_param 'Any', :args + param 'Any', :scope + repeated_param 'Any', :args + end + # Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1. + def call(scope, *args) + manipulated_args = [scope] + args + self.class.dispatcher.dispatch(self, scope, manipulated_args) end def deprecation_gen(scope, *args) call_function('deprecation', 'is_absolute_path', "This method is deprecated, please use match expressions with Stdlib::Compat::Absolute_Path instead. They are described at https://docs.puppet.com/puppet/latest/reference/lang_data_type.html#match-expressions.") diff --git a/lib/puppet/functions/is_array.rb b/lib/puppet/functions/is_array.rb index 0542a63..a29fe8a 100644 --- a/lib/puppet/functions/is_array.rb +++ b/lib/puppet/functions/is_array.rb @@ -1,7 +1,12 @@ -Puppet::Functions.create_function(:is_array, Puppet::Functions::InternalFunction) do +Puppet::Functions.create_function(:is_array) do dispatch :deprecation_gen do - scope_param - optional_repeated_param 'Any', :args + param 'Any', :scope + repeated_param 'Any', :args + end + # Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1. + def call(scope, *args) + manipulated_args = [scope] + args + self.class.dispatcher.dispatch(self, scope, manipulated_args) end def deprecation_gen(scope, *args) call_function('deprecation', 'is_array', "This method is deprecated, please use match expressions with Stdlib::Compat::Array instead. They are described at https://docs.puppet.com/puppet/latest/reference/lang_data_type.html#match-expressions.") diff --git a/lib/puppet/functions/is_bool.rb b/lib/puppet/functions/is_bool.rb index ff1d462..6e2c22b 100644 --- a/lib/puppet/functions/is_bool.rb +++ b/lib/puppet/functions/is_bool.rb @@ -1,7 +1,12 @@ -Puppet::Functions.create_function(:is_bool, Puppet::Functions::InternalFunction) do +Puppet::Functions.create_function(:is_bool) do dispatch :deprecation_gen do - scope_param - optional_repeated_param 'Any', :args + param 'Any', :scope + repeated_param 'Any', :args + end + # Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1. + def call(scope, *args) + manipulated_args = [scope] + args + self.class.dispatcher.dispatch(self, scope, manipulated_args) end def deprecation_gen(scope, *args) call_function('deprecation', 'is_bool', "This method is deprecated, please use match expressions with Stdlib::Compat::Bool instead. They are described at https://docs.puppet.com/puppet/latest/reference/lang_data_type.html#match-expressions.") diff --git a/lib/puppet/functions/is_float.rb b/lib/puppet/functions/is_float.rb index b3763f2..c91aa5d 100644 --- a/lib/puppet/functions/is_float.rb +++ b/lib/puppet/functions/is_float.rb @@ -1,7 +1,12 @@ -Puppet::Functions.create_function(:is_float, Puppet::Functions::InternalFunction) do +Puppet::Functions.create_function(:is_float) do dispatch :deprecation_gen do - scope_param - optional_repeated_param 'Any', :args + param 'Any', :scope + repeated_param 'Any', :args + end + # Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1. + def call(scope, *args) + manipulated_args = [scope] + args + self.class.dispatcher.dispatch(self, scope, manipulated_args) end def deprecation_gen(scope, *args) call_function('deprecation', 'is_float', "This method is deprecated, please use match expressions with Stdlib::Compat::Float instead. They are described at https://docs.puppet.com/puppet/latest/reference/lang_data_type.html#match-expressions.") diff --git a/lib/puppet/functions/is_ip_address.rb b/lib/puppet/functions/is_ip_address.rb index e584714..4c72037 100644 --- a/lib/puppet/functions/is_ip_address.rb +++ b/lib/puppet/functions/is_ip_address.rb @@ -1,7 +1,12 @@ -Puppet::Functions.create_function(:is_ip_address, Puppet::Functions::InternalFunction) do +Puppet::Functions.create_function(:is_ip_address) do dispatch :deprecation_gen do - scope_param - optional_repeated_param 'Any', :args + param 'Any', :scope + repeated_param 'Any', :args + end + # Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1. + def call(scope, *args) + manipulated_args = [scope] + args + self.class.dispatcher.dispatch(self, scope, manipulated_args) end def deprecation_gen(scope, *args) call_function('deprecation', 'is_ip_address', "This method is deprecated, please use match expressions with Stdlib::Compat::Ip_address instead. They are described at https://docs.puppet.com/puppet/latest/reference/lang_data_type.html#match-expressions.") diff --git a/lib/puppet/functions/is_ipv4_address.rb b/lib/puppet/functions/is_ipv4_address.rb index 76c75e5..97b01ae 100644 --- a/lib/puppet/functions/is_ipv4_address.rb +++ b/lib/puppet/functions/is_ipv4_address.rb @@ -1,7 +1,12 @@ -Puppet::Functions.create_function(:is_ipv4_address, Puppet::Functions::InternalFunction) do +Puppet::Functions.create_function(:is_ipv4_address) do dispatch :deprecation_gen do - scope_param - optional_repeated_param 'Any', :args + param 'Any', :scope + repeated_param 'Any', :args + end + # Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1. + def call(scope, *args) + manipulated_args = [scope] + args + self.class.dispatcher.dispatch(self, scope, manipulated_args) end def deprecation_gen(scope, *args) call_function('deprecation', 'is_ipv4_address', "This method is deprecated, please use match expressions with Stdlib::Compat::Ipv4 instead. They are described at https://docs.puppet.com/puppet/latest/reference/lang_data_type.html#match-expressions.") diff --git a/lib/puppet/functions/is_ipv6_address.rb b/lib/puppet/functions/is_ipv6_address.rb index dbf5282..be0c98a 100644 --- a/lib/puppet/functions/is_ipv6_address.rb +++ b/lib/puppet/functions/is_ipv6_address.rb @@ -1,7 +1,12 @@ -Puppet::Functions.create_function(:is_ipv6_address, Puppet::Functions::InternalFunction) do +Puppet::Functions.create_function(:is_ipv6_address) do dispatch :deprecation_gen do - scope_param - optional_repeated_param 'Any', :args + param 'Any', :scope + repeated_param 'Any', :args + end + # Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1. + def call(scope, *args) + manipulated_args = [scope] + args + self.class.dispatcher.dispatch(self, scope, manipulated_args) end def deprecation_gen(scope, *args) call_function('deprecation', 'is_ipv4_address', "This method is deprecated, please use match expressions with Stdlib::Compat::Ipv6 instead. They are described at https://docs.puppet.com/puppet/latest/reference/lang_data_type.html#match-expressions.") diff --git a/lib/puppet/functions/is_numeric.rb b/lib/puppet/functions/is_numeric.rb index 3a0f0cd..f5e9d41 100644 --- a/lib/puppet/functions/is_numeric.rb +++ b/lib/puppet/functions/is_numeric.rb @@ -1,7 +1,12 @@ -Puppet::Functions.create_function(:is_numeric, Puppet::Functions::InternalFunction) do +Puppet::Functions.create_function(:is_numeric) do dispatch :deprecation_gen do - scope_param - optional_repeated_param 'Any', :args + param 'Any', :scope + repeated_param 'Any', :args + end + # Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1. + def call(scope, *args) + manipulated_args = [scope] + args + self.class.dispatcher.dispatch(self, scope, manipulated_args) end def deprecation_gen(scope, *args) call_function('deprecation', 'is_numeric', "This method is deprecated, please use match expressions with Stdlib::Compat::Numeric instead. They are described at https://docs.puppet.com/puppet/latest/reference/lang_data_type.html#match-expressions.") diff --git a/lib/puppet/functions/is_string.rb b/lib/puppet/functions/is_string.rb index 4978284..a05a796 100644 --- a/lib/puppet/functions/is_string.rb +++ b/lib/puppet/functions/is_string.rb @@ -1,7 +1,12 @@ -Puppet::Functions.create_function(:is_string, Puppet::Functions::InternalFunction) do +Puppet::Functions.create_function(:is_string) do dispatch :deprecation_gen do - scope_param - optional_repeated_param 'Any', :args + param 'Any', :scope + repeated_param 'Any', :args + end + # Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1. + def call(scope, *args) + manipulated_args = [scope] + args + self.class.dispatcher.dispatch(self, scope, manipulated_args) end def deprecation_gen(scope, *args) call_function('deprecation', 'is_string', "This method is deprecated, please use match expressions with Stdlib::Compat::String instead. They are described at https://docs.puppet.com/puppet/latest/reference/lang_data_type.html#match-expressions.") diff --git a/lib/puppet/functions/validate_absolute_path.rb b/lib/puppet/functions/validate_absolute_path.rb index 946ff31..a3c696d 100644 --- a/lib/puppet/functions/validate_absolute_path.rb +++ b/lib/puppet/functions/validate_absolute_path.rb @@ -1,7 +1,12 @@ -Puppet::Functions.create_function(:validate_absolute_path, Puppet::Functions::InternalFunction) do +Puppet::Functions.create_function(:validate_absolute_path) do dispatch :deprecation_gen do - scope_param - optional_repeated_param 'Any', :args + param 'Any', :scope + repeated_param 'Any', :args + end + # Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1. + def call(scope, *args) + manipulated_args = [scope] + args + self.class.dispatcher.dispatch(self, scope, manipulated_args) end def deprecation_gen(scope, *args) call_function('deprecation', 'validate_absolute_path', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Absolute_Path. There is further documentation for validate_legacy function in the README.") diff --git a/lib/puppet/functions/validate_array.rb b/lib/puppet/functions/validate_array.rb index c8553c4..f59c6b4 100644 --- a/lib/puppet/functions/validate_array.rb +++ b/lib/puppet/functions/validate_array.rb @@ -1,7 +1,12 @@ -Puppet::Functions.create_function(:validate_array, Puppet::Functions::InternalFunction) do +Puppet::Functions.create_function(:validate_array) do dispatch :deprecation_gen do - scope_param - optional_repeated_param 'Any', :args + param 'Any', :scope + repeated_param 'Any', :args + end + # Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1. + def call(scope, *args) + manipulated_args = [scope] + args + self.class.dispatcher.dispatch(self, scope, manipulated_args) end def deprecation_gen(scope, *args) call_function('deprecation', 'validate_array', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Array. There is further documentation for validate_legacy function in the README.") diff --git a/lib/puppet/functions/validate_bool.rb b/lib/puppet/functions/validate_bool.rb index 9d68cc9..5cfb2ac 100644 --- a/lib/puppet/functions/validate_bool.rb +++ b/lib/puppet/functions/validate_bool.rb @@ -1,7 +1,12 @@ -Puppet::Functions.create_function(:validate_bool, Puppet::Functions::InternalFunction) do +Puppet::Functions.create_function(:validate_bool) do dispatch :deprecation_gen do - scope_param - optional_repeated_param 'Any', :args + param 'Any', :scope + repeated_param 'Any', :args + end + # Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1. + def call(scope, *args) + manipulated_args = [scope] + args + self.class.dispatcher.dispatch(self, scope, manipulated_args) end def deprecation_gen(scope, *args) call_function('deprecation', 'validate_bool', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Bool. There is further documentation for validate_legacy function in the README.") diff --git a/lib/puppet/functions/validate_hash.rb b/lib/puppet/functions/validate_hash.rb index fdd8e01..89ad9ab 100644 --- a/lib/puppet/functions/validate_hash.rb +++ b/lib/puppet/functions/validate_hash.rb @@ -1,7 +1,12 @@ -Puppet::Functions.create_function(:validate_hash, Puppet::Functions::InternalFunction) do +Puppet::Functions.create_function(:validate_hash) do dispatch :deprecation_gen do - scope_param - optional_repeated_param 'Any', :args + param 'Any', :scope + repeated_param 'Any', :args + end + # Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1. + def call(scope, *args) + manipulated_args = [scope] + args + self.class.dispatcher.dispatch(self, scope, manipulated_args) end def deprecation_gen(scope, *args) call_function('deprecation', 'validate_hash', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Hash. There is further documentation for validate_legacy function in the README.") diff --git a/lib/puppet/functions/validate_integer.rb b/lib/puppet/functions/validate_integer.rb index 63a3523..475ea0f 100644 --- a/lib/puppet/functions/validate_integer.rb +++ b/lib/puppet/functions/validate_integer.rb @@ -1,7 +1,12 @@ -Puppet::Functions.create_function(:validate_integer, Puppet::Functions::InternalFunction) do +Puppet::Functions.create_function(:validate_integer) do dispatch :deprecation_gen do - scope_param - optional_repeated_param 'Any', :args + param 'Any', :scope + repeated_param 'Any', :args + end + # Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1. + def call(scope, *args) + manipulated_args = [scope] + args + self.class.dispatcher.dispatch(self, scope, manipulated_args) end def deprecation_gen(scope, *args) call_function('deprecation', 'validate_integer', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Integer. There is further documentation for validate_legacy function in the README.") diff --git a/lib/puppet/functions/validate_ip_address.rb b/lib/puppet/functions/validate_ip_address.rb index c9c52bb..1521c08 100644 --- a/lib/puppet/functions/validate_ip_address.rb +++ b/lib/puppet/functions/validate_ip_address.rb @@ -1,7 +1,12 @@ -Puppet::Functions.create_function(:validate_ip_address, Puppet::Functions::InternalFunction) do +Puppet::Functions.create_function(:validate_ip_address) do dispatch :deprecation_gen do - scope_param - optional_repeated_param 'Any', :args + param 'Any', :scope + repeated_param 'Any', :args + end + # Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1. + def call(scope, *args) + manipulated_args = [scope] + args + self.class.dispatcher.dispatch(self, scope, manipulated_args) end def deprecation_gen(scope, *args) call_function('deprecation', 'validate_ip_address', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Ip_Address. There is further documentation for validate_legacy function in the README.") diff --git a/lib/puppet/functions/validate_ipv4_address.rb b/lib/puppet/functions/validate_ipv4_address.rb index d501f7a..fe66ab3 100644 --- a/lib/puppet/functions/validate_ipv4_address.rb +++ b/lib/puppet/functions/validate_ipv4_address.rb @@ -1,7 +1,12 @@ -Puppet::Functions.create_function(:validate_ipv4_address, Puppet::Functions::InternalFunction) do +Puppet::Functions.create_function(:validate_ipv4_address) do dispatch :deprecation_gen do - scope_param - optional_repeated_param 'Any', :args + param 'Any', :scope + repeated_param 'Any', :args + end + # Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1. + def call(scope, *args) + manipulated_args = [scope] + args + self.class.dispatcher.dispatch(self, scope, manipulated_args) end def deprecation_gen(scope, *args) call_function('deprecation', 'validate_ipv4_address', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Ipv4_Address. There is further documentation for validate_legacy function in the README.") diff --git a/lib/puppet/functions/validate_ipv6_address.rb b/lib/puppet/functions/validate_ipv6_address.rb index aa8044f..7cc3cbd 100644 --- a/lib/puppet/functions/validate_ipv6_address.rb +++ b/lib/puppet/functions/validate_ipv6_address.rb @@ -1,7 +1,12 @@ -Puppet::Functions.create_function(:validate_ipv6_address, Puppet::Functions::InternalFunction) do +Puppet::Functions.create_function(:validate_ipv6_address) do dispatch :deprecation_gen do - scope_param - optional_repeated_param 'Any', :args + param 'Any', :scope + repeated_param 'Any', :args + end + # Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1. + def call(scope, *args) + manipulated_args = [scope] + args + self.class.dispatcher.dispatch(self, scope, manipulated_args) end def deprecation_gen(scope, *args) call_function('deprecation', 'validate_ipv6_address', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Ipv6_address. There is further documentation for validate_legacy function in the README.") diff --git a/lib/puppet/functions/validate_legacy.rb b/lib/puppet/functions/validate_legacy.rb index 3f50459..c9d1f56 100644 --- a/lib/puppet/functions/validate_legacy.rb +++ b/lib/puppet/functions/validate_legacy.rb @@ -1,20 +1,26 @@ -Puppet::Functions.create_function(:validate_legacy, Puppet::Functions::InternalFunction) do +Puppet::Functions.create_function(:validate_legacy) do # The function checks a value against both the target_type (new) and the previous_validation function (old). dispatch :validate_legacy do - scope_param + param 'Any', :scope param 'Type', :target_type param 'String', :function_name param 'Any', :value - optional_repeated_param 'Any', :args + repeated_param 'Any', :args end dispatch :validate_legacy_s do - scope_param + param 'Any', :scope param 'String', :type_string param 'String', :function_name param 'Any', :value - optional_repeated_param 'Any', :args + repeated_param 'Any', :args + end + + # Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1. + def call(scope, *args) + manipulated_args = [scope] + args + self.class.dispatcher.dispatch(self, scope, manipulated_args) end def validate_legacy_s(scope, type_string, *args) diff --git a/lib/puppet/functions/validate_numeric.rb b/lib/puppet/functions/validate_numeric.rb index 7db5c90..3052d35 100644 --- a/lib/puppet/functions/validate_numeric.rb +++ b/lib/puppet/functions/validate_numeric.rb @@ -1,7 +1,12 @@ -Puppet::Functions.create_function(:validate_numeric, Puppet::Functions::InternalFunction) do +Puppet::Functions.create_function(:validate_numeric) do dispatch :deprecation_gen do - scope_param - optional_repeated_param 'Any', :args + param 'Any', :scope + repeated_param 'Any', :args + end + # Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1. + def call(scope, *args) + manipulated_args = [scope] + args + self.class.dispatcher.dispatch(self, scope, manipulated_args) end def deprecation_gen(scope, *args) call_function('deprecation', 'validate_numeric', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Numeric. There is further documentation for validate_legacy function in the README.") diff --git a/lib/puppet/functions/validate_re.rb b/lib/puppet/functions/validate_re.rb index ae5d9f1..19443a8 100644 --- a/lib/puppet/functions/validate_re.rb +++ b/lib/puppet/functions/validate_re.rb @@ -1,7 +1,12 @@ -Puppet::Functions.create_function(:validate_re, Puppet::Functions::InternalFunction) do +Puppet::Functions.create_function(:validate_re) do dispatch :deprecation_gen do - scope_param - optional_repeated_param 'Any', :args + param 'Any', :scope + repeated_param 'Any', :args + end + # Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1. + def call(scope, *args) + manipulated_args = [scope] + args + self.class.dispatcher.dispatch(self, scope, manipulated_args) end def deprecation_gen(scope, *args) call_function('deprecation', 'validate_re', "This method is deprecated, please use the stdlib validate_legacy function, with Pattern[]. There is further documentation for validate_legacy function in the README.") diff --git a/lib/puppet/functions/validate_slength.rb b/lib/puppet/functions/validate_slength.rb index c3c29a5..584232a 100644 --- a/lib/puppet/functions/validate_slength.rb +++ b/lib/puppet/functions/validate_slength.rb @@ -1,7 +1,12 @@ -Puppet::Functions.create_function(:validate_slength, Puppet::Functions::InternalFunction) do +Puppet::Functions.create_function(:validate_slength) do dispatch :deprecation_gen do - scope_param - optional_repeated_param 'Any', :args + param 'Any', :scope + repeated_param 'Any', :args + end + # Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1. + def call(scope, *args) + manipulated_args = [scope] + args + self.class.dispatcher.dispatch(self, scope, manipulated_args) end def deprecation_gen(scope, *args) call_function('deprecation', 'validate_slength', "This method is deprecated, please use the stdlib validate_legacy function, with String[]. There is further documentation for validate_legacy function in the README.") diff --git a/lib/puppet/functions/validate_string.rb b/lib/puppet/functions/validate_string.rb index 9b0b731..91ff004 100644 --- a/lib/puppet/functions/validate_string.rb +++ b/lib/puppet/functions/validate_string.rb @@ -1,7 +1,12 @@ -Puppet::Functions.create_function(:validate_string, Puppet::Functions::InternalFunction) do +Puppet::Functions.create_function(:validate_string) do dispatch :deprecation_gen do - scope_param - optional_repeated_param 'Any', :args + param 'Any', :scope + repeated_param 'Any', :args + end + # Workaround PUP-4438 (fixed: https://github.com/puppetlabs/puppet/commit/e01c4dc924cd963ff6630008a5200fc6a2023b08#diff-c937cc584953271bb3d3b3c2cb141790R221) to support puppet < 4.1.0 and puppet < 3.8.1. + def call(scope, *args) + manipulated_args = [scope] + args + self.class.dispatcher.dispatch(self, scope, manipulated_args) end def deprecation_gen(scope, *args) call_function('deprecation', 'validate_string', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::String. There is further documentation for validate_legacy function in the README.") -- cgit v1.2.3 From 64abfc99c6222f22ccfbb39ae9ece5ccd41fa25c Mon Sep 17 00:00:00 2001 From: Helen Campbell Date: Mon, 7 Nov 2016 14:52:12 +0000 Subject: Call site display for deprecation warnings --- lib/puppet/functions/deprecation.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lib/puppet/functions') diff --git a/lib/puppet/functions/deprecation.rb b/lib/puppet/functions/deprecation.rb index a860aa2..7082068 100644 --- a/lib/puppet/functions/deprecation.rb +++ b/lib/puppet/functions/deprecation.rb @@ -8,15 +8,19 @@ Puppet::Functions.create_function(:deprecation) do end def deprecation(key, message) + stacktrace = Puppet::Pops::PuppetStack.stacktrace() + file = stacktrace[0] + line = stacktrace[1] + output_message = "#{message} at #{file}:#{line}" # depending on configuration setting of strict case Puppet.settings[:strict] when :off # do nothing when :error - fail("deprecation. #{key}. #{message}") + fail("deprecation. #{key}. #{output_message}") else unless ENV['STDLIB_LOG_DEPRECATIONS'] == 'false' - Puppet.deprecation_warning(message, key) + Puppet.deprecation_warning(output_message, key) end end end -- cgit v1.2.3 From 91847caad08faba7f3cd12badff73a3f936ff9d1 Mon Sep 17 00:00:00 2001 From: Bryan Jen Date: Mon, 21 Nov 2016 14:18:29 -0700 Subject: Revert "Call site output for deprecation warnings" --- lib/puppet/functions/deprecation.rb | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'lib/puppet/functions') diff --git a/lib/puppet/functions/deprecation.rb b/lib/puppet/functions/deprecation.rb index 7082068..a860aa2 100644 --- a/lib/puppet/functions/deprecation.rb +++ b/lib/puppet/functions/deprecation.rb @@ -8,19 +8,15 @@ Puppet::Functions.create_function(:deprecation) do end def deprecation(key, message) - stacktrace = Puppet::Pops::PuppetStack.stacktrace() - file = stacktrace[0] - line = stacktrace[1] - output_message = "#{message} at #{file}:#{line}" # depending on configuration setting of strict case Puppet.settings[:strict] when :off # do nothing when :error - fail("deprecation. #{key}. #{output_message}") + fail("deprecation. #{key}. #{message}") else unless ENV['STDLIB_LOG_DEPRECATIONS'] == 'false' - Puppet.deprecation_warning(output_message, key) + Puppet.deprecation_warning(message, key) end end end -- cgit v1.2.3 From 746c1f83984ce875d810e00788e383109fa7ab2f Mon Sep 17 00:00:00 2001 From: Helen Campbell Date: Wed, 23 Nov 2016 16:01:01 +0000 Subject: Deprecation - Use puppet stacktrace if available A previous PR (#685) was raised on this issue, however once it was merged it was discovered that Puppet 3 with future parser enabled was calling the Puppet 4 version of the deprecation function. The Puppet stacktrace is not available until Puppet 4.6, so this was breaking existing setups. The solution was to check is the stacktrace was defined, and if it was to use it as part of the message output. --- lib/puppet/functions/deprecation.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib/puppet/functions') diff --git a/lib/puppet/functions/deprecation.rb b/lib/puppet/functions/deprecation.rb index a860aa2..39d9bc7 100644 --- a/lib/puppet/functions/deprecation.rb +++ b/lib/puppet/functions/deprecation.rb @@ -8,6 +8,12 @@ Puppet::Functions.create_function(:deprecation) do end def deprecation(key, message) + if defined? Puppet::Pops::PuppetStack.stacktrace() + stacktrace = Puppet::Pops::PuppetStack.stacktrace() + file = stacktrace[0] + line = stacktrace[1] + message = "#{message} at #{file}:#{line}" + end # depending on configuration setting of strict case Puppet.settings[:strict] when :off -- cgit v1.2.3 From d3bbd3cbf89cb23bce4e55c3828e17c05c4cfd70 Mon Sep 17 00:00:00 2001 From: Nick Walker Date: Thu, 1 Dec 2016 05:54:08 -0800 Subject: Indicate that the type function is preferred (#695) Prior to this commit, users coming to the type_of function would not realize that the type function in puppet does the same thing and is preferred over type_of. After this commit, we have a comment indicating the above. --- lib/puppet/functions/type_of.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib/puppet/functions') diff --git a/lib/puppet/functions/type_of.rb b/lib/puppet/functions/type_of.rb index 02cdd4d..01f1f49 100644 --- a/lib/puppet/functions/type_of.rb +++ b/lib/puppet/functions/type_of.rb @@ -10,6 +10,8 @@ # See the documentation for "The Puppet Type System" for more information about types. # See the `assert_type()` function for flexible ways to assert the type of a value. # +# The built-in type() function in puppet is generally preferred over this function +# this function is provided for backwards compatibility. Puppet::Functions.create_function(:type_of) do def type_of(value) Puppet::Pops::Types::TypeCalculator.infer_set(value) -- cgit v1.2.3