Skip to content

Commit

Permalink
Updating with Type support (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
cdenneen authored and pcfens committed Mar 20, 2018
1 parent bd26154 commit d2d355a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 22 deletions.
15 changes: 6 additions & 9 deletions manifests/ca.pp
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,16 @@
# }

define ca_cert::ca (
$ca_text = undef,
$source = 'text',
$ensure = 'trusted',
$verify_https_cert = true,
$checksum = undef,
$ca_file_mode = $ca_cert::params::ca_file_mode,
Optional[String] $ca_text = undef,
String $source = 'text',
String $ensure = 'trusted',
Boolean $verify_https_cert = true,
Optional[String] $checksum = undef,
String $ca_file_mode = $ca_cert::params::ca_file_mode,
) {

include ::ca_cert::params

validate_string($source)
validate_bool($verify_https_cert)

if ($ensure == 'trusted' or $ensure == 'distrusted') and $source == 'text' and !is_string($ca_text) {
fail('ca_text is required if source is set to text')
}
Expand Down
15 changes: 6 additions & 9 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,17 @@
# Phil Fenstermacher <[email protected]>
#
class ca_cert (
$always_update_certs = false,
$purge_unmanaged_CAs = false,
$install_package = true,
$ca_certs = {},
$package_ensure = present,
$package_name = $ca_cert::params::package_name,
Boolean $always_update_certs = false,
Boolean $purge_unmanaged_CAs = false,
Boolean $install_package = true,
Hash $ca_certs = {},
String $package_ensure = present,
String $package_name = $ca_cert::params::package_name,
) inherits ca_cert::params {

include ::ca_cert::params
include ::ca_cert::update

validate_bool($always_update_certs)
validate_hash($ca_certs)

if $always_update_certs == true {
Exec <| title=='ca_cert_update' |> {
refreshonly => false,
Expand Down
8 changes: 4 additions & 4 deletions spec/classes/ca_cert_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
context "with purge_unmanaged_CAs set to true" do
let :params do
{
:purge_unmanaged_CAs => 'true',
:purge_unmanaged_CAs => true,
}
end
it { is_expected.to contain_file("trusted_certs").with(
Expand Down Expand Up @@ -65,7 +65,7 @@
context "with purge_unmanaged_CAs set to true" do
let :params do
{
:purge_unmanaged_CAs => 'true',
:purge_unmanaged_CAs => true,
}
end
it { is_expected.to contain_file("trusted_certs").with(
Expand Down Expand Up @@ -102,7 +102,7 @@
context "with purge_unmanaged_CAs set to true" do
let :params do
{
:purge_unmanaged_CAs => 'true',
:purge_unmanaged_CAs => true,
}
end
it { is_expected.to contain_file("trusted_certs").with(
Expand Down Expand Up @@ -139,7 +139,7 @@
context "with purge_unmanaged_CAs set to true" do
let :params do
{
:purge_unmanaged_CAs => 'true',
:purge_unmanaged_CAs => true,
}
end
it { is_expected.to contain_file("trusted_certs").with(
Expand Down

0 comments on commit d2d355a

Please sign in to comment.