1
0
mirror of https://github.com/krislamo/puppet-fluentd synced 2024-12-16 13:20:35 +00:00

Merge pull request #24 from wycore/puppet4

migrate from stdlib validation to puppet datatypes
This commit is contained in:
Christian Becker 2018-01-16 18:36:46 +01:00 committed by GitHub
commit 0023cc7902
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 32 additions and 62 deletions

View File

@ -38,23 +38,16 @@
# Copyright 2015 wywy, unless otherwise noted. # Copyright 2015 wywy, unless otherwise noted.
# #
define fluentd::filter ( define fluentd::filter (
$ensure = present, Enum['present', 'absent'] $ensure = present,
$priority = 20, Integer $priority = 20,
$pattern = '**', String $pattern = '**',
$config = {}, Hash $config = {},
) { ) {
# parameter validation
if ! ($ensure in [ 'present', 'absent' ]) {
fail('ensure parameter must be present or absent')
}
validate_integer($priority)
validate_string($pattern)
validate_hash($config)
fluentd::config::file { "filter-${title}": fluentd::config::file { "filter-${title}":
ensure => $ensure, ensure => $ensure,
priority => $priority, priority => $priority,
content => template( 'fluentd/filter.erb'), content => template( 'fluentd/filter.erb'),
} }
} }

View File

@ -65,37 +65,24 @@
# Copyright 2015 wywy, unless otherwise noted. # Copyright 2015 wywy, unless otherwise noted.
# #
class fluentd ( class fluentd (
$repo_manage = $::fluentd::params::repo_manage, Boolean $repo_manage = $::fluentd::params::repo_manage,
$package_ensure = $::fluentd::params::package_ensure, String $package_ensure = $::fluentd::params::package_ensure,
$package_name = $::fluentd::params::package_name, String $package_name = $::fluentd::params::package_name,
$package_install_options = $::fluentd::params::package_install_options, Array $package_install_options = $::fluentd::params::package_install_options,
$service_manage = $::fluentd::params::service_manage, Boolean $service_manage = $::fluentd::params::service_manage,
$service_name = $::fluentd::params::service_name, String $service_name = $::fluentd::params::service_name,
$service_ensure = $::fluentd::params::service_ensure, Enum['running', 'stopped'] $service_ensure = $::fluentd::params::service_ensure,
$service_enable = $::fluentd::params::service_enable, Boolean $service_enable = $::fluentd::params::service_enable,
$config_path = $::fluentd::params::config_path, String $config_path = $::fluentd::params::config_path,
$conf_dir = $::fluentd::params::conf_dir, String $conf_dir = $::fluentd::params::conf_dir,
$config_file = $::fluentd::params::config_file, String $config_file = $::fluentd::params::config_file,
$conf_dir_manage = $::fluentd::params::conf_dir_manage, Boolean $conf_dir_manage = $::fluentd::params::conf_dir_manage,
$user_manage = $::fluentd::params::user_manage, Boolean $user_manage = $::fluentd::params::user_manage,
$user_name = $::fluentd::params::user_name, String $user_name = $::fluentd::params::user_name,
$user_group = $::fluentd::params::user_group, String $user_group = $::fluentd::params::user_group,
$user_groups = $::fluentd::params::user_groups, Array $user_groups = $::fluentd::params::user_groups,
) inherits fluentd::params { ) inherits fluentd::params {
# parameter validation
validate_bool($repo_manage)
validate_string($package_ensure)
validate_string($package_name)
validate_array($package_install_options)
validate_bool($service_manage)
validate_string($service_name)
validate_bool($service_enable)
if ! ($service_ensure in [ 'running', 'stopped' ]) {
fail('service_ensure parameter must be running or stopped')
}
# class calls # class calls
include '::fluentd::repo' include '::fluentd::repo'
include '::fluentd::install' include '::fluentd::install'

View File

@ -43,23 +43,16 @@
# Copyright 2015 wywy, unless otherwise noted. # Copyright 2015 wywy, unless otherwise noted.
# #
define fluentd::match ( define fluentd::match (
$ensure = present, Enum['present', 'absent'] $ensure = present,
$priority = 30, Integer $priority = 30,
$pattern = '**', String $pattern = '**',
$config = {}, Hash $config = {},
) { ) {
# parameter validation
if ! ($ensure in [ 'present', 'absent' ]) {
fail('ensure parameter must be present or absent')
}
validate_integer($priority)
validate_string($pattern)
validate_hash($config)
fluentd::config::file { "match-${title}": fluentd::config::file { "match-${title}":
ensure => $ensure, ensure => $ensure,
priority => $priority, priority => $priority,
content => template( 'fluentd/match.erb'), content => template( 'fluentd/match.erb'),
} }
} }

View File

@ -26,9 +26,9 @@
# Copyright 2015 wywy, unless otherwise noted. # Copyright 2015 wywy, unless otherwise noted.
# #
define fluentd::plugin ( define fluentd::plugin (
$ensure = present, String $ensure = present,
$type = 'gem', String $type = 'gem',
$source = undef, Optional[String] $source = undef,
) { ) {
case $type { case $type {
@ -43,7 +43,6 @@ define fluentd::plugin (
if ! ($ensure in [ 'present', 'absent' ]) { if ! ($ensure in [ 'present', 'absent' ]) {
fail('ensure parameter must be present or absent') fail('ensure parameter must be present or absent')
} }
validate_string($source)
fluentd::plugin::file { $name: fluentd::plugin::file { $name:
ensure => $ensure, ensure => $ensure,

View File

@ -34,17 +34,15 @@
# Copyright 2015 wywy, unless otherwise noted. # Copyright 2015 wywy, unless otherwise noted.
# #
define fluentd::source ( define fluentd::source (
$ensure = present, String $ensure = present,
$priority = 10, Integer $priority = 10,
$config = {}, Hash $config = {},
) { ) {
# parameter validation # parameter validation
if ! ($ensure in [ 'present', 'absent' ]) { if ! ($ensure in [ 'present', 'absent' ]) {
fail('ensure parameter must be present or absent') fail('ensure parameter must be present or absent')
} }
validate_integer($priority)
validate_hash($config)
fluentd::config::file { "source-${title}": fluentd::config::file { "source-${title}":
ensure => $ensure, ensure => $ensure,