From d78077b7ec1a3ab5f0a2f7e82c9f66e9c77cd5d8 Mon Sep 17 00:00:00 2001 From: Michael Arnold Date: Sat, 3 Aug 2013 16:39:44 -0700 Subject: [PATCH] Use puppetlabs/stdlib to validate inputs. --- .fixtures.yml | 2 +- Modulefile | 1 + manifests/init.pp | 13 +++++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/.fixtures.yml b/.fixtures.yml index 2257e31..d4c8fea 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -1,6 +1,6 @@ fixtures: repositories: -# "stdlib": "git://github.com/puppetlabs/puppetlabs-stdlib.git" + "stdlib": "git://github.com/puppetlabs/puppetlabs-stdlib.git" "shell_config": "http://tig.csail.mit.edu/git-public/shell_config.git/" symlinks: "smartd": "#{source_dir}" diff --git a/Modulefile b/Modulefile index a081fe7..2bd80cb 100644 --- a/Modulefile +++ b/Modulefile @@ -11,3 +11,4 @@ for detecting and identifying disks hiding behind an LSI MegaRAID/Dell PERC RAID controller (currently only implemented for Linux).' project_page 'http://tig.csail.mit.edu/wiki/TIG/PuppetAtCSAIL' dependency 'csail/shell_config', '>= 0.0.1' +dependency 'puppetlabs/stdlib', '>=2.3.0' diff --git a/manifests/init.pp b/manifests/init.pp index a74fe7e..d5465cc 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -121,6 +121,19 @@ $warning_schedule = $smartd::params::warning_schedule, $enable_monit = $smartd::params::enable_monit, ) inherits smartd::params { + # Validate our booleans + validate_bool($autoupdate) + validate_bool($devicescan) + validate_bool($enable_monit) + + # Validate our hashs + validate_hash($device_opts) + + # Validate our regexs + $states = [ '^daily$', '^once$', '^diminishing$', ] + validate_re($warning_schedule, $states, + '$warning_schedule must be either daily, once, or diminishing.') + case $ensure { 'present': { if $autoupdate {