Skip to content

Commit

Permalink
Merge pull request #350 from voxpupuli/puppet4
Browse files Browse the repository at this point in the history
replace validate_* with puppet4 datatypes
  • Loading branch information
rnelson0 authored Jun 12, 2017
2 parents 253bc8e + 2241148 commit 00a0b8f
Show file tree
Hide file tree
Showing 20 changed files with 163 additions and 275 deletions.
7 changes: 2 additions & 5 deletions manifests/apache_config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,14 @@
# Hash with nested hash of key => value to set in inifile
#
class php::apache_config(
$inifile = $::php::params::apache_inifile,
$settings = {}
Stdlib::Absolutepath $inifile = $::php::params::apache_inifile,
Hash $settings = {}
) inherits ::php::params {

if $caller_module_name != $module_name {
warning('php::apache_config is private')
}

validate_absolute_path($inifile)
validate_hash($settings)

$real_settings = deep_merge($settings, hiera_hash('php::apache::settings', {}))

::php::config { 'apache':
Expand Down
7 changes: 2 additions & 5 deletions manifests/cli.pp
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,14 @@
# Hash with nested hash of key => value to set in inifile
#
class php::cli(
$inifile = $::php::params::cli_inifile,
$settings = {}
Stdlib::Absolutepath $inifile = $::php::params::cli_inifile,
Hash $settings = {}
) inherits ::php::params {

if $caller_module_name != $module_name {
warning('php::cli is private')
}

validate_absolute_path($inifile)
validate_hash($settings)

$real_settings = deep_merge($settings, hiera_hash('php::cli::settings', {}))

::php::config { 'cli':
Expand Down
19 changes: 7 additions & 12 deletions manifests/composer.pp
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,19 @@
# UNIX group of the root user
#
class php::composer (
$source = $::php::params::composer_source,
$path = $::php::params::composer_path,
$proxy_type = undef,
$proxy_server = undef,
$auto_update = true,
$max_age = $::php::params::composer_max_age,
$root_group = $::php::params::root_group,
String $source = $::php::params::composer_source,
Stdlib::Absolutepath $path = $::php::params::composer_path,
$proxy_type = undef,
$proxy_server = undef,
Boolean $auto_update = true,
Integer $max_age = $::php::params::composer_max_age,
Variant[Integer, String] $root_group = $::php::params::root_group,
) inherits ::php::params {

if $caller_module_name != $module_name {
warning('php::composer is private')
}

validate_string($source)
validate_absolute_path($path)
validate_bool($auto_update)
validate_re("x${max_age}", '^x\d+$')

archive { 'download composer':
path => $path,
source => $source,
Expand Down
7 changes: 2 additions & 5 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,14 @@
# }
#
define php::config(
$file,
$config
Stdlib::Absolutepath $file,
Hash $config
) {

if $caller_module_name != $module_name {
warning('php::config is private')
}

validate_absolute_path($file)
validate_hash($config)

create_resources(::php::config::setting, to_hash_settings($config, $file), {
file => $file
})
Expand Down
4 changes: 1 addition & 3 deletions manifests/config/setting.pp
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,13 @@
define php::config::setting(
$key,
$value,
$file,
Stdlib::Absolutepath $file,
) {

if $caller_module_name != $module_name {
warning('php::config::setting is private')
}

validate_string($file)

$split_name = split($key, '/')
if count($split_name) == 1 {
$section = '' # lint:ignore:empty_string_assignment
Expand Down
7 changes: 2 additions & 5 deletions manifests/dev.pp
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,14 @@
# The package name for the PHP development files
#
class php::dev(
$ensure = $::php::ensure,
$package = "${::php::package_prefix}${::php::params::dev_package_suffix}",
String $ensure = $::php::ensure,
String $package = "${::php::package_prefix}${::php::params::dev_package_suffix}",
) inherits ::php::params {

if $caller_module_name != $module_name {
warning('php::dev is private')
}

validate_string($ensure)
validate_string($package)

# On FreeBSD there is no 'devel' package.
$real_package = $::osfamily ? {
'FreeBSD' => [],
Expand Down
12 changes: 4 additions & 8 deletions manifests/embedded.pp
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,16 @@
# Specify which version of the package to install
#
class php::embedded(
$ensure = $::php::ensure,
$package =
"${::php::package_prefix}${::php::params::embedded_package_suffix}",
$inifile = $::php::params::embedded_inifile,
$settings = {},
String $ensure = $::php::ensure,
String $package = "${::php::package_prefix}${::php::params::embedded_package_suffix}",
Stdlib::Absolutepath $inifile = $::php::params::embedded_inifile,
Hash $settings = {},
) inherits ::php::params {

if $caller_module_name != $module_name {
warning('php::embedded is private')
}

validate_absolute_path($inifile)
validate_hash($settings)

$real_settings = deep_merge(
$settings,
hiera_hash('php::embedded::settings', {})
Expand Down
18 changes: 9 additions & 9 deletions manifests/extension.pp
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@
# *providers*: pear, pecl.
#
define php::extension (
String $ensure = 'installed',
Optional[Php::Provider] $provider = undef,
Optional[String] $source = undef,
Optional[String] $so_name = downcase($name),
Optional[String] $php_api_version = undef,
String $package_prefix = $::php::package_prefix,
Boolean $zend = false,
Hash $settings = {},
Php::Sapi $sapi = 'ALL',
String $ensure = 'installed',
Optional[Php::Provider] $provider = undef,
Optional[String] $source = undef,
Optional[String] $so_name = downcase($name),
Optional[String] $php_api_version = undef,
String $package_prefix = $::php::package_prefix,
Boolean $zend = false,
Hash $settings = {},
Php::Sapi $sapi = 'ALL',
Variant[Boolean, String] $settings_prefix = false,
Optional[Stdlib::AbsolutePath] $responsefile = undef,
Variant[String, Array[String]] $header_packages = [],
Expand Down
8 changes: 4 additions & 4 deletions manifests/extension/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
# *providers*: pear, pecl.
#
define php::extension::install (
String $ensure = 'installed',
Optional[Php::Provider] $provider = undef,
Optional[String] $source = undef,
String $package_prefix = $::php::package_prefix,
String $ensure = 'installed',
Optional[Php::Provider] $provider = undef,
Optional[String] $source = undef,
String $package_prefix = $::php::package_prefix,
Optional[Stdlib::AbsolutePath] $responsefile = undef,
Variant[String, Array[String]] $header_packages = [],
Variant[String, Array[String]] $compiler_packages = $::php::params::compiler_packages,
Expand Down
34 changes: 14 additions & 20 deletions manifests/fpm.pp
Original file line number Diff line number Diff line change
Expand Up @@ -44,32 +44,26 @@
# Defaults is empty hash.
#
class php::fpm (
$ensure = $::php::ensure,
$user = $::php::fpm_user,
$group = $::php::fpm_group,
$service_ensure = $::php::fpm_service_ensure,
$service_enable = $::php::fpm_service_enable,
$service_name = $::php::fpm_service_name,
$service_provider = $::php::fpm_service_provider,
$package = $::php::real_fpm_package,
$inifile = $::php::fpm_inifile,
$settings = $::php::real_settings,
$global_pool_settings = $::php::real_fpm_global_pool_settings,
$pools = $::php::real_fpm_pools,
$log_owner = $::php::log_owner,
$log_group = $::php::log_group,
String $ensure = $::php::ensure,
$user = $::php::fpm_user,
$group = $::php::fpm_group,
$service_ensure = $::php::fpm_service_ensure,
$service_enable = $::php::fpm_service_enable,
$service_name = $::php::fpm_service_name,
$service_provider = $::php::fpm_service_provider,
String $package = $::php::real_fpm_package,
Stdlib::Absolutepath $inifile = $::php::fpm_inifile,
Hash $settings = $::php::real_settings,
$global_pool_settings = $::php::real_fpm_global_pool_settings,
Hash $pools = $::php::real_fpm_pools,
$log_owner = $::php::log_owner,
$log_group = $::php::log_group,
) {

if ! defined(Class['php']) {
warning('php::fpm is private')
}

validate_string($ensure)
validate_string($package)
validate_absolute_path($inifile)
validate_hash($settings)
validate_hash($pools)

$real_settings = deep_merge($settings, hiera_hash('php::fpm::settings', {}))

# On FreeBSD fpm is not a separate package, but included in the 'php' package.
Expand Down
68 changes: 22 additions & 46 deletions manifests/fpm/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -71,54 +71,30 @@
# Path to fpm pid file
#
class php::fpm::config(
$config_file = $::php::params::fpm_config_file,
$user = $::php::params::fpm_user,
$group = $::php::params::fpm_group,
$inifile = $::php::params::fpm_inifile,
$pid_file = $::php::params::fpm_pid_file,
$settings = {},
$pool_base_dir = $::php::params::fpm_pool_dir,
$pool_purge = false,
$error_log = $::php::params::fpm_error_log,
$log_level = 'notice',
$emergency_restart_threshold = '0',
$emergency_restart_interval = '0',
$process_control_timeout = '0',
$process_max = '0',
$rlimit_files = undef,
$systemd_interval = undef,
$log_owner = $::php::params::fpm_user,
$log_group = $::php::params::fpm_group,
$log_dir_mode = '0770',
$root_group = $::php::params::root_group,
$syslog_facility = 'daemon',
$syslog_ident = 'php-fpm',
$config_file = $::php::params::fpm_config_file,
String $user = $::php::params::fpm_user,
String $group = $::php::params::fpm_group,
String $inifile = $::php::params::fpm_inifile,
$pid_file = $::php::params::fpm_pid_file,
Hash $settings = {},
Stdlib::Absolutepath $pool_base_dir = $::php::params::fpm_pool_dir,
$pool_purge = false,
String $error_log = $::php::params::fpm_error_log,
String $log_level = 'notice',
Integer $emergency_restart_threshold = 0,
Variant[Integer, Pattern[/^\d+[smhd]?$/]] $emergency_restart_interval = 0,
Variant[Integer, Pattern[/^\d+[smhd]?$/]] $process_control_timeout = 0,
Integer $process_max = 0,
$rlimit_files = undef,
Optional[Variant[Integer,Pattern[/^\d+[smhd]?$/]]] $systemd_interval = undef,
String $log_owner = $::php::params::fpm_user,
String $log_group = $::php::params::fpm_group,
Pattern[/^\d+$/] $log_dir_mode = '0770',
$root_group = $::php::params::root_group,
String $syslog_facility = 'daemon',
String $syslog_ident = 'php-fpm',
) inherits ::php::params {

validate_string($user)
validate_string($group)
validate_string($inifile)
validate_hash($settings)

$number_re = '^\d+$'
$interval_re = '^\d+[smhd]?$'

validate_absolute_path($pool_base_dir)
validate_string($error_log)
validate_string($log_level)
validate_re($emergency_restart_threshold, $number_re)
validate_re($emergency_restart_interval, $interval_re)
validate_re($process_control_timeout, $interval_re)
validate_string($log_owner)
validate_string($log_group)
validate_re($log_dir_mode, $number_re)
validate_string($syslog_facility)
validate_string($syslog_ident)

if $systemd_interval {
validate_re($systemd_interval, $interval_re)
}

if $caller_module_name != $module_name {
warning('php::fpm::config is private')
}
Expand Down
Loading

0 comments on commit 00a0b8f

Please sign in to comment.