Showing with 17 additions and 38 deletions.
  1. +1 −1 .travis.yml
  2. +1 −0 Gemfile
  3. +0 −11 Modulefile
  4. +10 −18 manifests/init.pp
  5. +3 −6 metadata.json
  6. +2 −2 spec/classes/init_spec.rb
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ env:

sudo: false

script: 'bundle exec rake validate && bundle exec rake lint && SPEC_OPTS="--format documentation" bundle exec rake spec'
script: 'bundle exec metadata-json-lint metadata.json && bundle exec rake validate && bundle exec rake lint && SPEC_OPTS="--format documentation" bundle exec rake spec'

matrix:
fast_finish: true
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ else
gem 'puppet', :require => false
end

gem 'metadata-json-lint'
gem 'puppetlabs_spec_helper', '>= 0.1.0'
gem 'puppet-lint', '>= 1.0.0'
gem 'facter', '>= 1.7.0'
Expand Down
11 changes: 0 additions & 11 deletions Modulefile

This file was deleted.

28 changes: 10 additions & 18 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -21,48 +21,42 @@


# validate type and convert string to boolean if necessary
$collect_all_type = type($collect_all)
if $collect_all_type == 'string' {
if is_string($collect_all) {
$collect_all_real = str2bool($collect_all)
} else {
$collect_all_real = $collect_all
}

# validate type and convert string to boolean if necessary
$enable_ipv4_localhost_type = type($enable_ipv4_localhost)
if $enable_ipv4_localhost_type == 'string' {
if is_string($enable_ipv4_localhost) {
$ipv4_localhost_enabled = str2bool($enable_ipv4_localhost)
} else {
$ipv4_localhost_enabled = $enable_ipv4_localhost
}

# validate type and convert string to boolean if necessary
$enable_ipv6_localhost_type = type($enable_ipv6_localhost)
if $enable_ipv6_localhost_type == 'string' {
if is_string($enable_ipv6_localhost) {
$ipv6_localhost_enabled = str2bool($enable_ipv6_localhost)
} else {
$ipv6_localhost_enabled = $enable_ipv6_localhost
}

# validate type and convert string to boolean if necessary
$enable_fqdn_entry_type = type($enable_fqdn_entry)
if $enable_fqdn_entry_type == 'string' {
if is_string($enable_fqdn_entry) {
$fqdn_entry_enabled = str2bool($enable_fqdn_entry)
} else {
$fqdn_entry_enabled = $enable_fqdn_entry
}

# validate type and convert string to boolean if necessary
$use_fqdn_type = type($use_fqdn)
if $use_fqdn_type == 'string' {
if is_string($use_fqdn) {
$use_fqdn_real = str2bool($use_fqdn)
} else {
$use_fqdn_real = $use_fqdn
}

# validate type and convert string to boolean if necessary
$purge_hosts_type = type($purge_hosts)
if $purge_hosts_type == 'string' {
if is_string($purge_hosts) {
$purge_hosts_enabled = str2bool($purge_hosts)
} else {
$purge_hosts_enabled = $purge_hosts
Expand All @@ -88,14 +82,12 @@
$my_localhost6_aliases = undef
}

$my_localhost_aliases_type = type($my_localhost_aliases)
if $my_localhost_aliases_type != 'string' and $my_localhost_aliases_type != 'array' {
fail("hosts::localhost_aliases must be a string or an array. Detected type is <${my_localhost_aliases_type}>.")
if !is_string($my_localhost_aliases) and !is_array($my_localhost_aliases) {
fail("hosts::localhost_aliases must be a string or an array.")
}

$my_localhost6_aliases_type = type($my_localhost6_aliases)
if $my_localhost6_aliases_type != 'string' and $my_localhost6_aliases_type != 'array' {
fail("hosts::localhost6_aliases must be a string or an array. Detected type is <${my_localhost6_aliases_type}>.")
if !is_string($my_localhost6_aliases) and !is_array($my_localhost6_aliases) {
fail("hosts::localhost6_aliases must be a string or an array.")
}

if $fqdn_entry_enabled == true {
Expand Down
9 changes: 3 additions & 6 deletions metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ghoneycutt-hosts",
"version": "2.2.2",
"version": "2.2.3",
"author": "ghoneycutt",
"summary": "Manages host entries",
"license": "Apache-2.0",
Expand All @@ -10,7 +10,7 @@
"requirements": [
{
"name": "pe",
"version_requirement": "3.2.x"
"version_requirement": "3.x"
},
{
"name": "puppet",
Expand Down Expand Up @@ -47,10 +47,7 @@
}
],
"description": "Can ensure entries for localhost, localhost6, and $::fqdn,\nincluding aliases and optionally purge unmanaged entries.",
"types": [

],
"dependencies": [
{"name":"puppetlabs/stdlib","version_requirement":">= 3.2.0"}
{"name":"puppetlabs/stdlib","version_requirement":">= 3.2.0 < 5.0.0"}
]
}
4 changes: 2 additions & 2 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@
it 'should fail' do
expect {
should contain_class('hosts')
}.to raise_error(Puppet::Error,/hosts::localhost_aliases must be a string or an array. Detected type is <boolean>./)
}.to raise_error(Puppet::Error,/hosts::localhost_aliases must be a string or an array./)
end
end
end
Expand Down Expand Up @@ -447,7 +447,7 @@
it 'should fail' do
expect {
should contain_class('hosts')
}.to raise_error(Puppet::Error,/hosts::localhost6_aliases must be a string or an array. Detected type is <boolean>./)
}.to raise_error(Puppet::Error,/hosts::localhost6_aliases must be a string or an array./)
end
end
end
Expand Down