Skip to content

Commit

Permalink
Ignore Puppet's strict setting when calling function without namespace
Browse files Browse the repository at this point in the history
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
  • Loading branch information
alexjfisher committed Jun 27, 2023
1 parent 4b64d06 commit 2760ee6
Show file tree
Hide file tree
Showing 21 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion Rakefile
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/functions/batch_escape.rb
Expand Up @@ -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
2 changes: 1 addition & 1 deletion lib/puppet/functions/ensure_packages.rb
Expand Up @@ -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
2 changes: 1 addition & 1 deletion lib/puppet/functions/fqdn_rand_string.rb
Expand Up @@ -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
2 changes: 1 addition & 1 deletion lib/puppet/functions/has_interface_with.rb
Expand Up @@ -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
2 changes: 1 addition & 1 deletion lib/puppet/functions/merge.rb
Expand Up @@ -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
2 changes: 1 addition & 1 deletion lib/puppet/functions/os_version_gte.rb
Expand Up @@ -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
2 changes: 1 addition & 1 deletion lib/puppet/functions/parsehocon.rb
Expand Up @@ -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
2 changes: 1 addition & 1 deletion lib/puppet/functions/powershell_escape.rb
Expand Up @@ -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
2 changes: 1 addition & 1 deletion lib/puppet/functions/seeded_rand.rb
Expand Up @@ -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
2 changes: 1 addition & 1 deletion lib/puppet/functions/seeded_rand_string.rb
Expand Up @@ -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
2 changes: 1 addition & 1 deletion lib/puppet/functions/shell_escape.rb
Expand Up @@ -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
2 changes: 1 addition & 1 deletion lib/puppet/functions/to_json.rb
Expand Up @@ -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
2 changes: 1 addition & 1 deletion lib/puppet/functions/to_json_pretty.rb
Expand Up @@ -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
2 changes: 1 addition & 1 deletion lib/puppet/functions/to_python.rb
Expand Up @@ -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
2 changes: 1 addition & 1 deletion lib/puppet/functions/to_ruby.rb
Expand Up @@ -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
2 changes: 1 addition & 1 deletion lib/puppet/functions/to_toml.rb
Expand Up @@ -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
2 changes: 1 addition & 1 deletion lib/puppet/functions/to_yaml.rb
Expand Up @@ -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
2 changes: 1 addition & 1 deletion lib/puppet/functions/type_of.rb
Expand Up @@ -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
2 changes: 1 addition & 1 deletion lib/puppet/functions/validate_domain_name.rb
Expand Up @@ -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
2 changes: 1 addition & 1 deletion lib/puppet/functions/validate_email_address.rb
Expand Up @@ -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

0 comments on commit 2760ee6

Please sign in to comment.