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