Skip to content

Commit

Permalink
Fix Datatype-Mismatch
Browse files Browse the repository at this point in the history
The Variant of $track_script's Datatype
```
Variant[Array[String[1]],String[1]] $track_script
```

has to get handled correctly in the ERB-File.  Otherwise it fails with a
single String.

fixes 4307d70
  • Loading branch information
cocker-cc committed Mar 18, 2024
1 parent 214d490 commit 350e64c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
4 changes: 3 additions & 1 deletion REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -1197,7 +1197,9 @@ Default value: `undef`

Data type: `Variant[Array[String[1]],String[1]]`

Define which script to run to track service states.
Define which scripts to run to track service states.
May be specified either as a String with a single Scriptname,
or as an Array of Strings with multiple Scriptnames.

Default value: `[]`

Expand Down
4 changes: 3 additions & 1 deletion manifests/vrrp/instance.pp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@
# Authentication password.
#
# @param track_script
# Define which script to run to track service states.
# Define which scripts to run to track service states.
# May be specified either as a String with a single Scriptname,
# or as an Array of Strings with multiple Scriptnames.
#
# @param track_process
# Define which process trackers to run.
Expand Down
19 changes: 18 additions & 1 deletion spec/defines/keepalived_vrrp_instance_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@
}
end

describe 'with parameter track_script' do
describe 'with parameter track_script as an Array of Strings' do
let(:params) do
mandatory_params.merge(
track_script: ['_VALUE_']
Expand All @@ -370,6 +370,23 @@
}
end

describe 'with parameter track_script as a single String' do
let(:params) do
mandatory_params.merge(
track_script: '_VALUE_'
)
end

it { is_expected.to create_keepalived__vrrp__instance('_NAME_') }

it {
is_expected.to \
contain_concat__fragment('keepalived.conf_vrrp_instance__NAME_').with(
'content' => %r!^ track_script {\n _VALUE_!
)
}
end

describe 'with parameter lvs_interface' do
let(:params) do
mandatory_params.merge(
Expand Down
2 changes: 1 addition & 1 deletion templates/vrrp_instance.erb
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ vrrp_instance <%= @_name %> {
<%- unless @track_script.empty? -%>

track_script {
<%- @track_script.each do |track| -%>
<%- Array(@track_script).flatten.each do |track| -%>
<%= track %>
<%- end -%>
}
Expand Down

0 comments on commit 350e64c

Please sign in to comment.