From e2b39a9e2140b9c57eb400145e476a14de826242 Mon Sep 17 00:00:00 2001 From: William Yardley Date: Wed, 20 Sep 2017 12:01:55 -0700 Subject: [PATCH] Switch to Puppet Data Types --- manifests/init.pp | 39 ++++++++++++++++-------------------- manifests/params.pp | 3 --- spec/classes/grafana_spec.rb | 10 --------- 3 files changed, 17 insertions(+), 35 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index c4f020343..9897d9819 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -73,30 +73,25 @@ # } # class grafana ( - $archive_source = $::grafana::params::archive_source, - $cfg_location = $::grafana::params::cfg_location, - $cfg = $::grafana::params::cfg, - $ldap_cfg = $::grafana::params::ldap_cfg, - $container_cfg = $::grafana::params::container_cfg, - $container_params = $::grafana::params::container_params, - $data_dir = $::grafana::params::data_dir, - $install_dir = $::grafana::params::install_dir, - $install_method = $::grafana::params::install_method, - $manage_package_repo = $::grafana::params::manage_package_repo, - $package_name = $::grafana::params::package_name, - $package_source = $::grafana::params::package_source, - $repo_name = $::grafana::params::repo_name, - $rpm_iteration = $::grafana::params::rpm_iteration, - $service_name = $::grafana::params::service_name, - $version = $::grafana::params::version, - $plugins = {} + Optional[String] $archive_source = undef, + String $cfg_location = $::grafana::params::cfg_location, + Hash $cfg = $::grafana::params::cfg, + Optional[Hash] $ldap_cfg = undef, + Boolean $container_cfg = $::grafana::params::container_cfg, + Hash $container_params = $::grafana::params::container_params, + String $data_dir = $::grafana::params::data_dir, + String $install_dir = $::grafana::params::install_dir, + String $install_method = $::grafana::params::install_method, + Boolean $manage_package_repo = $::grafana::params::manage_package_repo, + String $package_name = $::grafana::params::package_name, + Optional[String] $package_source = undef, + Enum['stable', 'testing'] $repo_name = $::grafana::params::repo_name, + String $rpm_iteration = $::grafana::params::rpm_iteration, + String $service_name = $::grafana::params::service_name, + String $version = $::grafana::params::version, + Hash $plugins = {} ) inherits grafana::params { - # validate parameters here - if !is_hash($cfg) { - fail('cfg parameter must be a hash') - } - contain grafana::install contain grafana::config contain grafana::service diff --git a/manifests/params.pp b/manifests/params.pp index 4407a1c5e..54ef4a05b 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -4,7 +4,6 @@ # It sets variables according to platform # class grafana::params { - $archive_source = undef $cfg = {} $container_cfg = false $container_params = {} @@ -12,9 +11,7 @@ $docker_image = 'grafana/grafana' $docker_ports = '3000:3000' $install_dir = '/usr/share/grafana' - $ldap_cfg = false $package_name = 'grafana' - $package_source = undef $rpm_iteration = '1' $repo_name = 'stable' $version = '4.5.1' diff --git a/spec/classes/grafana_spec.rb b/spec/classes/grafana_spec.rb index 46b870f93..71a9296cf 100644 --- a/spec/classes/grafana_spec.rb +++ b/spec/classes/grafana_spec.rb @@ -221,16 +221,6 @@ context 'invalid parameters' do context 'cfg' do - describe 'should raise an error when cfg parameter is not a hash' do - let(:params) do - { - cfg: [] - } - end - - it { expect { is_expected.to contain_package('grafana') }.to raise_error(Puppet::Error, %r{cfg parameter must be a hash}) } - end - describe 'should not raise an error when cfg parameter is a hash' do let(:params) do {