Puppet Function: simplib::deprecation
- Defined in:
- lib/puppet/functions/simplib/deprecation.rb
- Function type:
- Ruby 4.x API
Overview
Function to print deprecation warnings, logging a warning once for a given key.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/puppet/functions/simplib/deprecation.rb', line 4 Puppet::Functions.create_function(:'simplib::deprecation') do # @param key Uniqueness key, which is used to dedupe messages. # @param message Message to be printed, to which file and line # information will be appended, if available. # @return [Nil] # # @example Emit a warning about a function that will be removed # # simplib::deprecation('simplib::foo', 'simplib::foo is deprecated and will be removed in a future version') # # @example Emit a Warning about function that has been replaced # # simplib::deprecation('simplib::foo', 'simplib::foo is deprecated. Please use simplib::foo2 instead') # dispatch :deprecation do required_param 'String', :key required_param 'String', :message end def deprecation(key, ) if defined? Puppet::Pops::PuppetStack.stacktrace() stacktrace = Puppet::Pops::PuppetStack.stacktrace() file = stacktrace[0] line = stacktrace[1] = "#{} at #{file}:#{line}" end Puppet.deprecation_warning(, key) unless ENV['SIMPLIB_NOLOG_DEPRECATIONS'] end end |