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: I7e0af11ac8c01253778312e26430be6beeac1267
This commit is contained in:
Tobias Urdin 2019-02-23 11:46:05 +01:00
parent 1c40ef70f3
commit dc906582e9
8 changed files with 27 additions and 26 deletions

View File

@ -282,9 +282,9 @@ class ec2api::api (
include ::ec2api::deps include ::ec2api::deps
validate_bool($manage_service) validate_legacy(Boolean, 'validate_bool', $manage_service)
validate_string($service_name) validate_legacy(String, 'validate_string', $service_name)
validate_bool($enabled) validate_legacy(Boolean, 'validate_bool', $enabled)
ec2api_config { ec2api_config {
'DEFAULT/keystone_ec2_tokens_url': value => $keystone_ec2_tokens_url; 'DEFAULT/keystone_ec2_tokens_url': value => $keystone_ec2_tokens_url;

View File

@ -30,8 +30,8 @@ class ec2api::config (
include ::ec2api::deps include ::ec2api::deps
validate_hash($ec2api_config) validate_legacy(Hash, 'validate_hash', $ec2api_config)
validate_hash($ec2api_api_paste_ini) validate_legacy(Hash, 'validate_hash', $ec2api_api_paste_ini)
create_resources('ec2api_config', $ec2api_config) create_resources('ec2api_config', $ec2api_config)
create_resources('ec2api_api_paste_ini', $ec2api_api_paste_ini) create_resources('ec2api_api_paste_ini', $ec2api_api_paste_ini)

View File

@ -56,7 +56,8 @@ class ec2api::db (
include ::ec2api::deps include ::ec2api::deps
validate_re($database_connection, '^(sqlite|mysql(\+pymysql)?|postgresql):\/\/(\S+:\S+@\S+\/\S+)?') validate_legacy(Oslo::Dbconn, 'validate_re', $database_connection,
['^(sqlite|mysql(\+pymysql)?|postgresql):\/\/(\S+:\S+@\S+\/\S+)?'])
oslo::db { 'ec2api_config': oslo::db { 'ec2api_config':
connection => $database_connection, connection => $database_connection,

View File

@ -45,12 +45,12 @@ class ec2api::db::mysql (
include ::ec2api::deps include ::ec2api::deps
validate_string($password) validate_legacy(String, 'validate_string', $password)
validate_string($dbname) validate_legacy(String, 'validate_string', $dbname)
validate_string($user) validate_legacy(String, 'validate_string', $user)
validate_string($host) validate_legacy(String, 'validate_string', $host)
validate_string($charset) validate_legacy(String, 'validate_string', $charset)
validate_string($collate) validate_legacy(String, 'validate_string', $collate)
::openstacklib::db::mysql { 'ec2api': ::openstacklib::db::mysql { 'ec2api':
user => $user, user => $user,

View File

@ -37,9 +37,9 @@ class ec2api (
include ::ec2api::policy include ::ec2api::policy
include ::ec2api::db include ::ec2api::db
validate_string($package_ensure) validate_legacy(String, 'validate_string', $package_ensure)
validate_bool($package_manage) validate_legacy(Boolean, 'validate_bool', $package_manage)
validate_string($package_name) validate_legacy(String, 'validate_string', $package_name)
if $package_manage { if $package_manage {
package { 'ec2api' : package { 'ec2api' :

View File

@ -80,13 +80,13 @@ class ec2api::keystone::auth (
include ::ec2api::deps include ::ec2api::deps
validate_string($password) validate_legacy(String, 'validate_string', $password)
validate_string($auth_name) validate_legacy(String, 'validate_string', $auth_name)
validate_string($email) validate_legacy(String, 'validate_string', $email)
validate_string($tenant) validate_legacy(String, 'validate_string', $tenant)
validate_bool($configure_endpoint) validate_legacy(Boolean, 'validate_bool', $configure_endpoint)
validate_bool($configure_user) validate_legacy(Boolean, 'validate_bool', $configure_user)
validate_bool($configure_user_role) validate_legacy(Boolean, 'validate_bool', $configure_user_role)
$real_service_name = pick($service_name, $auth_name) $real_service_name = pick($service_name, $auth_name)

View File

@ -94,9 +94,9 @@ class ec2api::metadata (
include ::ec2api::deps include ::ec2api::deps
validate_bool($manage_service) validate_legacy(Boolean, 'validate_bool', $manage_service)
validate_string($service_name) validate_legacy(String, 'validate_string', $service_name)
validate_bool($enabled) validate_legacy(Boolean, 'validate_bool', $enabled)
ec2api_config { ec2api_config {
'metadata/nova_metadata_ip': value => $nova_metadata_ip; 'metadata/nova_metadata_ip': value => $nova_metadata_ip;

View File

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