Commit 10456575 authored by Christian Kaenzig's avatar Christian Kaenzig Committed by GitHub
Browse files

Merge pull request #154 from ckaenzig/fix-params-validation

Fix params validation + specs
parents 9048b697 4fa44f58
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -56,7 +56,6 @@ define postfix::conffile (
  validate_absolute_path($path)
  if !is_string($source) and !is_array($source) { fail("value for source should be either String type or Array type got ${source}") }
  if !is_string($content) { fail("value for content should be String type; got ${content}") }
  validate_string($ensure)
  validate_re($ensure, ['present', 'absent', 'directory'],
    "\$ensure must be either 'present', 'absent' or 'directory', got '${ensure}'")
  validate_hash($options)
+0 −2
Original line number Diff line number Diff line
@@ -29,11 +29,9 @@
#
define postfix::config ($value = undef, $ensure = 'present') {

  validate_string($ensure)
  validate_re($ensure, ['present', 'absent', 'blank'],
    "\$ensure must be either 'present', 'absent' or 'blank', got '${ensure}'")
  if ($ensure == 'present') {
    validate_string($value)
    validate_re($value, '^.+$',
      '$value can not be empty if ensure = present')
  }
+9 −3
Original line number Diff line number Diff line
@@ -5,6 +5,8 @@ class postfix::files {
  $inet_interfaces     = $postfix::inet_interfaces
  $mail_user           = $postfix::mail_user
  $manage_conffiles    = $postfix::manage_conffiles
  $maincf_source       = $postfix::maincf_source
  $mastercf_source     = $postfix::mastercf_source
  $master_smtp         = $postfix::master_smtp
  $master_smtps        = $postfix::master_smtps
  $master_submission   = $postfix::master_submission
@@ -17,6 +19,10 @@ class postfix::files {
  $use_schleuder       = $postfix::use_schleuder
  $use_sympa           = $postfix::use_sympa

  validate_string($mastercf_source)
  validate_string($master_smtp)
  validate_string($master_smtps)

  File {
    replace => $manage_conffiles,
  }
@@ -45,7 +51,7 @@ class postfix::files {
  }

  # Config files
  if $postfix::mastercf_source {
  if $mastercf_source {
    $mastercf_content = undef
  } else {
    $mastercf_content = template(
@@ -61,7 +67,7 @@ class postfix::files {
    mode    => '0644',
    owner   => 'root',
    seltype => $postfix::params::seltype,
    source  => $postfix::mastercf_source,
    source  => $mastercf_source,
  }

  # Config files
@@ -72,7 +78,7 @@ class postfix::files {
    owner   => 'root',
    replace => false,
    seltype => $postfix::params::seltype,
    source  => $postfix::maincf_source,
    source  => $maincf_source,
  }

  ::postfix::config {
+0 −3
Original line number Diff line number Diff line
@@ -31,11 +31,8 @@ define postfix::hash (
  include ::postfix::params

  validate_absolute_path($name)
#  validate_string($source)
#  validate_string($content)
  if !is_string($source) and !is_array($source) { fail("value for source should be either String type or Array type got ${source}") }
  if !is_string($content) and !is_array($content) { fail("value for source should be either String type or Array type got ${content}") }
  validate_string($ensure)
  validate_re($ensure, ['present', 'absent'],
    "\$ensure must be either 'present' or 'absent', got '${ensure}'")

+0 −7
Original line number Diff line number Diff line
@@ -118,14 +118,7 @@ class postfix (

  validate_string($alias_maps)
  validate_string($inet_interfaces)
  validate_string($ldap_base)
  validate_string($ldap_host)
  validate_string($ldap_options)
  validate_string($mail_user)
  validate_string($maincf_source)
  validate_string($mastercf_source)
  validate_string($master_smtp)
  validate_string($master_smtps)
  validate_string($mydestination)
  validate_string($mynetworks)
  validate_string($myorigin)
Loading