Skip to content

Commit e1c3a24

Browse files
authored
Merge pull request #1530 from puppetlabs/fix-postgresql_default
Fix `postgresql::default()` return value for unknown parameters
2 parents f2f2754 + 4e15857 commit e1c3a24

File tree

2 files changed

+37
-4
lines changed

2 files changed

+37
-4
lines changed

functions/default.pp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ function postgresql::default(
88
) {
99
include postgresql::params
1010

11-
#search for the variable name in params first
12-
#then fall back to globals if not found
13-
pick( getvar("postgresql::params::${parameter_name}"),
14-
"postgresql::globals::${parameter_name}")
11+
# Search for the variable name in params.
12+
# params inherits from globals, so it will also catch these variables.
13+
pick(getvar("postgresql::params::${parameter_name}"))
1514
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# frozen_string_literal: true
2+
3+
require 'spec_helper'
4+
5+
describe 'postgresql::default' do
6+
let(:facts) do
7+
{
8+
'os' => {
9+
'family' => 'Debian',
10+
'name' => 'Debian',
11+
'release' => {
12+
'full' => '11.7',
13+
'major' => '11',
14+
'minor' => '7',
15+
}
16+
}
17+
}
18+
end
19+
20+
let(:pre_condition) do
21+
<<~PP
22+
class { 'postgresql::server':
23+
}
24+
PP
25+
end
26+
27+
# parameter in params.pp only
28+
it { is_expected.to run.with_params('port').and_return(5432) }
29+
30+
# parameter in globals.pp only
31+
it { is_expected.to run.with_params('default_connect_settings').and_return({}) }
32+
33+
it { is_expected.to run.with_params('a_parameter_that_does_not_exist').and_raise_error(Puppet::ParseError, %r{pick\(\): must receive at least one non empty value}) }
34+
end

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy