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: I6e75488ea8cfb5cb2be5fdb892355274ab18224b
This commit is contained in:
parent
4a7ed3f84b
commit
c2aa24ac27
|
@ -31,8 +31,9 @@ class monasca::config (
|
|||
$monasca_config = {},
|
||||
$monasca_ini = {},
|
||||
) {
|
||||
validate_hash($monasca_config)
|
||||
validate_hash($monasca_ini)
|
||||
|
||||
validate_legacy(Hash, 'validate_hash', $monasca_config)
|
||||
validate_legacy(Hash, 'validate_hash', $monasca_ini)
|
||||
|
||||
create_resources('monasca_config', $monasca_config)
|
||||
create_resources('monasca_ini', $monasca_ini)
|
||||
|
|
|
@ -93,15 +93,17 @@ class monasca::params(
|
|||
'database_type' => 'influxdb',
|
||||
}
|
||||
) {
|
||||
|
||||
include ::openstacklib::defaults
|
||||
validate_string($admin_password)
|
||||
validate_string($admin_project_name)
|
||||
validate_string($user_password)
|
||||
validate_string($agent_password)
|
||||
validate_string($sql_password)
|
||||
validate_string($sql_host)
|
||||
validate_string($api_db_password)
|
||||
validate_string($pers_db_password)
|
||||
|
||||
validate_legacy(String, 'validate_string', $admin_password)
|
||||
validate_legacy(String, 'validate_string', $admin_project_name)
|
||||
validate_legacy(String, 'validate_string', $user_password)
|
||||
validate_legacy(String, 'validate_string', $agent_password)
|
||||
validate_legacy(String, 'validate_string', $sql_password)
|
||||
validate_legacy(String, 'validate_string', $sql_host)
|
||||
validate_legacy(String, 'validate_string', $api_db_password)
|
||||
validate_legacy(String, 'validate_string', $pers_db_password)
|
||||
|
||||
if $::osfamily == 'Debian' {
|
||||
$agent_package = 'monasca-agent'
|
||||
|
|
|
@ -36,13 +36,16 @@ define monasca::virtualenv::agent_instance(
|
|||
$venv_active = false,
|
||||
$venv_extra_args = undef,
|
||||
) {
|
||||
validate_string($ensure)
|
||||
|
||||
validate_legacy(String, 'validate_string', $ensure)
|
||||
|
||||
$valid_values = [
|
||||
'^present$',
|
||||
'^absent$',
|
||||
]
|
||||
validate_re($ensure, $valid_values,
|
||||
"Unknown value '${ensure}' for ensure, must be present or absent")
|
||||
|
||||
validate_legacy(Enum['present', 'absent'], 'validate_re', $ensure,
|
||||
[$valid_values, "Unknown value '${ensure}' for ensure, must be present or absent"])
|
||||
|
||||
File[$basedir] -> anchor { 'monasca::virtualenv::instance': }
|
||||
Package<| name == 'python-virtualenv' |> -> Anchor['monasca::virtualenv::instance']
|
||||
|
|
|
@ -58,20 +58,23 @@ define monasca::virtualenv::instance(
|
|||
$venv_active = false,
|
||||
$venv_extra_args = undef,
|
||||
) {
|
||||
validate_string($ensure)
|
||||
|
||||
validate_legacy(String, 'validate_string', $ensure)
|
||||
|
||||
$valid_values = [
|
||||
'^present$',
|
||||
'^absent$',
|
||||
]
|
||||
validate_re($ensure, $valid_values,
|
||||
"Unknown value '${ensure}' for ensure, must be present or absent")
|
||||
|
||||
validate_legacy(Enum['present', 'absent'], 'validate_re', $ensure,
|
||||
[$valid_values, "Unknown value '${ensure}' for ensure, must be present or absent"])
|
||||
|
||||
$req_dest = "${basedir}/${venv_prefix}-requirements.txt"
|
||||
$venv_dir = "${basedir}/${venv_prefix}-venv"
|
||||
$venv_name = "${venv_prefix}-${name}"
|
||||
|
||||
if $ensure == 'present' {
|
||||
validate_string($venv_requirements)
|
||||
validate_legacy(String, 'validate_string', $venv_requirements)
|
||||
|
||||
file { $req_dest:
|
||||
ensure => 'file',
|
||||
|
|
Loading…
Reference in New Issue