Skip to content

Commit

Permalink
Merge pull request #75 from bastelfreak/puppet4
Browse files Browse the repository at this point in the history
replace validate_* with datatypes in init
  • Loading branch information
wyardley authored Oct 21, 2017
2 parents fb0ad42 + 1f56e9e commit 1fb547f
Showing 1 changed file with 39 additions and 50 deletions.
89 changes: 39 additions & 50 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -112,63 +112,52 @@
# Sample Usage:
#
class prometheus (
$manage_user = true,
$user = $::prometheus::params::user,
$manage_group = true,
$purge_config_dir = true,
$group = $::prometheus::params::group,
$extra_groups = $::prometheus::params::extra_groups,
$bin_dir = $::prometheus::params::bin_dir,
$shared_dir = $::prometheus::params::shared_dir,
$arch = $::prometheus::params::arch,
$version = $::prometheus::params::version,
$install_method = $::prometheus::params::install_method,
$os = $::prometheus::params::os,
$download_url = undef,
$download_url_base = $::prometheus::params::download_url_base,
$download_extension = $::prometheus::params::download_extension,
$package_name = $::prometheus::params::package_name,
$package_ensure = $::prometheus::params::package_ensure,
$config_dir = $::prometheus::params::config_dir,
$localstorage = $::prometheus::params::localstorage,
$extra_options = '',
$config_hash = {},
$config_defaults = {},
$config_template = $::prometheus::params::config_template,
$config_mode = $::prometheus::params::config_mode,
$service_enable = true,
$service_ensure = 'running',
$manage_service = true,
$restart_on_change = true,
$init_style = $::prometheus::params::init_style,
$global_config = $::prometheus::params::global_config,
$rule_files = $::prometheus::params::rule_files,
$scrape_configs = $::prometheus::params::scrape_configs,
$alerts = $::prometheus::params::alerts,
$alert_relabel_config = $::prometheus::params::alert_relabel_config,
$alertmanagers_config = $::prometheus::params::alertmanagers_config,
Boolean $manage_user = true,
$user = $::prometheus::params::user,
$manage_group = true,
Boolean $purge_config_dir = true,
$group = $::prometheus::params::group,
$extra_groups = $::prometheus::params::extra_groups,
$bin_dir = $::prometheus::params::bin_dir,
$shared_dir = $::prometheus::params::shared_dir,
$arch = $::prometheus::params::arch,
$version = $::prometheus::params::version,
$install_method = $::prometheus::params::install_method,
$os = $::prometheus::params::os,
$download_url = undef,
$download_url_base = $::prometheus::params::download_url_base,
$download_extension = $::prometheus::params::download_extension,
$package_name = $::prometheus::params::package_name,
$package_ensure = $::prometheus::params::package_ensure,
$config_dir = $::prometheus::params::config_dir,
$localstorage = $::prometheus::params::localstorage,
$extra_options = '',
Hash $config_hash = {},
Hash $config_defaults = {},
$config_template = $::prometheus::params::config_template,
$config_mode = $::prometheus::params::config_mode,
$service_enable = true,
$service_ensure = 'running',
Boolean $manage_service = true,
Boolean $restart_on_change = true,
$init_style = $::prometheus::params::init_style,
Hash $global_config = $::prometheus::params::global_config,
Array $rule_files = $::prometheus::params::rule_files,
Array $scrape_configs = $::prometheus::params::scrape_configs,
$alerts = $::prometheus::params::alerts,
Array $alert_relabel_config = $::prometheus::params::alert_relabel_config,
Array $alertmanagers_config = $::prometheus::params::alertmanagers_config,
) inherits prometheus::params {

if( versioncmp($::prometheus::version, '1.0.0') == -1 ){
$real_download_url = pick($download_url,
$real_download_url = pick($download_url,
"${download_url_base}/download/${version}/${package_name}-${version}.${os}-${arch}.${download_extension}")
} else {
$real_download_url = pick($download_url,
$real_download_url = pick($download_url,
"${download_url_base}/download/v${version}/${package_name}-${version}.${os}-${arch}.${download_extension}")
}
validate_bool($purge_config_dir)
validate_bool($manage_user)
validate_bool($manage_service)
validate_bool($restart_on_change)
validate_hash($config_hash)
validate_hash($config_defaults)
validate_hash($global_config)
validate_array($rule_files)
validate_array($scrape_configs)
validate_array($alert_relabel_config)
validate_array($alertmanagers_config)

$config_hash_real = deep_merge($config_defaults, $config_hash)
validate_hash($config_hash_real)
$config_hash_real = assert_type(Hash, deep_merge($config_defaults, $config_hash))

anchor {'prometheus_first': }
-> class { '::prometheus::install': }
Expand Down

0 comments on commit 1fb547f

Please sign in to comment.