From 2760ee68d6283fa0e86c29ac5a801095f1213479 Mon Sep 17 00:00:00 2001 From: Alexander Fisher Date: Tue, 27 Jun 2023 09:14:57 +0100 Subject: [PATCH] Ignore Puppet's `strict` setting when calling function without namespace Previously, when a user had the Puppet setting `strict` set to `error` (which is the default in Puppet 8), a call to one of stdlib's functions via the deprecated non-namespaced function would cause a hard failure instead of just logging a warning and calling the real namespaced function. In this change, all of our shims have been updated to call `deprecation` with its new third parameter, (`use_strict_setting`), set to `false`. The non-namespaced versions will now only ever log warnings informing users to moved to the namespaced versions. It will not raise exceptions even if `strict` is set to `error`. This change will make it much easier for users to migrate to stdlib 9 (and to upgrade modules that now depend on stdlib 9) Fixes #1373 --- Rakefile | 2 +- lib/puppet/functions/batch_escape.rb | 2 +- lib/puppet/functions/ensure_packages.rb | 2 +- lib/puppet/functions/fqdn_rand_string.rb | 2 +- lib/puppet/functions/has_interface_with.rb | 2 +- lib/puppet/functions/merge.rb | 2 +- lib/puppet/functions/os_version_gte.rb | 2 +- lib/puppet/functions/parsehocon.rb | 2 +- lib/puppet/functions/powershell_escape.rb | 2 +- lib/puppet/functions/seeded_rand.rb | 2 +- lib/puppet/functions/seeded_rand_string.rb | 2 +- lib/puppet/functions/shell_escape.rb | 2 +- lib/puppet/functions/to_json.rb | 2 +- lib/puppet/functions/to_json_pretty.rb | 2 +- lib/puppet/functions/to_python.rb | 2 +- lib/puppet/functions/to_ruby.rb | 2 +- lib/puppet/functions/to_toml.rb | 2 +- lib/puppet/functions/to_yaml.rb | 2 +- lib/puppet/functions/type_of.rb | 2 +- lib/puppet/functions/validate_domain_name.rb | 2 +- lib/puppet/functions/validate_email_address.rb | 2 +- 21 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Rakefile b/Rakefile index a647c6f93..b32f1f0d1 100644 --- a/Rakefile +++ b/Rakefile @@ -115,7 +115,7 @@ task :regenerate_unamespaced_shims 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('deprecation', '#{function_name}', 'This function is deprecated, please use stdlib::#{function_name} instead.', false) call_function('stdlib::#{function_name}', *args) end end diff --git a/lib/puppet/functions/batch_escape.rb b/lib/puppet/functions/batch_escape.rb index 92f705d45..07d326a88 100644 --- a/lib/puppet/functions/batch_escape.rb +++ b/lib/puppet/functions/batch_escape.rb @@ -8,7 +8,7 @@ repeated_param 'Any', :args end def deprecation_gen(*args) - call_function('deprecation', 'batch_escape', 'This function is deprecated, please use stdlib::batch_escape instead.') + call_function('deprecation', 'batch_escape', 'This function is deprecated, please use stdlib::batch_escape instead.', false) call_function('stdlib::batch_escape', *args) end end diff --git a/lib/puppet/functions/ensure_packages.rb b/lib/puppet/functions/ensure_packages.rb index fd26cbc11..f6f4b3ce8 100644 --- a/lib/puppet/functions/ensure_packages.rb +++ b/lib/puppet/functions/ensure_packages.rb @@ -7,7 +7,7 @@ repeated_param 'Any', :args end def deprecation_gen(scope, *args) - call_function('deprecation', 'ensure_packages', 'This function is deprecated, please use stdlib::ensure_packages instead.') + call_function('deprecation', 'ensure_packages', 'This function is deprecated, please use stdlib::ensure_packages instead.', false) scope.call_function('stdlib::ensure_packages', args) end end diff --git a/lib/puppet/functions/fqdn_rand_string.rb b/lib/puppet/functions/fqdn_rand_string.rb index 6363b4d62..1c5f5f6fe 100644 --- a/lib/puppet/functions/fqdn_rand_string.rb +++ b/lib/puppet/functions/fqdn_rand_string.rb @@ -8,7 +8,7 @@ repeated_param 'Any', :args end def deprecation_gen(*args) - call_function('deprecation', 'fqdn_rand_string', 'This function is deprecated, please use stdlib::fqdn_rand_string instead.') + call_function('deprecation', 'fqdn_rand_string', 'This function is deprecated, please use stdlib::fqdn_rand_string instead.', false) call_function('stdlib::fqdn_rand_string', *args) end end diff --git a/lib/puppet/functions/has_interface_with.rb b/lib/puppet/functions/has_interface_with.rb index 002ca6e2d..bd36802c8 100644 --- a/lib/puppet/functions/has_interface_with.rb +++ b/lib/puppet/functions/has_interface_with.rb @@ -8,7 +8,7 @@ repeated_param 'Any', :args end def deprecation_gen(*args) - call_function('deprecation', 'has_interface_with', 'This function 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.', false) call_function('stdlib::has_interface_with', *args) end end diff --git a/lib/puppet/functions/merge.rb b/lib/puppet/functions/merge.rb index 7a8ae5c84..5d4f5c951 100644 --- a/lib/puppet/functions/merge.rb +++ b/lib/puppet/functions/merge.rb @@ -8,7 +8,7 @@ repeated_param 'Any', :args end def deprecation_gen(*args) - call_function('deprecation', 'merge', 'This function is deprecated, please use stdlib::merge instead.') + call_function('deprecation', 'merge', 'This function is deprecated, please use stdlib::merge instead.', false) call_function('stdlib::merge', *args) end end diff --git a/lib/puppet/functions/os_version_gte.rb b/lib/puppet/functions/os_version_gte.rb index 3506236b7..28da44fe0 100644 --- a/lib/puppet/functions/os_version_gte.rb +++ b/lib/puppet/functions/os_version_gte.rb @@ -8,7 +8,7 @@ repeated_param 'Any', :args end def deprecation_gen(*args) - call_function('deprecation', 'os_version_gte', 'This function is deprecated, please use stdlib::os_version_gte instead.') + call_function('deprecation', 'os_version_gte', 'This function is deprecated, please use stdlib::os_version_gte instead.', false) call_function('stdlib::os_version_gte', *args) end end diff --git a/lib/puppet/functions/parsehocon.rb b/lib/puppet/functions/parsehocon.rb index 7f1c6d5e1..700f685e5 100644 --- a/lib/puppet/functions/parsehocon.rb +++ b/lib/puppet/functions/parsehocon.rb @@ -8,7 +8,7 @@ repeated_param 'Any', :args end def deprecation_gen(*args) - call_function('deprecation', 'parsehocon', 'This function is deprecated, please use stdlib::parsehocon instead.') + call_function('deprecation', 'parsehocon', 'This function is deprecated, please use stdlib::parsehocon instead.', false) call_function('stdlib::parsehocon', *args) end end diff --git a/lib/puppet/functions/powershell_escape.rb b/lib/puppet/functions/powershell_escape.rb index 65701cb2d..72209b24a 100644 --- a/lib/puppet/functions/powershell_escape.rb +++ b/lib/puppet/functions/powershell_escape.rb @@ -8,7 +8,7 @@ repeated_param 'Any', :args end def deprecation_gen(*args) - call_function('deprecation', 'powershell_escape', 'This function is deprecated, please use stdlib::powershell_escape instead.') + call_function('deprecation', 'powershell_escape', 'This function is deprecated, please use stdlib::powershell_escape instead.', false) call_function('stdlib::powershell_escape', *args) end end diff --git a/lib/puppet/functions/seeded_rand.rb b/lib/puppet/functions/seeded_rand.rb index 38d743da4..b97c93f36 100644 --- a/lib/puppet/functions/seeded_rand.rb +++ b/lib/puppet/functions/seeded_rand.rb @@ -8,7 +8,7 @@ repeated_param 'Any', :args end def deprecation_gen(*args) - call_function('deprecation', 'seeded_rand', 'This function is deprecated, please use stdlib::seeded_rand instead.') + call_function('deprecation', 'seeded_rand', 'This function is deprecated, please use stdlib::seeded_rand instead.', false) call_function('stdlib::seeded_rand', *args) end end diff --git a/lib/puppet/functions/seeded_rand_string.rb b/lib/puppet/functions/seeded_rand_string.rb index 32d25061a..486082547 100644 --- a/lib/puppet/functions/seeded_rand_string.rb +++ b/lib/puppet/functions/seeded_rand_string.rb @@ -8,7 +8,7 @@ repeated_param 'Any', :args end def deprecation_gen(*args) - call_function('deprecation', 'seeded_rand_string', 'This function is deprecated, please use stdlib::seeded_rand_string instead.') + call_function('deprecation', 'seeded_rand_string', 'This function is deprecated, please use stdlib::seeded_rand_string instead.', false) call_function('stdlib::seeded_rand_string', *args) end end diff --git a/lib/puppet/functions/shell_escape.rb b/lib/puppet/functions/shell_escape.rb index 9d55d9e00..87af9a9af 100644 --- a/lib/puppet/functions/shell_escape.rb +++ b/lib/puppet/functions/shell_escape.rb @@ -8,7 +8,7 @@ repeated_param 'Any', :args end def deprecation_gen(*args) - call_function('deprecation', 'shell_escape', 'This function is deprecated, please use stdlib::shell_escape instead.') + call_function('deprecation', 'shell_escape', 'This function is deprecated, please use stdlib::shell_escape instead.', false) call_function('stdlib::shell_escape', *args) end end diff --git a/lib/puppet/functions/to_json.rb b/lib/puppet/functions/to_json.rb index 4b6358553..82c0534c2 100644 --- a/lib/puppet/functions/to_json.rb +++ b/lib/puppet/functions/to_json.rb @@ -8,7 +8,7 @@ repeated_param 'Any', :args end def deprecation_gen(*args) - call_function('deprecation', 'to_json', 'This function is deprecated, please use stdlib::to_json instead.') + call_function('deprecation', 'to_json', 'This function is deprecated, please use stdlib::to_json instead.', false) call_function('stdlib::to_json', *args) end end diff --git a/lib/puppet/functions/to_json_pretty.rb b/lib/puppet/functions/to_json_pretty.rb index 0616256f1..9f6dc5e5d 100644 --- a/lib/puppet/functions/to_json_pretty.rb +++ b/lib/puppet/functions/to_json_pretty.rb @@ -8,7 +8,7 @@ repeated_param 'Any', :args end def deprecation_gen(*args) - call_function('deprecation', 'to_json_pretty', 'This function is deprecated, please use stdlib::to_json_pretty instead.') + call_function('deprecation', 'to_json_pretty', 'This function is deprecated, please use stdlib::to_json_pretty instead.', false) call_function('stdlib::to_json_pretty', *args) end end diff --git a/lib/puppet/functions/to_python.rb b/lib/puppet/functions/to_python.rb index 78f887017..95045c1bb 100644 --- a/lib/puppet/functions/to_python.rb +++ b/lib/puppet/functions/to_python.rb @@ -8,7 +8,7 @@ repeated_param 'Any', :args end def deprecation_gen(*args) - call_function('deprecation', 'to_python', 'This function is deprecated, please use stdlib::to_python instead.') + call_function('deprecation', 'to_python', 'This function is deprecated, please use stdlib::to_python instead.', false) call_function('stdlib::to_python', *args) end end diff --git a/lib/puppet/functions/to_ruby.rb b/lib/puppet/functions/to_ruby.rb index 433673776..c2d919c9b 100644 --- a/lib/puppet/functions/to_ruby.rb +++ b/lib/puppet/functions/to_ruby.rb @@ -8,7 +8,7 @@ repeated_param 'Any', :args end def deprecation_gen(*args) - call_function('deprecation', 'to_ruby', 'This function is deprecated, please use stdlib::to_ruby instead.') + call_function('deprecation', 'to_ruby', 'This function is deprecated, please use stdlib::to_ruby instead.', false) call_function('stdlib::to_ruby', *args) end end diff --git a/lib/puppet/functions/to_toml.rb b/lib/puppet/functions/to_toml.rb index d5c9804bc..6de87678e 100644 --- a/lib/puppet/functions/to_toml.rb +++ b/lib/puppet/functions/to_toml.rb @@ -8,7 +8,7 @@ repeated_param 'Any', :args end def deprecation_gen(*args) - call_function('deprecation', 'to_toml', 'This function is deprecated, please use stdlib::to_toml instead.') + call_function('deprecation', 'to_toml', 'This function is deprecated, please use stdlib::to_toml instead.', false) call_function('stdlib::to_toml', *args) end end diff --git a/lib/puppet/functions/to_yaml.rb b/lib/puppet/functions/to_yaml.rb index f8b26b2dc..980748bfa 100644 --- a/lib/puppet/functions/to_yaml.rb +++ b/lib/puppet/functions/to_yaml.rb @@ -8,7 +8,7 @@ repeated_param 'Any', :args end def deprecation_gen(*args) - call_function('deprecation', 'to_yaml', 'This function is deprecated, please use stdlib::to_yaml instead.') + call_function('deprecation', 'to_yaml', 'This function is deprecated, please use stdlib::to_yaml instead.', false) call_function('stdlib::to_yaml', *args) end end diff --git a/lib/puppet/functions/type_of.rb b/lib/puppet/functions/type_of.rb index a835e01f5..414b361d0 100644 --- a/lib/puppet/functions/type_of.rb +++ b/lib/puppet/functions/type_of.rb @@ -8,7 +8,7 @@ repeated_param 'Any', :args end def deprecation_gen(*args) - call_function('deprecation', 'type_of', 'This function is deprecated, please use stdlib::type_of instead.') + call_function('deprecation', 'type_of', 'This function is deprecated, please use stdlib::type_of instead.', false) call_function('stdlib::type_of', *args) end end diff --git a/lib/puppet/functions/validate_domain_name.rb b/lib/puppet/functions/validate_domain_name.rb index 3d2acf6ba..04ca517a9 100644 --- a/lib/puppet/functions/validate_domain_name.rb +++ b/lib/puppet/functions/validate_domain_name.rb @@ -8,7 +8,7 @@ repeated_param 'Any', :args end def deprecation_gen(*args) - call_function('deprecation', 'validate_domain_name', 'This function is deprecated, please use stdlib::validate_domain_name instead.') + call_function('deprecation', 'validate_domain_name', 'This function is deprecated, please use stdlib::validate_domain_name instead.', false) call_function('stdlib::validate_domain_name', *args) end end diff --git a/lib/puppet/functions/validate_email_address.rb b/lib/puppet/functions/validate_email_address.rb index f59a0aa8c..bbc21d648 100644 --- a/lib/puppet/functions/validate_email_address.rb +++ b/lib/puppet/functions/validate_email_address.rb @@ -8,7 +8,7 @@ repeated_param 'Any', :args end def deprecation_gen(*args) - call_function('deprecation', 'validate_email_address', 'This function is deprecated, please use stdlib::validate_email_address instead.') + call_function('deprecation', 'validate_email_address', 'This function is deprecated, please use stdlib::validate_email_address instead.', false) call_function('stdlib::validate_email_address', *args) end end