From 39bd0df71e788a16b1649d597947cefea5712788 Mon Sep 17 00:00:00 2001 From: Tobias Urdin Date: Sat, 23 Feb 2019 22:32:56 +0100 Subject: [PATCH] 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: I041af9f00d9463e35a53d1979cf03697cdf41376 --- manifests/db.pp | 4 ++-- manifests/log.pp | 2 +- spec/defines/oslo_db_spec.rb | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/manifests/db.pp b/manifests/db.pp index ee6257b..3b7d02b 100644 --- a/manifests/db.pp +++ b/manifests/db.pp @@ -136,8 +136,8 @@ define oslo::db( if !is_service_default($connection) { - validate_re($connection, - '^(sqlite|mysql(\+pymysql)?|postgresql(\+psycopg2)?|mongodb):\/\/(\S+:\S+@\S+\/\S+)?') + validate_legacy(Oslo::Dbconn, 'validate_re', $connection, + ['^(sqlite|mysql(\+pymysql)?|postgresql(\+psycopg2)?|mongodb):\/\/(\S+:\S+@\S+\/\S+)?']) if $manage_backend_package { case $connection { diff --git a/manifests/log.pp b/manifests/log.pp index 0e1d0b2..96ce363 100644 --- a/manifests/log.pp +++ b/manifests/log.pp @@ -137,7 +137,7 @@ define oslo::log( if is_service_default($default_log_levels) { $default_log_levels_real = $default_log_levels } else { - validate_hash($default_log_levels) + validate_legacy(Hash, 'validate_hash', $default_log_levels) $default_log_levels_real = join(sort(join_keys_to_values($default_log_levels, '=')), ',') } diff --git a/spec/defines/oslo_db_spec.rb b/spec/defines/oslo_db_spec.rb index cba5026..47e5431 100644 --- a/spec/defines/oslo_db_spec.rb +++ b/spec/defines/oslo_db_spec.rb @@ -157,7 +157,7 @@ describe 'oslo::db' do { :connection => 'foo://db:db@localhost/db', } end - it_raises 'a Puppet::Error', /validate_re/ + it { should raise_error(Puppet::Error) } end context 'with incorrect pymysql database_connection string' do @@ -165,7 +165,7 @@ describe 'oslo::db' do { :connection => 'foo+pymysql://db:db@localhost/db', } end - it_raises 'a Puppet::Error', /validate_re/ + it { should raise_error(Puppet::Error) } end end