replace validate_legacy with proper data types

the validate_legacy function is marked for deprecation in
v9.0.0 from puppetlabs-stdlib.

Change-Id: I14ad3f5a77573b1bf82b490249ca5a8a6b220565
This commit is contained in:
Takashi Kajinami 2023-06-19 16:49:09 +09:00
parent 3f5c30de21
commit 74e7afdb9e
5 changed files with 13 additions and 22 deletions

View File

@ -13,15 +13,12 @@
# Defaults to 'present'
#
class gnocchi::db (
$database_connection = 'sqlite:////var/lib/gnocchi/gnocchi.sqlite',
$package_ensure = 'present',
Oslo::DBconn $database_connection = 'sqlite:////var/lib/gnocchi/gnocchi.sqlite',
$package_ensure = 'present',
) inherits gnocchi::params {
include gnocchi::deps
validate_legacy(Oslo::Dbconn, 'validate_re', $database_connection,
['^(sqlite|mysql(\+pymysql)?|postgresql):\/\/(\S+:\S+@\S+\/\S+)?'])
if $database_connection {
case $database_connection {
/^mysql(\+pymysql)?:\/\//: {

View File

@ -34,7 +34,7 @@
# Defaults to 'utf8_general_ci'
#
class gnocchi::db::mysql(
$password,
String[1] $password,
$dbname = 'gnocchi',
$user = 'gnocchi',
$host = '127.0.0.1',
@ -45,8 +45,6 @@ class gnocchi::db::mysql(
include gnocchi::deps
validate_legacy(String, 'validate_string', $password)
::openstacklib::db::mysql { 'gnocchi':
user => $user,
password => $password,

View File

@ -54,19 +54,17 @@
#
class gnocchi::storage::ceph(
$ceph_username,
$ceph_keyring = $facts['os_service_default'],
$ceph_secret = $facts['os_service_default'],
$ceph_pool = 'gnocchi',
$ceph_timeout = $facts['os_service_default'],
$ceph_conffile = '/etc/ceph/ceph.conf',
$manage_rados = true,
$package_ensure = 'present',
$ceph_keyring = $facts['os_service_default'],
$ceph_secret = $facts['os_service_default'],
$ceph_pool = 'gnocchi',
$ceph_timeout = $facts['os_service_default'],
$ceph_conffile = '/etc/ceph/ceph.conf',
Boolean $manage_rados = true,
$package_ensure = 'present',
) inherits gnocchi::params {
include gnocchi::deps
validate_legacy(Boolean, 'validate_bool', $manage_rados)
if (is_service_default($ceph_keyring) and is_service_default($ceph_secret)) or (! $ceph_keyring and ! $ceph_secret) {
fail('You need to specify either gnocchi::storage::ceph::ceph_keyring or gnocchi::storage::ceph::ceph_secret.')
}

View File

@ -39,15 +39,13 @@ class gnocchi::storage::s3(
$s3_access_key_id = undef,
$s3_secret_access_key = undef,
$s3_bucket_prefix = $facts['os_service_default'],
$manage_boto3 = true,
Boolean $manage_boto3 = true,
$package_ensure = 'present',
) {
include gnocchi::deps
include gnocchi::params
validate_legacy(Boolean, 'validate_bool', $manage_boto3)
if $manage_boto3 {
ensure_packages('python-boto3', {
'ensure' => $package_ensure,

View File

@ -48,7 +48,7 @@ describe 'gnocchi::db' do
}
end
it { should raise_error(Puppet::Error, /validate_re/) }
it { should raise_error(Puppet::Error) }
end
context 'with incorrect pymysql database_connection string' do
@ -58,7 +58,7 @@ describe 'gnocchi::db' do
}
end
it { should raise_error(Puppet::Error, /validate_re/) }
it { should raise_error(Puppet::Error) }
end
end