Skip to content

Commit

Permalink
Merge pull request puppetlabs#672 from DavidS/modules-3961-fix-deprec…
Browse files Browse the repository at this point in the history
…ation-warnings

(MODULES-3961) emit more deprecation warnings
  • Loading branch information
Helen authored Oct 12, 2016
2 parents f3978b8 + b92fad2 commit 6fb7465
Show file tree
Hide file tree
Showing 44 changed files with 141 additions and 42 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## Supported Release 4.13.1
### Summary

This bugfix release improves the user experience around function deprecations by emitting one warning per function(-name) instead of only one deprecation overall. This allows users to identify all deprecated functions used in one agent run, with less back-and-forth.

This release also adds additional Puppet 4 overrides for the `is_` counterparts of the deprecated functions to emit the deprecations warnings in all cases.

## Supported Release 4.13.0
### Summary

Expand Down
10 changes: 10 additions & 0 deletions lib/puppet/functions/is_absolute_path.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Puppet::Functions.create_function(:is_absolute_path, Puppet::Functions::InternalFunction) do
dispatch :deprecation_gen do
scope_param
optional_repeated_param 'Any', :args
end
def deprecation_gen(scope, *args)
call_function('deprecation', 'is_absolute_path', "This method is deprecated, please use match expressions with Stdlib::Compat::Absolute_Path instead. They are described at https://docs.puppet.com/puppet/latest/reference/lang_data_type.html#match-expressions.")
scope.send("function_is_absolute_path", args)
end
end
10 changes: 10 additions & 0 deletions lib/puppet/functions/is_array.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Puppet::Functions.create_function(:is_array, Puppet::Functions::InternalFunction) do
dispatch :deprecation_gen do
scope_param
optional_repeated_param 'Any', :args
end
def deprecation_gen(scope, *args)
call_function('deprecation', 'is_array', "This method is deprecated, please use match expressions with Stdlib::Compat::Array instead. They are described at https://docs.puppet.com/puppet/latest/reference/lang_data_type.html#match-expressions.")
scope.send("function_is_array", args)
end
end
10 changes: 10 additions & 0 deletions lib/puppet/functions/is_bool.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Puppet::Functions.create_function(:is_bool, Puppet::Functions::InternalFunction) do
dispatch :deprecation_gen do
scope_param
optional_repeated_param 'Any', :args
end
def deprecation_gen(scope, *args)
call_function('deprecation', 'is_bool', "This method is deprecated, please use match expressions with Stdlib::Compat::Bool instead. They are described at https://docs.puppet.com/puppet/latest/reference/lang_data_type.html#match-expressions.")
scope.send("function_is_bool", args)
end
end
10 changes: 10 additions & 0 deletions lib/puppet/functions/is_float.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Puppet::Functions.create_function(:is_float, Puppet::Functions::InternalFunction) do
dispatch :deprecation_gen do
scope_param
optional_repeated_param 'Any', :args
end
def deprecation_gen(scope, *args)
call_function('deprecation', 'is_float', "This method is deprecated, please use match expressions with Stdlib::Compat::Float instead. They are described at https://docs.puppet.com/puppet/latest/reference/lang_data_type.html#match-expressions.")
scope.send("function_is_float", args)
end
end
10 changes: 10 additions & 0 deletions lib/puppet/functions/is_ip_address.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Puppet::Functions.create_function(:is_ip_address, Puppet::Functions::InternalFunction) do
dispatch :deprecation_gen do
scope_param
optional_repeated_param 'Any', :args
end
def deprecation_gen(scope, *args)
call_function('deprecation', 'is_ip_address', "This method is deprecated, please use match expressions with Stdlib::Compat::Ip_address instead. They are described at https://docs.puppet.com/puppet/latest/reference/lang_data_type.html#match-expressions.")
scope.send("function_is_ip_address", args)
end
end
10 changes: 10 additions & 0 deletions lib/puppet/functions/is_ipv4_address.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Puppet::Functions.create_function(:is_ipv4_address, Puppet::Functions::InternalFunction) do
dispatch :deprecation_gen do
scope_param
optional_repeated_param 'Any', :args
end
def deprecation_gen(scope, *args)
call_function('deprecation', 'is_ipv4_address', "This method is deprecated, please use match expressions with Stdlib::Compat::Ipv4 instead. They are described at https://docs.puppet.com/puppet/latest/reference/lang_data_type.html#match-expressions.")
scope.send("function_is_ipv4_address", args)
end
end
10 changes: 10 additions & 0 deletions lib/puppet/functions/is_ipv6_address.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Puppet::Functions.create_function(:is_ipv6_address, Puppet::Functions::InternalFunction) do
dispatch :deprecation_gen do
scope_param
optional_repeated_param 'Any', :args
end
def deprecation_gen(scope, *args)
call_function('deprecation', 'is_ipv4_address', "This method is deprecated, please use match expressions with Stdlib::Compat::Ipv6 instead. They are described at https://docs.puppet.com/puppet/latest/reference/lang_data_type.html#match-expressions.")
scope.send("function_is_ipv6_address", args)
end
end
10 changes: 10 additions & 0 deletions lib/puppet/functions/is_numeric.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Puppet::Functions.create_function(:is_numeric, Puppet::Functions::InternalFunction) do
dispatch :deprecation_gen do
scope_param
optional_repeated_param 'Any', :args
end
def deprecation_gen(scope, *args)
call_function('deprecation', 'is_numeric', "This method is deprecated, please use match expressions with Stdlib::Compat::Numeric instead. They are described at https://docs.puppet.com/puppet/latest/reference/lang_data_type.html#match-expressions.")
scope.send("function_is_numeric", args)
end
end
10 changes: 10 additions & 0 deletions lib/puppet/functions/is_string.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Puppet::Functions.create_function(:is_string, Puppet::Functions::InternalFunction) do
dispatch :deprecation_gen do
scope_param
optional_repeated_param 'Any', :args
end
def deprecation_gen(scope, *args)
call_function('deprecation', 'is_string', "This method is deprecated, please use match expressions with Stdlib::Compat::String instead. They are described at https://docs.puppet.com/puppet/latest/reference/lang_data_type.html#match-expressions.")
scope.send("function_is_string", args)
end
end
2 changes: 1 addition & 1 deletion lib/puppet/functions/validate_absolute_path.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
optional_repeated_param 'Any', :args
end
def deprecation_gen(scope, *args)
call_function('deprecation', 'puppet_3_type_check', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Absolute_Path. There is further documentation for validate_legacy function in the README.")
call_function('deprecation', 'validate_absolute_path', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Absolute_Path. There is further documentation for validate_legacy function in the README.")
scope.send("function_validate_absolute_path", args)
end
end
2 changes: 1 addition & 1 deletion lib/puppet/functions/validate_array.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
optional_repeated_param 'Any', :args
end
def deprecation_gen(scope, *args)
call_function('deprecation', 'puppet_3_type_check', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Array. There is further documentation for validate_legacy function in the README.")
call_function('deprecation', 'validate_array', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Array. There is further documentation for validate_legacy function in the README.")
scope.send("function_validate_array", args)
end
end
2 changes: 1 addition & 1 deletion lib/puppet/functions/validate_bool.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
optional_repeated_param 'Any', :args
end
def deprecation_gen(scope, *args)
call_function('deprecation', 'puppet_3_type_check', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Bool. There is further documentation for validate_legacy function in the README.")
call_function('deprecation', 'validate_bool', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Bool. There is further documentation for validate_legacy function in the README.")
scope.send("function_validate_bool", args)
end
end
2 changes: 1 addition & 1 deletion lib/puppet/functions/validate_hash.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
optional_repeated_param 'Any', :args
end
def deprecation_gen(scope, *args)
call_function('deprecation', 'puppet_3_type_check', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Hash. There is further documentation for validate_legacy function in the README.")
call_function('deprecation', 'validate_hash', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Hash. There is further documentation for validate_legacy function in the README.")
scope.send("function_validate_hash", args)
end
end
2 changes: 1 addition & 1 deletion lib/puppet/functions/validate_integer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
optional_repeated_param 'Any', :args
end
def deprecation_gen(scope, *args)
call_function('deprecation', 'puppet_3_type_check', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Integer. There is further documentation for validate_legacy function in the README.")
call_function('deprecation', 'validate_integer', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Integer. There is further documentation for validate_legacy function in the README.")
scope.send("function_validate_integer", args)
end
end
2 changes: 1 addition & 1 deletion lib/puppet/functions/validate_ip_address.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
optional_repeated_param 'Any', :args
end
def deprecation_gen(scope, *args)
call_function('deprecation', 'puppet_3_type_check', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Ip_Address. There is further documentation for validate_legacy function in the README.")
call_function('deprecation', 'validate_ip_address', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Ip_Address. There is further documentation for validate_legacy function in the README.")
scope.send("function_validate_ip_address", args)
end
end
2 changes: 1 addition & 1 deletion lib/puppet/functions/validate_ipv4_address.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
optional_repeated_param 'Any', :args
end
def deprecation_gen(scope, *args)
call_function('deprecation', 'puppet_3_type_check', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Ipv4_Address. There is further documentation for validate_legacy function in the README.")
call_function('deprecation', 'validate_ipv4_address', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Ipv4_Address. There is further documentation for validate_legacy function in the README.")
scope.send("function_validate_ipv4_address", args)
end
end
2 changes: 1 addition & 1 deletion lib/puppet/functions/validate_ipv6_address.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
optional_repeated_param 'Any', :args
end
def deprecation_gen(scope, *args)
call_function('deprecation', 'puppet_3_type_check', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Ipv6_address. There is further documentation for validate_legacy function in the README.")
call_function('deprecation', 'validate_ipv6_address', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Ipv6_address. There is further documentation for validate_legacy function in the README.")
scope.send("function_validate_ipv6_address", args)
end
end
2 changes: 1 addition & 1 deletion lib/puppet/functions/validate_numeric.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
optional_repeated_param 'Any', :args
end
def deprecation_gen(scope, *args)
call_function('deprecation', 'puppet_3_type_check', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Numeric. There is further documentation for validate_legacy function in the README.")
call_function('deprecation', 'validate_numeric', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Numeric. There is further documentation for validate_legacy function in the README.")
scope.send("function_validate_numeric", args)
end
end
2 changes: 1 addition & 1 deletion lib/puppet/functions/validate_re.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
optional_repeated_param 'Any', :args
end
def deprecation_gen(scope, *args)
call_function('deprecation', 'puppet_3_type_check', "This method is deprecated, please use the stdlib validate_legacy function, with Pattern[]. There is further documentation for validate_legacy function in the README.")
call_function('deprecation', 'validate_re', "This method is deprecated, please use the stdlib validate_legacy function, with Pattern[]. There is further documentation for validate_legacy function in the README.")
scope.send("function_validate_re", args)
end
end
2 changes: 1 addition & 1 deletion lib/puppet/functions/validate_slength.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
optional_repeated_param 'Any', :args
end
def deprecation_gen(scope, *args)
call_function('deprecation', 'puppet_3_type_check', "This method is deprecated, please use the stdlib validate_legacy function, with String[]. There is further documentation for validate_legacy function in the README.")
call_function('deprecation', 'validate_slength', "This method is deprecated, please use the stdlib validate_legacy function, with String[]. There is further documentation for validate_legacy function in the README.")
scope.send("function_validate_slength", args)
end
end
2 changes: 1 addition & 1 deletion lib/puppet/functions/validate_string.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
optional_repeated_param 'Any', :args
end
def deprecation_gen(scope, *args)
call_function('deprecation', 'puppet_3_type_check', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::String. There is further documentation for validate_legacy function in the README.")
call_function('deprecation', 'validate_string', "This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::String. There is further documentation for validate_legacy function in the README.")
scope.send("function_validate_string", args)
end
end
2 changes: 1 addition & 1 deletion lib/puppet/parser/functions/is_absolute_path.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module Puppet::Parser::Functions
is_absolute_path($undefined)
ENDHEREDOC
function_deprecation([:puppet_3_type_check, 'This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Absolute_path. There is further documentation for validate_legacy function in the README.'])
function_deprecation([:is_absolute_path, 'This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Absolute_path. There is further documentation for validate_legacy function in the README.'])
require 'puppet/util'

path = args[0]
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/parser/functions/is_array.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module Puppet::Parser::Functions
EOS
) do |arguments|

function_deprecation([:puppet_3_type_check, 'This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Array. There is further documentation for validate_legacy function in the README.'])
function_deprecation([:is_array, 'This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Array. There is further documentation for validate_legacy function in the README.'])

raise(Puppet::ParseError, "is_array(): Wrong number of arguments " +
"given (#{arguments.size} for 1)") if arguments.size < 1
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/parser/functions/is_bool.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module Puppet::Parser::Functions
EOS
) do |arguments|

function_deprecation([:puppet_3_type_check, 'This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Bool. There is further documentation for validate_legacy function in the README.'])
function_deprecation([:is_bool, 'This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Bool. There is further documentation for validate_legacy function in the README.'])

raise(Puppet::ParseError, "is_bool(): Wrong number of arguments " +
"given (#{arguments.size} for 1)") if arguments.size != 1
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/parser/functions/is_float.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module Puppet::Parser::Functions
EOS
) do |arguments|

function_deprecation([:puppet_3_type_check, 'This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Float. There is further documentation for validate_legacy function in the README.'])
function_deprecation([:is_float, 'This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Float. There is further documentation for validate_legacy function in the README.'])

if (arguments.size != 1) then
raise(Puppet::ParseError, "is_float(): Wrong number of arguments "+
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/parser/functions/is_ip_address.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module Puppet::Parser::Functions

require 'ipaddr'

function_deprecation([:puppet_3_type_check, 'This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Ip_address. There is further documentation for validate_legacy function in the README.'])
function_deprecation([:is_ip_address, 'This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Ip_address. There is further documentation for validate_legacy function in the README.'])

if (arguments.size != 1) then
raise(Puppet::ParseError, "is_ip_address(): Wrong number of arguments "+
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/parser/functions/is_ipv4_address.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module Puppet::Parser::Functions

require 'ipaddr'

function_deprecation([:puppet_3_type_check, 'This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Ipv4. There is further documentation for validate_legacy function in the README.'])
function_deprecation([:is_ipv4_address, 'This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Ipv4. There is further documentation for validate_legacy function in the README.'])

if (arguments.size != 1) then
raise(Puppet::ParseError, "is_ipv4_address(): Wrong number of arguments "+
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/parser/functions/is_ipv6_address.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module Puppet::Parser::Functions
EOS
) do |arguments|

function_deprecation([:puppet_3_type_check, 'This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Ipv6. There is further documentation for validate_legacy function in the README.'])
function_deprecation([:is_ipv6_address, 'This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Ipv6. There is further documentation for validate_legacy function in the README.'])

require 'ipaddr'

Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/parser/functions/is_numeric.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module Puppet::Parser::Functions
EOS
) do |arguments|

function_deprecation([:puppet_3_type_check, 'This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Numeric. There is further documentation for validate_legacy function in the README.'])
function_deprecation([:is_numeric, 'This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Numeric. There is further documentation for validate_legacy function in the README.'])

if (arguments.size != 1) then
raise(Puppet::ParseError, "is_numeric(): Wrong number of arguments "+
Expand Down
5 changes: 3 additions & 2 deletions lib/puppet/parser/functions/is_string.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ module Puppet::Parser::Functions
EOS
) do |arguments|

function_deprecation([:puppet_3_type_check, 'This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::String. There is further documentation for validate_legacy function in the README.'])
function_deprecation([:is_string, 'This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::String. There is further documentation for validate_legacy function in the README.'])

raise(Puppet::ParseError, "is_string(): Wrong number of arguments " +
"given (#{arguments.size} for 1)") if arguments.size < 1

type = arguments[0]

result = type.is_a?(String)
# when called through the v4 API shim, undef gets translated to nil
result = type.is_a?(String) || type.nil?

if result and (type == type.to_f.to_s or type == type.to_i.to_s) then
return false
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/parser/functions/validate_absolute_path.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module Puppet::Parser::Functions
ENDHEREDOC

# The deprecation function was being called twice, as validate_absolute_path calls is_absolute_path. I have removed it from here so it only calls deprecation once within is_absolute_path.
# function_deprecation([:puppet_3_type_check, 'This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Absolute_path. There is further documentation for validate_legacy function in the README.'])
# function_deprecation([:validate_absolute_path, 'This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Absolute_path. There is further documentation for validate_legacy function in the README.'])

require 'puppet/util'

Expand Down
Loading

0 comments on commit 6fb7465

Please sign in to comment.