From a16116f1704ae835ce8a0e13550914a710c19883 Mon Sep 17 00:00:00 2001 From: Chris Denneen Date: Tue, 20 Mar 2018 15:38:28 -0400 Subject: [PATCH] Updating with Type support --- manifests/ca.pp | 15 ++++++--------- manifests/init.pp | 15 ++++++--------- spec/classes/ca_cert_spec.rb | 8 ++++---- 3 files changed, 16 insertions(+), 22 deletions(-) diff --git a/manifests/ca.pp b/manifests/ca.pp index c56618e..0306df5 100644 --- a/manifests/ca.pp +++ b/manifests/ca.pp @@ -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') } diff --git a/manifests/init.pp b/manifests/init.pp index 47af1da..31138da 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -37,20 +37,17 @@ # Phil Fenstermacher # 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, diff --git a/spec/classes/ca_cert_spec.rb b/spec/classes/ca_cert_spec.rb index 7628f2e..00b1317 100644 --- a/spec/classes/ca_cert_spec.rb +++ b/spec/classes/ca_cert_spec.rb @@ -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( @@ -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( @@ -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( @@ -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(