From 867f8c524af73e396dab64947ff4b3dff9032926 Mon Sep 17 00:00:00 2001 From: Jeff McCune Date: Thu, 26 May 2011 11:29:17 -0700 Subject: [PATCH] Change jre and jdk booleans to a single string Dan raised the comment in the previous patch set that it doesn't make sense to provide two options and four states when there are really only two possibilities; install the jre or the jdk. This change removes the jdk and jre class parameters and replaces them with a single distribution parameters. --- manifests/init.pp | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index f8dd0a2..de54142 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -12,33 +12,31 @@ # # [Remember: No empty lines between comments and class definition] class java( - $jre = false, - $jdk = true, - $version='1.6.0_25-fcs' + $distribution = 'jdk', + $version = 'installed' ) { # Cannot pass anonymous arrays to functions in 2.6.8 - $v_true_false = [ '^true$', '^false$' ] + $v_distribution = [ '^jre$', '^jdk$' ] # Must compare string values, not booleans. - validate_re("$jre", $v_true_false) - validate_re("$jdk", $v_true_false) validate_re($version, '^[._0-9a-zA-Z:-]+$') + validate_re($distribution, $v_distribution) - $jre_real = $jre - $jdk_real = $jdk - $version_real = $version + $version_real = $version + $distribution_real = $distribution - if $jre_real { - class { 'java::jre_package': - version => $version_real, - stage => 'runtime', + case $distribution_real { + jre: { + class { 'java::jre_package': + version => $version_real, + stage => 'runtime', + } } - } - - if $jdk_real { - class { 'java::jdk_package': - version => $version_real, - stage => 'runtime', + jdk: { + class { 'java::jdk_package': + version => $version_real, + stage => 'runtime', + } } }