From 6e7e69fe203e042b28aacb01301c338d55448c5f Mon Sep 17 00:00:00 2001 From: tphoney Date: Wed, 3 Aug 2016 17:06:25 +0100 Subject: (modules-3533) deprecation for 3.x number function --- lib/puppet/parser/functions/deprecation.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 lib/puppet/parser/functions/deprecation.rb (limited to 'lib/puppet/parser/functions/deprecation.rb') diff --git a/lib/puppet/parser/functions/deprecation.rb b/lib/puppet/parser/functions/deprecation.rb new file mode 100644 index 0000000..5d74984 --- /dev/null +++ b/lib/puppet/parser/functions/deprecation.rb @@ -0,0 +1,15 @@ +module Puppet::Parser::Functions + newfunction(:deprecation, :type => :rvalue, :doc => <<-EOS + Function to print deprecation warnings (this is the 3.X version of it), 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.). +EOS + ) do |arguments| + + raise(Puppet::ParseError, "deprecation: Wrong number of arguments " + + "given (#{arguments.size} for 2)") unless arguments.size == 2 + + key = arguments[0] + message = arguments[1] + + warn("deprecation. #{key}. #{message}") + end +end -- cgit v1.2.3 From 39148468abbd9b8af74b776eb49f0a8388fc8541 Mon Sep 17 00:00:00 2001 From: Dominic Cleal Date: Mon, 15 Aug 2016 10:39:50 +0100 Subject: (maint) Switch 3.x deprecation() to use Puppet warning logger The deprecation function was calling the `Kernel#warn` function which prints to stderr, rather than the Puppet logger. This causes problems for Puppet module tests on Travis CI, which has a cap on the amount of stdout/err permitted in its logs and also prevents users from finding the deprecation warnings when running under a Puppet master. --- lib/puppet/parser/functions/deprecation.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/puppet/parser/functions/deprecation.rb') diff --git a/lib/puppet/parser/functions/deprecation.rb b/lib/puppet/parser/functions/deprecation.rb index 5d74984..fc861a6 100644 --- a/lib/puppet/parser/functions/deprecation.rb +++ b/lib/puppet/parser/functions/deprecation.rb @@ -10,6 +10,6 @@ EOS key = arguments[0] message = arguments[1] - warn("deprecation. #{key}. #{message}") + warning("deprecation. #{key}. #{message}") 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/parser/functions/deprecation.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lib/puppet/parser/functions/deprecation.rb') diff --git a/lib/puppet/parser/functions/deprecation.rb b/lib/puppet/parser/functions/deprecation.rb index fc861a6..e30f3a0 100644 --- a/lib/puppet/parser/functions/deprecation.rb +++ b/lib/puppet/parser/functions/deprecation.rb @@ -9,7 +9,9 @@ EOS key = arguments[0] message = arguments[1] - - warning("deprecation. #{key}. #{message}") + + if ENV['STDLIB_LOG_DEPRECATIONS'] == "true" + warning("deprecation. #{key}. #{message}") + 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/parser/functions/deprecation.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/puppet/parser/functions/deprecation.rb') diff --git a/lib/puppet/parser/functions/deprecation.rb b/lib/puppet/parser/functions/deprecation.rb index e30f3a0..0cb247d 100644 --- a/lib/puppet/parser/functions/deprecation.rb +++ b/lib/puppet/parser/functions/deprecation.rb @@ -11,7 +11,9 @@ EOS message = arguments[1] if ENV['STDLIB_LOG_DEPRECATIONS'] == "true" - warning("deprecation. #{key}. #{message}") + caller_infos = caller.first.split(":") + err_message = "#{message} : #{caller_infos[0]} : #{caller_infos[1]}" + warning("deprecation. #{key}. #{err_message}") end 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/parser/functions/deprecation.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'lib/puppet/parser/functions/deprecation.rb') diff --git a/lib/puppet/parser/functions/deprecation.rb b/lib/puppet/parser/functions/deprecation.rb index 0cb247d..e30f3a0 100644 --- a/lib/puppet/parser/functions/deprecation.rb +++ b/lib/puppet/parser/functions/deprecation.rb @@ -11,9 +11,7 @@ EOS message = arguments[1] if ENV['STDLIB_LOG_DEPRECATIONS'] == "true" - caller_infos = caller.first.split(":") - err_message = "#{message} : #{caller_infos[0]} : #{caller_infos[1]}" - warning("deprecation. #{key}. #{err_message}") + warning("deprecation. #{key}. #{message}") end end end -- cgit v1.2.3 From c5fbd82204e9832b0d398e894003e9898adb71fc Mon Sep 17 00:00:00 2001 From: David Schmitt Date: Sun, 27 Nov 2016 17:39:07 +0000 Subject: Remove rvalue declaration from v3 deprecation() function Without this, some uses of this function do not work in puppet3. e.g. if $include_src != undef { deprecation('apt $include_src', "please use \$include => { 'src' => ${include_src} } instead") } causes Function 'deprecation' must be the value of a statement on puppet 3.8.7. --- lib/puppet/parser/functions/deprecation.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/puppet/parser/functions/deprecation.rb') diff --git a/lib/puppet/parser/functions/deprecation.rb b/lib/puppet/parser/functions/deprecation.rb index e30f3a0..cd64fe2 100644 --- a/lib/puppet/parser/functions/deprecation.rb +++ b/lib/puppet/parser/functions/deprecation.rb @@ -1,5 +1,5 @@ module Puppet::Parser::Functions - newfunction(:deprecation, :type => :rvalue, :doc => <<-EOS + newfunction(:deprecation, :doc => <<-EOS Function to print deprecation warnings (this is the 3.X version of it), 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.). EOS ) do |arguments| @@ -9,7 +9,7 @@ EOS key = arguments[0] message = arguments[1] - + if ENV['STDLIB_LOG_DEPRECATIONS'] == "true" warning("deprecation. #{key}. #{message}") end -- cgit v1.2.3