Skip to content

Commit 40fb0eb

Browse files
committed
Address post-merge comments on PR voxpupuli#224
Removes declaration of Class[splunk::params] since it should already be in scope and declared by either Class[splunk::enterprise] or Class[splunk::forwarder] and removes an unnecessary test of an empty hash. Modifies Splunk::Addon spec test to address the removal of Class[splunk::params].
1 parent 820a15b commit 40fb0eb

File tree

2 files changed

+23
-25
lines changed

2 files changed

+23
-25
lines changed

manifests/addon.pp

+20-25
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@
4343
Hash $inputs = {},
4444
) {
4545

46-
include splunk::params
47-
4846
if defined(Class['splunk::forwarder']) {
4947
$mode = 'forwarder'
5048
} else {
@@ -53,8 +51,7 @@
5351

5452
if $splunk_home {
5553
$_splunk_home = $splunk_home
56-
}
57-
else {
54+
} else {
5855
case $mode {
5956
'forwarder': { $_splunk_home = $splunk::params::forwarder_homedir }
6057
'enterprise': { $_splunk_home = $splunk::params::enterprise_homedir }
@@ -84,30 +81,28 @@
8481

8582
file { "${_splunk_home}/etc/apps/${name}/local": ensure => directory }
8683

87-
unless $inputs.empty {
88-
$inputs.each |$section, $attributes| {
89-
$attributes.each |$setting, $value| {
90-
case $mode {
91-
'forwarder': {
92-
splunkforwarder_input { "${name}_${section}_${setting}":
93-
section => $section,
94-
setting => $setting,
95-
value => $value,
96-
context => "apps/${name}/local",
97-
require => File["${_splunk_home}/etc/apps/${name}/local"],
98-
}
84+
$inputs.each |$section, $attributes| {
85+
$attributes.each |$setting, $value| {
86+
case $mode {
87+
'forwarder': {
88+
splunkforwarder_input { "${name}_${section}_${setting}":
89+
section => $section,
90+
setting => $setting,
91+
value => $value,
92+
context => "apps/${name}/local",
93+
require => File["${_splunk_home}/etc/apps/${name}/local"],
9994
}
100-
'enterprise': {
101-
splunk_input { "${name}_${section}_${setting}":
102-
section => $section,
103-
setting => $setting,
104-
value => $value,
105-
context => "apps/${name}/local",
106-
require => File["${_splunk_home}/etc/apps/${name}/local"],
107-
}
95+
}
96+
'enterprise': {
97+
splunk_input { "${name}_${section}_${setting}":
98+
section => $section,
99+
setting => $setting,
100+
value => $value,
101+
context => "apps/${name}/local",
102+
require => File["${_splunk_home}/etc/apps/${name}/local"],
108103
}
109-
default: { fail('Instances of Splunk::Addon require the declaration of one of either Class[splunk::enterprise] or Class[splunk::forwarder]') }
110104
}
105+
default: { fail('Instances of Splunk::Addon require the declaration of one of either Class[splunk::enterprise] or Class[splunk::forwarder]') }
111106
}
112107
}
113108
}

spec/defines/addon_spec.rb

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
describe 'splunk::addon' do
44
context 'supported operating systems' do
5+
let(:pre_condition) do
6+
'include splunk::forwarder'
7+
end
58
on_supported_os.each do |os, facts|
69
if os.start_with?('windows')
710
# Splunk Server not used supported on windows

0 commit comments

Comments
 (0)