summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorHelen Campbell <helen@puppetlabs.com>2016-11-23 16:01:01 +0000
committerHelen Campbell <helen@puppetlabs.com>2016-11-24 13:43:59 +0000
commit746c1f83984ce875d810e00788e383109fa7ab2f (patch)
treeec2b96766ce5a59940969b052cdaad5764c196e3 /lib
parent419f7d63ecf4a98ae55d614bc692544a639820ab (diff)
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.
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/functions/deprecation.rb6
1 files changed, 6 insertions, 0 deletions
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