Use validate_legacy
This changes all the puppet 3 validate_* functions to use the validate_legacy function. The validate_legacy function has been available since about three years but require Puppet >= 4.4.0 and since there is Puppet 4.10.12 as latest we should assume people are running a fairly new Puppet 4 version. This is the first step to then remove all validate function calls and use proper types for parameter as described in spec [1]. [1] https://review.openstack.org/#/c/568929/ Change-Id: If8c450da479eca3167d93a1ef29ac8b1bc4312ca
This commit is contained in:
parent
37ea75ea34
commit
d83b0dafdc
|
@ -38,9 +38,9 @@ class designate::config (
|
|||
|
||||
include ::designate::deps
|
||||
|
||||
validate_hash($designate_config)
|
||||
validate_hash($api_paste_ini_config)
|
||||
validate_hash($rootwrap_config)
|
||||
validate_legacy(Hash, 'validate_hash', $designate_config)
|
||||
validate_legacy(Hash, 'validate_hash', $api_paste_ini_config)
|
||||
validate_legacy(Hash, 'validate_hash', $rootwrap_config)
|
||||
|
||||
create_resources('designate_config', $designate_config)
|
||||
create_resources('designate_api_paste_ini', $api_paste_ini_config)
|
||||
|
|
|
@ -57,8 +57,8 @@ class designate::db (
|
|||
include ::designate::deps
|
||||
include ::designate::params
|
||||
|
||||
validate_re($database_connection,
|
||||
'(mysql(\+pymysql)?):\/\/(\S+:\S+@\S+\/\S+)?')
|
||||
validate_legacy(String, 'validate_re', $database_connection,
|
||||
['(mysql(\+pymysql)?):\/\/(\S+:\S+@\S+\/\S+)?'])
|
||||
|
||||
case $database_connection {
|
||||
/^mysql(\+pymysql)?:\/\//: {
|
||||
|
|
|
@ -31,7 +31,7 @@ class designate::policy (
|
|||
include ::designate::deps
|
||||
include ::designate::params
|
||||
|
||||
validate_hash($policies)
|
||||
validate_legacy(Hash, 'validate_hash', $policies)
|
||||
|
||||
Openstacklib::Policy::Base {
|
||||
file_path => $policy_path,
|
||||
|
|
|
@ -21,11 +21,13 @@ define designate::pool(
|
|||
|
||||
include ::designate::deps
|
||||
|
||||
validate_re($name, '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}',
|
||||
'Pool name should be a UUID.')
|
||||
validate_array($nameservers)
|
||||
validate_array($targets)
|
||||
validate_array($also_notifies)
|
||||
validate_legacy(Pattern[/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/],
|
||||
'validate_re', $name, ['[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}',
|
||||
'Pool name should be a UUID.'])
|
||||
|
||||
validate_legacy(Array, 'validate_array', $nameservers)
|
||||
validate_legacy(Array, 'validate_array', $targets)
|
||||
validate_legacy(Array, 'validate_array', $also_notifies)
|
||||
|
||||
designate_config {
|
||||
"pool:${name}/nameservers": value => join($nameservers,',');
|
||||
|
|
|
@ -19,7 +19,7 @@ class designate::pool_manager_cache::memcache(
|
|||
|
||||
include ::designate::deps
|
||||
|
||||
validate_array($memcached_servers)
|
||||
validate_legacy(Array, 'validate_array', $memcached_servers)
|
||||
|
||||
designate_config {
|
||||
'service:pool_manager/cache_driver': value => 'memcache';
|
||||
|
|
|
@ -15,8 +15,9 @@ define designate::pool_nameserver(
|
|||
|
||||
include ::designate::deps
|
||||
|
||||
validate_re($name, '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}',
|
||||
'Name should be a UUID.')
|
||||
validate_legacy(Pattern[/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/],
|
||||
'validate_re', $name, ['[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}',
|
||||
'Name should be a UUID.'])
|
||||
|
||||
designate_config {
|
||||
"pool_nameserver:${name}/port": value => $port;
|
||||
|
|
|
@ -35,8 +35,9 @@ define designate::pool_target (
|
|||
include ::powerdns::mysql
|
||||
}
|
||||
|
||||
validate_re($name, '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}')
|
||||
validate_array($masters)
|
||||
validate_legacy(Pattern[/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/],
|
||||
'validate_re', $name, ['[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'])
|
||||
validate_legacy(Array, 'validate_array', $masters)
|
||||
|
||||
if is_hash($options) {
|
||||
$options_real = join(join_keys_to_values($options,':'),',')
|
||||
|
|
|
@ -39,7 +39,7 @@ describe 'designate::db' do
|
|||
{ :database_connection => 'redis://designate:designate@localhost/designate', }
|
||||
end
|
||||
|
||||
it_raises 'a Puppet::Error', /validate_re/
|
||||
it { should raise_error(Puppet::Error) }
|
||||
end
|
||||
|
||||
context 'with specific parameters' do
|
||||
|
|
Loading…
Reference in New Issue