Skip to content
This repository has been archived by the owner on Jun 21, 2018. It is now read-only.

Commit

Permalink
Revisit parameter validation
Browse files Browse the repository at this point in the history
* Remove calls to deprecated validate_* functions
  Replace regex validation with !~ comparison
* Remove string/bool/hash/array validations
  Not truly relevant anyway
  "Puppet 3 deprecation is coming"
  • Loading branch information
antoineco committed Jan 12, 2017
1 parent afdb18d commit cb78fef
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
14 changes: 9 additions & 5 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,15 @@
}

# parameters validation
validate_re($version, '^([0-9]|[0-9]u[0-9]{1,3})$', '$version must be formated as \'major\'u\'minor\' or just \'major\'')
validate_re($type, '^(jre|jdk)$', '$type must be either \'jre\' or \'jdk\'')
validate_re($format_real, '^(rpm|tar\.gz)$', '$format must be either \'rpm\' or \'tar.gz\'')
validate_bool($check_checksum, $add_alternative)
validate_absolute_path($install_path)
if $version !~ /^([0-9]|[0-9]u[0-9]{1,3})$/ {
fail('$version must be formated as \'major\'u\'minor\' or just \'major\'')
}
if $type !~ /^(jre|jdk)$/ {
fail('$type must be either \'jre\' or \'jdk\'')
}
if $format_real !~ /^(rpm|tar\.gz)$/ {
fail('$format must be either \'rpm\' or \'tar.gz\'')
}

# set to latest release if no minor version was provided
if $version == '8' {
Expand Down
9 changes: 6 additions & 3 deletions manifests/installation.pp
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,12 @@
$install_path = $oracle_java::install_path

# parameters validation
validate_re($version, '^([0-9]|[0-9]u[0-9]{1,3})$', '$version must be formated as \'major\'u\'minor\' or just \'major\'')
validate_re($type, '^(jre|jdk)$', '$type must be either \'jre\' or \'jdk\'')
validate_bool($check_checksum, $add_alternative)
if $version !~ /^([0-9]|[0-9]u[0-9]{1,3})$/ {
fail('$version must be formated as \'major\'u\'minor\' or just \'major\'')
}
if $type !~ /^(jre|jdk)$/ {
fail('$type must be either \'jre\' or \'jdk\'')
}

# set to latest release if no minor version was provided
if $version == '8' {
Expand Down

0 comments on commit cb78fef

Please sign in to comment.