From dc906582e9eed796e971c55e839550fa11f60a97 Mon Sep 17 00:00:00 2001 From: Tobias Urdin Date: Sat, 23 Feb 2019 11:46:05 +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: I7e0af11ac8c01253778312e26430be6beeac1267 --- manifests/api.pp | 6 +++--- manifests/config.pp | 4 ++-- manifests/db.pp | 3 ++- manifests/db/mysql.pp | 12 ++++++------ manifests/init.pp | 6 +++--- manifests/keystone/auth.pp | 14 +++++++------- manifests/metadata.pp | 6 +++--- manifests/policy.pp | 2 +- 8 files changed, 27 insertions(+), 26 deletions(-) diff --git a/manifests/api.pp b/manifests/api.pp index eed5cd5..76f00a9 100644 --- a/manifests/api.pp +++ b/manifests/api.pp @@ -282,9 +282,9 @@ class ec2api::api ( include ::ec2api::deps - validate_bool($manage_service) - validate_string($service_name) - validate_bool($enabled) + validate_legacy(Boolean, 'validate_bool', $manage_service) + validate_legacy(String, 'validate_string', $service_name) + validate_legacy(Boolean, 'validate_bool', $enabled) ec2api_config { 'DEFAULT/keystone_ec2_tokens_url': value => $keystone_ec2_tokens_url; diff --git a/manifests/config.pp b/manifests/config.pp index a3eb46d..a9c7456 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -30,8 +30,8 @@ class ec2api::config ( include ::ec2api::deps - validate_hash($ec2api_config) - validate_hash($ec2api_api_paste_ini) + validate_legacy(Hash, 'validate_hash', $ec2api_config) + validate_legacy(Hash, 'validate_hash', $ec2api_api_paste_ini) create_resources('ec2api_config', $ec2api_config) create_resources('ec2api_api_paste_ini', $ec2api_api_paste_ini) diff --git a/manifests/db.pp b/manifests/db.pp index 0601e6b..8583ad4 100644 --- a/manifests/db.pp +++ b/manifests/db.pp @@ -56,7 +56,8 @@ class ec2api::db ( 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': connection => $database_connection, diff --git a/manifests/db/mysql.pp b/manifests/db/mysql.pp index 32e307a..41e3987 100644 --- a/manifests/db/mysql.pp +++ b/manifests/db/mysql.pp @@ -45,12 +45,12 @@ class ec2api::db::mysql ( include ::ec2api::deps - validate_string($password) - validate_string($dbname) - validate_string($user) - validate_string($host) - validate_string($charset) - validate_string($collate) + validate_legacy(String, 'validate_string', $password) + validate_legacy(String, 'validate_string', $dbname) + validate_legacy(String, 'validate_string', $user) + validate_legacy(String, 'validate_string', $host) + validate_legacy(String, 'validate_string', $charset) + validate_legacy(String, 'validate_string', $collate) ::openstacklib::db::mysql { 'ec2api': user => $user, diff --git a/manifests/init.pp b/manifests/init.pp index fef40f1..0749902 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -37,9 +37,9 @@ class ec2api ( include ::ec2api::policy include ::ec2api::db - validate_string($package_ensure) - validate_bool($package_manage) - validate_string($package_name) + validate_legacy(String, 'validate_string', $package_ensure) + validate_legacy(Boolean, 'validate_bool', $package_manage) + validate_legacy(String, 'validate_string', $package_name) if $package_manage { package { 'ec2api' : diff --git a/manifests/keystone/auth.pp b/manifests/keystone/auth.pp index de6eca5..46d65d5 100644 --- a/manifests/keystone/auth.pp +++ b/manifests/keystone/auth.pp @@ -80,13 +80,13 @@ class ec2api::keystone::auth ( include ::ec2api::deps - validate_string($password) - validate_string($auth_name) - validate_string($email) - validate_string($tenant) - validate_bool($configure_endpoint) - validate_bool($configure_user) - validate_bool($configure_user_role) + validate_legacy(String, 'validate_string', $password) + validate_legacy(String, 'validate_string', $auth_name) + validate_legacy(String, 'validate_string', $email) + validate_legacy(String, 'validate_string', $tenant) + validate_legacy(Boolean, 'validate_bool', $configure_endpoint) + validate_legacy(Boolean, 'validate_bool', $configure_user) + validate_legacy(Boolean, 'validate_bool', $configure_user_role) $real_service_name = pick($service_name, $auth_name) diff --git a/manifests/metadata.pp b/manifests/metadata.pp index be102a4..8c0e7bc 100644 --- a/manifests/metadata.pp +++ b/manifests/metadata.pp @@ -94,9 +94,9 @@ class ec2api::metadata ( include ::ec2api::deps - validate_bool($manage_service) - validate_string($service_name) - validate_bool($enabled) + validate_legacy(Boolean, 'validate_bool', $manage_service) + validate_legacy(String, 'validate_string', $service_name) + validate_legacy(Boolean, 'validate_bool', $enabled) ec2api_config { 'metadata/nova_metadata_ip': value => $nova_metadata_ip; diff --git a/manifests/policy.pp b/manifests/policy.pp index b0a5749..7a6004a 100644 --- a/manifests/policy.pp +++ b/manifests/policy.pp @@ -31,7 +31,7 @@ class ec2api::policy ( include ::ec2api::deps include ::ec2api::params - validate_hash($policies) + validate_legacy(Hash, 'validate_hash', $policies) Openstacklib::Policy::Base { file_path => $policy_path,