Skip to content
This repository has been archived by the owner on Dec 31, 2024. It is now read-only.

Commit

Permalink
Use more types instead of validations
Browse files Browse the repository at this point in the history
  • Loading branch information
BuJo committed Sep 6, 2023
1 parent a361775 commit 5868482
Showing 1 changed file with 14 additions and 35 deletions.
49 changes: 14 additions & 35 deletions manifests/instance.pp
Original file line number Diff line number Diff line change
@@ -1,42 +1,21 @@
# port389::instance
define port389::instance (
$admin_domain = $::port389::admin_domain,
$config_directory_admin_id = $::port389::config_directory_admin_id,
$config_directory_admin_pwd = $::port389::config_directory_admin_pwd,
$config_directory_ldap_url = $::port389::config_directory_ldap_url,
$root_dn = $::port389::root_dn,
$root_dn_pwd = $::port389::root_dn_pwd,
$server_port = $::port389::server_port,
$enable_ssl = $::port389::enable_ssl,
$ssl_server_port = $::port389::ssl_server_port,
$ssl_cert = $::port389::ssl_cert,
$ssl_key = $::port389::ssl_key,
$ssl_ca_certs = $::port389::ssl_ca_certs,
$schema_file = undef,
$suffix = port389_domain2dn($::port389::admin_domain),
Stdlib::Fqdn $admin_domain = $::port389::admin_domain,
String $config_directory_admin_id = $::port389::config_directory_admin_id,
String $config_directory_admin_pwd = $::port389::config_directory_admin_pwd,
String $config_directory_ldap_url = $::port389::config_directory_ldap_url,
String $root_dn = $::port389::root_dn,
String $root_dn_pwd = $::port389::root_dn_pwd,
String $server_port = $::port389::server_port,
Boolean $enable_ssl = $::port389::enable_ssl,
Optional[String] $ssl_server_port = $::port389::ssl_server_port,
Optional[Stdlib::Absolutepath] $ssl_cert = $::port389::ssl_cert,
Optional[Stdlib::Absolutepath] $ssl_key = $::port389::ssl_key,
Optional[Hash] $ssl_ca_certs = $::port389::ssl_ca_certs,
Optional[String] $schema_file = undef,
String $suffix = port389_domain2dn($::port389::admin_domain),
) {
# follow the same server identifier validation rules as setup-ds-admin.pl
validate_re($title, '^[\w#%:@-]*$', "The ServerIdentifier '${title}' contains invalid characters.\
It must contain only alphanumeric characters and the following: #%:@_-")
validate_string($admin_domain)
validate_string($config_directory_admin_id)
validate_string($config_directory_admin_pwd)
validate_string($config_directory_ldap_url)
validate_string($root_dn)
validate_string($root_dn_pwd)
validate_string($server_port)
# ssl
validate_bool($enable_ssl)
# don't validate ssl_* params unless $enable_ssl == true
if $enable_ssl {
validate_string($ssl_server_port)
validate_absolute_path($ssl_cert)
validate_absolute_path($ssl_key)
validate_hash($ssl_ca_certs)
}
# schema_file may be undef
validate_string($suffix)

$setup_inf_name = "setup_${title}.inf"
$setup_inf_path = "${::port389::setup_dir}/${setup_inf_name}"

Expand Down

0 comments on commit 5868482

Please sign in to comment.