diff --git a/Rakefile b/Rakefile index 9aa3a64e3..3767a06d4 100644 --- a/Rakefile +++ b/Rakefile @@ -87,3 +87,33 @@ EOM end end +desc 'Regenerate the deprecated unamespaced shims' +task :regenerate_unamespaced_shims do + Dir['lib/puppet/functions/*.rb'].each do |filename| + content = File.read(filename) + + unless content =~ /@summary DEPRECATED. Use the namespaced function/ + warn("#{filename} does not look like a deprecation shim (skipping)") + next + end + + function_name = File.basename(filename, '.rb') + + File.write(filename, <<~CODE) + # frozen_string_literal: true + + # THIS FILE WAS GENERATED BY `rake regenerate_unamespaced_shims` + + # @summary DEPRECATED. Use the namespaced function [`stdlib::#{function_name}`](#stdlib#{function_name}) instead. + Puppet::Functions.create_function(:#{function_name}) do + dispatch :deprecation_gen do + repeated_param 'Any', :args + end + def deprecation_gen(*args) + call_function('deprecation', '#{function_name}', 'This function is deprecated, please use stdlib::#{function_name} instead.') + call_function('stdlib::#{function_name}', *args) + end + end + CODE + end +end diff --git a/lib/puppet/functions/has_interface_with.rb b/lib/puppet/functions/has_interface_with.rb index d166bb42f..002ca6e2d 100644 --- a/lib/puppet/functions/has_interface_with.rb +++ b/lib/puppet/functions/has_interface_with.rb @@ -1,12 +1,14 @@ # frozen_string_literal: true +# THIS FILE WAS GENERATED BY `rake regenerate_unamespaced_shims` + # @summary DEPRECATED. Use the namespaced function [`stdlib::has_interface_with`](#stdlibhas_interface_with) instead. Puppet::Functions.create_function(:has_interface_with) do dispatch :deprecation_gen do repeated_param 'Any', :args end def deprecation_gen(*args) - call_function('deprecation', 'has_interface_with', 'This method is deprecated, please use stdlib::has_interface_with instead.') + call_function('deprecation', 'has_interface_with', 'This function is deprecated, please use stdlib::has_interface_with instead.') call_function('stdlib::has_interface_with', *args) end end