In Puppet 7, extra methods within a function definition block are no longer permitted when using the 3.x API.
Attempting to use such functions aborts catalog compilation with:
Error: Could not retrieve catalog from remote server:
Error 500 on SERVER: Internal Server Error: org.jruby.exceptions.SecurityError:
(SecurityError) Illegal method definition of method 'example_function' in source .../example-module/lib/puppet/parser/functions/example_function.rb on line XXX in legacy function.
See https://puppet.com/docs/puppet/latest/functions_refactor_legacy.html for more information
We fix the error by updating the only function that has extra methods to use the 4.x API.
This change drops support for Puppet 3.