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: Ib21fef57404d63579743270be4080d248a4ca8cc
This commit is contained in:
Tobias Urdin 2019-02-23 11:57:34 +01:00
parent e51177e296
commit 4b558f6f00
9 changed files with 18 additions and 16 deletions

View File

@ -521,7 +521,8 @@ class glance::api(
# Set the pipeline, it is allowed to be blank
if $pipeline != '' {
validate_re($pipeline, '^(\w+([+]\w+)*)*$')
validate_legacy(Pattern[/^(\w+([+]\w+)*)*$/], 'validate_re', $pipeline, ['^(\w+([+]\w+)*)*$'])
glance_api_config {
'paste_deploy/flavor':
ensure => present,

View File

@ -66,8 +66,8 @@ class glance::api::db (
$database_retry_interval_real = pick($::glance::api::database_retry_interval, $database_retry_interval)
$database_max_overflow_real = pick($::glance::api::database_max_overflow, $database_max_overflow)
validate_re($database_connection_real,
'^(sqlite|mysql(\+pymysql)?|postgresql):\/\/(\S+:\S+@\S+\/\S+)?')
validate_legacy(Oslo::Dbconn, 'validate_re', $database_connection_real,
['^(sqlite|mysql(\+pymysql)?|postgresql):\/\/(\S+:\S+@\S+\/\S+)?'])
oslo::db { 'glance_api_config':
db_max_retries => $database_db_max_retries,

View File

@ -49,12 +49,12 @@ class glance::config (
include ::glance::deps
validate_hash($api_config)
validate_hash($api_paste_ini_config)
validate_hash($registry_config)
validate_hash($registry_paste_ini_config)
validate_hash($cache_config)
validate_hash($image_import_config)
validate_legacy(Hash, 'validate_hash', $api_config)
validate_legacy(Hash, 'validate_hash', $api_paste_ini_config)
validate_legacy(Hash, 'validate_hash', $registry_config)
validate_legacy(Hash, 'validate_hash', $registry_paste_ini_config)
validate_legacy(Hash, 'validate_hash', $cache_config)
validate_legacy(Hash, 'validate_hash', $image_import_config)
create_resources('glance_api_config', $api_config)
create_resources('glance_api_paste_ini', $api_paste_ini_config)

View File

@ -42,7 +42,7 @@ class glance::db::mysql(
include ::glance::deps
validate_string($password)
validate_legacy(String, 'validate_string', $password)
::openstacklib::db::mysql { 'glance':
user => $user,

View File

@ -31,7 +31,7 @@ class glance::policy (
include ::glance::deps
include ::glance::params
validate_hash($policies)
validate_legacy(Hash, 'validate_hash', $policies)
Openstacklib::Policy::Base {
file_path => $policy_path,

View File

@ -146,7 +146,8 @@ class glance::registry(
# Set the pipeline, it is allowed to be blank
if $pipeline != '' {
validate_re($pipeline, '^(\w+([+]\w+)*)*$')
validate_legacy(Pattern[/^(\w+([+]\w+)*)*$/], 'validate_re', $pipeline, ['^(\w+([+]\w+)*)*$'])
glance_registry_config {
'paste_deploy/flavor':
ensure => present,

View File

@ -66,8 +66,8 @@ class glance::registry::db (
$database_retry_interval_real = pick($::glance::registry::database_retry_interval, $database_retry_interval)
$database_max_overflow_real = pick($::glance::registry::database_max_overflow, $database_max_overflow)
validate_re($database_connection_real,
'^(sqlite|mysql(\+pymysql)?|postgresql):\/\/(\S+:\S+@\S+\/\S+)?')
validate_legacy(Oslo::Dbconn, 'validate_re', $database_connection_real,
['^(sqlite|mysql(\+pymysql)?|postgresql):\/\/(\S+:\S+@\S+\/\S+)?'])
oslo::db { 'glance_registry_config':
db_max_retries => $database_db_max_retries,

View File

@ -274,7 +274,7 @@ describe 'glance::api' do
end
it { expect { is_expected.to contain_glance_api_config('filter:paste_deploy/flavor') }.to\
raise_error(Puppet::Error, /validate_re\(\): .* does not match/) }
raise_error(Puppet::Error) }
end
end

View File

@ -150,7 +150,7 @@ describe 'glance::registry' do
end
it { expect { is_expected.to contain_glance_registry_config('filter:paste_deploy/flavor') }.to\
raise_error(Puppet::Error, /validate_re\(\): .* does not match/) }
raise_error(Puppet::Error) }
end
end